diff --git a/app/[locale]/(protected)/dashboard/routine-task/components/columns.tsx b/app/[locale]/(protected)/dashboard/routine-task/components/columns.tsx index 61cbd6c9..4ccafa03 100644 --- a/app/[locale]/(protected)/dashboard/routine-task/components/columns.tsx +++ b/app/[locale]/(protected)/dashboard/routine-task/components/columns.tsx @@ -2,7 +2,7 @@ import * as React from "react"; import { ColumnDef } from "@tanstack/react-table"; import { Eye, MoreVertical, SquarePen, Trash2 } from "lucide-react"; -import { cn } from "@/lib/utils"; +import { cn, getCookiesDecrypt } from "@/lib/utils"; import { DropdownMenu, DropdownMenuContent, @@ -13,6 +13,8 @@ import { Button } from "@/components/ui/button"; import { format } from "date-fns"; import { Link } from "@/i18n/routing"; +const userLevelId = getCookiesDecrypt("ulie"); + const columns: ColumnDef[] = [ { accessorKey: "no", @@ -120,9 +122,27 @@ const columns: ColumnDef[] = [ Ditolak: "text-red-500 border-red-500", }; + const colors = [ + "text-orange-500 border-orange-500", + "text-orange-500 border-orange-500", + "text-green-500 border-green-500", + "text-blue-500 border-blue-500", + "text-red-500 border-red-500", + ]; + + const status = + Number(row.original?.statusId) == 2 && + row.original?.reviewedAtLevel !== null && + !row.original?.reviewedAtLevel?.includes(`:${userLevelId}:`) && + Number(row.original?.creatorGroupLevelId) != Number(userLevelId) + ? "1" + : row.original?.statusId; + // Mendapatkan kelas warna dari mapping, default ke abu-abu jika tidak ditemukan const buttonClass = - colorMapping[statusName] || "text-gray-500 border-gray-500"; + colors[Number(status)] || "text-gray-500 border-gray-500"; + // const buttonClass = + // colorMapping[statusName] || "text-gray-500 border-gray-500"; return (
@@ -131,7 +151,18 @@ const columns: ColumnDef[] = [ variant="outline" className={`btn btn-sm pill-btn ml-1 ${buttonClass}`} > - {statusName || "Tidak Diketahui"} + {(Number(row.original?.statusId) == 2 && + !row.original?.reviewedAtLevel !== null && + !row.original?.reviewedAtLevel?.includes( + `:${Number(userLevelId)}:` + ) && + Number(row.original?.creatorGroupLevelId) != + Number(userLevelId)) || + (Number(row.original?.statusId) == 1 && + Number(row.original?.needApprovalFromLevel) == + Number(userLevelId)) + ? "Menunggu Review" + : row.original?.statusName}{" "}
); diff --git a/components/form/content/audio-detail-form.tsx b/components/form/content/audio-detail-form.tsx index a6bc9eae..d3f28fb7 100644 --- a/components/form/content/audio-detail-form.tsx +++ b/components/form/content/audio-detail-form.tsx @@ -316,19 +316,20 @@ export default function FormAudioDetail() { Number(status) == 2 || Number(status) == 4 ) { - MySwal.fire({ - title: "Simpan Approval", - text: "", - icon: "warning", - showCancelButton: true, - cancelButtonColor: "#d33", - confirmButtonColor: "#3085d6", - confirmButtonText: "Simpan", - }).then((result) => { - if (result.isConfirmed) { - save(); - } - }); + save(); + + // MySwal.fire({ + // title: "Simpan Approval", + // text: "", + // icon: "warning", + // showCancelButton: true, + // cancelButtonColor: "#d33", + // confirmButtonColor: "#3085d6", + // confirmButtonText: "Simpan", + // }).then((result) => { + // if (result.isConfirmed) { + // } + // }); } }; @@ -353,7 +354,7 @@ export default function FormAudioDetail() { // files: [], files: isUserMabesApprover ? getPlacement() : [], }; - + setModalOpen(false); loading(); const response = await submitApproval(data); @@ -568,7 +569,7 @@ export default function FormAudioDetail() {
- +
@@ -670,39 +671,6 @@ export default function FormAudioDetail() { ) : ( "" )} */} - {Number(detail?.needApprovalFromLevel) == Number(userLevelId) ? ( - Number(detail?.uploadedById) == Number(userId) ? ( - "" - ) : ( -
- - - -
- ) - ) : ( - "" - )} @@ -715,7 +683,18 @@ export default function FormAudioDetail() { key={file.id} className="flex flex-row gap-2 items-center" > - + {/* */} + + + {" "}
{file.fileName} @@ -904,6 +883,39 @@ export default function FormAudioDetail() {
+ {Number(detail?.needApprovalFromLevel) == Number(userLevelId) ? ( + Number(detail?.uploadedById) == Number(userId) ? ( + "" + ) : ( +
+ + + +
+ ) + ) : ( + "" + )}
) : ( diff --git a/components/form/content/audio-form.tsx b/components/form/content/audio-form.tsx index 3ff74041..8da158ab 100644 --- a/components/form/content/audio-form.tsx +++ b/components/form/content/audio-form.tsx @@ -148,6 +148,9 @@ export default function FormAudio() { onDrop: (acceptedFiles) => { setFiles(acceptedFiles.map((file) => Object.assign(file))); }, + accept: { + "audio/*": [], + }, }); const audioSchema = z.object({ @@ -668,7 +671,18 @@ export default function FormAudio() { className=" flex justify-between border px-3.5 py-3 my-6 rounded-md" >
-
{renderFilePreview(file)}
+ {/*
{renderFilePreview(file)}
*/} + + + {" "}
{file.name}
@@ -1015,12 +1029,12 @@ export default function FormAudio() {
{fileList}
-
+ {/*
-
+
*/} @@ -723,12 +738,12 @@ export default function FormAudioUpdate() {
{fileList}
-
+ {/*
-
+
*/} {/* +
+ ))} + {/* {files.length > 0 && (
- )} + )} */}
- +
@@ -930,14 +997,14 @@ export default function FormAudioUpdate() { ))}
-
+ {/*

{t("suggestion-box")} (0)

{t("information")}:

- {/*

{detail?.status}

*/} -
+

{detail?.status}

+
*/}
diff --git a/components/form/content/image-detail-form.tsx b/components/form/content/image-detail-form.tsx index cc0b1e5a..3cd600ca 100644 --- a/components/form/content/image-detail-form.tsx +++ b/components/form/content/image-detail-form.tsx @@ -333,6 +333,8 @@ export default function FormImageDetail() { message: description, files: isUserMabesApprover ? getPlacement() : [], }; + + setModalOpen(false); loading(); const response = await submitApproval(data); @@ -551,7 +553,7 @@ export default function FormImageDetail() {
- +
@@ -695,40 +697,6 @@ export default function FormImageDetail() { ) : ( "" )} */} - {Number(detail?.needApprovalFromLevel) == Number(userLevelId) ? ( - Number(detail?.uploadedById) == Number(userId) ? ( - "" - ) : ( -
- - - -
- ) - ) : ( - "" - )} @@ -939,6 +907,40 @@ export default function FormImageDetail() { + {Number(detail?.needApprovalFromLevel) == Number(userLevelId) ? ( + Number(detail?.uploadedById) == Number(userId) ? ( + "" + ) : ( +
+ + + +
+ ) + ) : ( + "" + )}
) : ( diff --git a/components/form/content/image-form.tsx b/components/form/content/image-form.tsx index 669abf69..58933e16 100644 --- a/components/form/content/image-form.tsx +++ b/components/form/content/image-form.tsx @@ -157,6 +157,9 @@ export default function FormImage() { onDrop: (acceptedFiles) => { setFiles(acceptedFiles.map((file) => Object.assign(file))); }, + accept: { + "image/*": [], + }, }); const imageSchema = z.object({ @@ -1020,12 +1023,12 @@ export default function FormImage() {
{fileList}
-
+ {/*
-
+
*/}
- +
@@ -693,39 +694,6 @@ export default function FormTeksDetail() { ) : ( "" )} */} - {Number(detail?.needApprovalFromLevel) == Number(userLevelId) ? ( - Number(detail?.uploadedById) == Number(userId) ? ( - "" - ) : ( -
- - - -
- ) - ) : ( - "" - )} @@ -738,7 +706,18 @@ export default function FormTeksDetail() { key={file.id} className="flex flex-row gap-2 items-center" > - + {/* */} + + +
{file.fileName} @@ -927,6 +906,39 @@ export default function FormTeksDetail() {
+ {Number(detail?.needApprovalFromLevel) == Number(userLevelId) ? ( + Number(detail?.uploadedById) == Number(userId) ? ( + "" + ) : ( +
+ + + +
+ ) + ) : ( + "" + )}
) : ( diff --git a/components/form/content/teks-form.tsx b/components/form/content/teks-form.tsx index ffc993b4..c9a9ce4e 100644 --- a/components/form/content/teks-form.tsx +++ b/components/form/content/teks-form.tsx @@ -147,6 +147,12 @@ export default function FormTeks() { onDrop: (acceptedFiles) => { setFiles(acceptedFiles.map((file) => Object.assign(file))); }, + accept: { + "application/pdf": [], + "application/msword": [], // .doc + "application/vnd.openxmlformats-officedocument.wordprocessingml.document": + [], // .docx + }, }); const teksSchema = z.object({ @@ -1012,12 +1018,12 @@ export default function FormTeks() {
{fileList}
-
+ {/*
-
+
*/}
- +
@@ -647,39 +648,6 @@ export default function FormVideoDetail() { ) : ( "" )} */} - {Number(detail?.needApprovalFromLevel) == Number(userLevelId) ? ( - Number(detail?.uploadedById) == Number(userId) ? ( - "" - ) : ( -
- - - -
- ) - ) : ( - "" - )} @@ -692,7 +660,21 @@ export default function FormVideoDetail() { key={file.id} className="flex flex-row gap-2 items-center" > - + {/* */} + + + + + +
{file.fileName} @@ -879,6 +861,39 @@ export default function FormVideoDetail() {
+ {Number(detail?.needApprovalFromLevel) == Number(userLevelId) ? ( + Number(detail?.uploadedById) == Number(userId) ? ( + "" + ) : ( +
+ + + +
+ ) + ) : ( + "" + )}
) : ( diff --git a/components/form/content/video-form.tsx b/components/form/content/video-form.tsx index e6e4be2d..e27a0a94 100644 --- a/components/form/content/video-form.tsx +++ b/components/form/content/video-form.tsx @@ -148,6 +148,9 @@ export default function FormVideo() { onDrop: (acceptedFiles) => { setFiles(acceptedFiles.map((file) => Object.assign(file))); }, + accept: { + "video/*": [], + }, }); const videoSchema = z.object({ @@ -666,7 +669,21 @@ export default function FormVideo() { className=" flex justify-between border px-3.5 py-3 my-6 rounded-md" >
-
{renderFilePreview(file)}
+ {/*
{renderFilePreview(file)}
*/} + + + + + +
{file.name}
@@ -1011,12 +1028,12 @@ export default function FormVideo() {
{fileList}
-
+ {/*
-
+
*/}