diff --git a/app/[locale]/(protected)/contributor/content/audio/components/columns.tsx b/app/[locale]/(protected)/contributor/content/audio/components/columns.tsx index 66d5d9bc..7a6f8170 100644 --- a/app/[locale]/(protected)/contributor/content/audio/components/columns.tsx +++ b/app/[locale]/(protected)/contributor/content/audio/components/columns.tsx @@ -20,7 +20,7 @@ import Swal from "sweetalert2"; import { useTranslations } from "next-intl"; const useTableColumns = () => { - const t = useTranslations("Table"); // Panggil di dalam hook + const t = useTranslations("Table"); const MySwal = withReactContent(Swal); const userLevelId = getCookiesDecrypt("ulie"); @@ -97,7 +97,8 @@ const useTableColumns = () => { cell: ({ row }) => { const isPublish = row.original.isPublish; const isPublishOnPolda = row.original.isPublishOnPolda; - const creatorGroupParentLevelId = row.original.creatorGroupParentLevelId; + const creatorGroupParentLevelId = + row.original.creatorGroupParentLevelId; let displayText = "-"; if (isPublish && !isPublishOnPolda) { @@ -225,6 +226,20 @@ const useTableColumns = () => { } }); }; + + const [isMabesApprover, setIsMabesApprover] = React.useState(false); + const userId = getCookiesDecrypt("uie"); + const userLevelId = getCookiesDecrypt("ulie"); + const roleId = getCookiesDecrypt("urie"); + + React.useEffect(() => { + if (userLevelId !== undefined && roleId !== undefined) { + setIsMabesApprover( + Number(userLevelId) == 216 && Number(roleId) == 3 + ); + } + }, [userLevelId, roleId]); + return ( @@ -245,14 +260,25 @@ const useTableColumns = () => { View - Edit - + */} + {(Number(row.original.uploadedById) === Number(userId) || + isMabesApprover) && ( + + + + Edit + + + )} handleDeleteMedia(row.original.id)} className="p-2 border-b text-destructive bg-destructive/30 focus:bg-destructive focus:text-destructive-foreground rounded-none" @@ -260,6 +286,15 @@ const useTableColumns = () => { Delete + {/* {(row.original.uploadedById === userId || isMabesApprover) && ( + handleDeleteMedia(row.original.id)} + className="p-2 border-b text-destructive bg-destructive/30 focus:bg-destructive focus:text-destructive-foreground rounded-none" + > + + Hapus + + )} */} ); diff --git a/app/[locale]/(protected)/contributor/content/image/components/columns.tsx b/app/[locale]/(protected)/contributor/content/image/components/columns.tsx index 28edda42..18b9837b 100644 --- a/app/[locale]/(protected)/contributor/content/image/components/columns.tsx +++ b/app/[locale]/(protected)/contributor/content/image/components/columns.tsx @@ -100,7 +100,8 @@ const useTableColumns = () => { cell: ({ row }) => { const isPublish = row.original.isPublish; const isPublishOnPolda = row.original.isPublishOnPolda; - const creatorGroupParentLevelId = row.original.creatorGroupParentLevelId; + const creatorGroupParentLevelId = + row.original.creatorGroupParentLevelId; let displayText = "-"; if (isPublish && !isPublishOnPolda) { @@ -231,6 +232,20 @@ const useTableColumns = () => { } }); }; + + const [isMabesApprover, setIsMabesApprover] = React.useState(false); + const userId = getCookiesDecrypt("uie"); + const userLevelId = getCookiesDecrypt("ulie"); + const roleId = getCookiesDecrypt("urie"); + + React.useEffect(() => { + if (userLevelId !== undefined && roleId !== undefined) { + setIsMabesApprover( + Number(userLevelId) == 216 && Number(roleId) == 3 + ); + } + }, [userLevelId, roleId]); + return ( @@ -251,14 +266,25 @@ const useTableColumns = () => { View - Edit - + */} + {(Number(row.original.uploadedById) === Number(userId) || + isMabesApprover) && ( + + + + Edit + + + )} handleDeleteMedia(row.original.id)} className="p-2 border-b text-destructive bg-destructive/30 focus:bg-destructive focus:text-destructive-foreground rounded-none" @@ -266,6 +292,15 @@ const useTableColumns = () => { Delete + {/* {(row.original.uploadedById === userId || isMabesApprover) && ( + handleDeleteMedia(row.original.id)} + className="p-2 border-b text-destructive bg-destructive/30 focus:bg-destructive focus:text-destructive-foreground rounded-none" + > + + Hapus + + )} */} ); diff --git a/app/[locale]/(protected)/contributor/content/teks/components/columns.tsx b/app/[locale]/(protected)/contributor/content/teks/components/columns.tsx index 7dc5990f..398c1f29 100644 --- a/app/[locale]/(protected)/contributor/content/teks/components/columns.tsx +++ b/app/[locale]/(protected)/contributor/content/teks/components/columns.tsx @@ -20,7 +20,7 @@ import Swal from "sweetalert2"; import { useTranslations } from "next-intl"; const useTableColumns = () => { - const t = useTranslations("Table"); // Panggil di dalam hook + const t = useTranslations("Table"); const MySwal = withReactContent(Swal); const userLevelId = getCookiesDecrypt("ulie"); @@ -97,7 +97,8 @@ const useTableColumns = () => { cell: ({ row }) => { const isPublish = row.original.isPublish; const isPublishOnPolda = row.original.isPublishOnPolda; - const creatorGroupParentLevelId = row.original.creatorGroupParentLevelId; + const creatorGroupParentLevelId = + row.original.creatorGroupParentLevelId; let displayText = "-"; if (isPublish && !isPublishOnPolda) { @@ -226,6 +227,20 @@ const useTableColumns = () => { } }); }; + + const [isMabesApprover, setIsMabesApprover] = React.useState(false); + const userId = getCookiesDecrypt("uie"); + const userLevelId = getCookiesDecrypt("ulie"); + const roleId = getCookiesDecrypt("urie"); + + React.useEffect(() => { + if (userLevelId !== undefined && roleId !== undefined) { + setIsMabesApprover( + Number(userLevelId) == 216 && Number(roleId) == 3 + ); + } + }, [userLevelId, roleId]); + return ( @@ -246,14 +261,25 @@ const useTableColumns = () => { View - + + + Edit + + + )} + {/* Edit - + */} handleDeleteMedia(row.original.id)} className="p-2 border-b text-destructive bg-destructive/30 focus:bg-destructive focus:text-destructive-foreground rounded-none" @@ -261,6 +287,15 @@ const useTableColumns = () => { Delete + {/* {(row.original.uploadedById === userId || isMabesApprover) && ( + handleDeleteMedia(row.original.id)} + className="p-2 border-b text-destructive bg-destructive/30 focus:bg-destructive focus:text-destructive-foreground rounded-none" + > + + Hapus + + )} */} ); diff --git a/app/[locale]/(protected)/contributor/content/video/components/columns.tsx b/app/[locale]/(protected)/contributor/content/video/components/columns.tsx index ccd03859..3cc325c2 100644 --- a/app/[locale]/(protected)/contributor/content/video/components/columns.tsx +++ b/app/[locale]/(protected)/contributor/content/video/components/columns.tsx @@ -20,7 +20,7 @@ import { error } from "@/lib/swal"; import { useTranslations } from "next-intl"; const useTableColumns = () => { - const t = useTranslations("Table"); // Panggil di dalam hook + const t = useTranslations("Table"); const MySwal = withReactContent(Swal); const userLevelId = getCookiesDecrypt("ulie"); @@ -97,7 +97,8 @@ const useTableColumns = () => { cell: ({ row }) => { const isPublish = row.original.isPublish; const isPublishOnPolda = row.original.isPublishOnPolda; - const creatorGroupParentLevelId = row.original.creatorGroupParentLevelId; + const creatorGroupParentLevelId = + row.original.creatorGroupParentLevelId; let displayText = "-"; if (isPublish && !isPublishOnPolda) { @@ -226,6 +227,20 @@ const useTableColumns = () => { } }); }; + + const [isMabesApprover, setIsMabesApprover] = React.useState(false); + const userId = getCookiesDecrypt("uie"); + const userLevelId = getCookiesDecrypt("ulie"); + const roleId = getCookiesDecrypt("urie"); + + React.useEffect(() => { + if (userLevelId !== undefined && roleId !== undefined) { + setIsMabesApprover( + Number(userLevelId) == 216 && Number(roleId) == 3 + ); + } + }, [userLevelId, roleId]); + return ( @@ -246,14 +261,25 @@ const useTableColumns = () => { View - Edit - + */} + {(Number(row.original.uploadedById) === Number(userId) || + isMabesApprover) && ( + + + + Edit + + + )} handleDeleteMedia(row.original.id)} className="p-2 border-b text-destructive bg-destructive/30 focus:bg-destructive focus:text-destructive-foreground rounded-none" @@ -261,6 +287,15 @@ const useTableColumns = () => { Delete + {/* {(row.original.uploadedById === userId || isMabesApprover) && ( + handleDeleteMedia(row.original.id)} + className="p-2 border-b text-destructive bg-destructive/30 focus:bg-destructive focus:text-destructive-foreground rounded-none" + > + + Hapus + + )} */} ); diff --git a/app/[locale]/(protected)/dashboard/routine-task/components/columns.tsx b/app/[locale]/(protected)/dashboard/routine-task/components/columns.tsx index 0a6c4caf..cf176d13 100644 --- a/app/[locale]/(protected)/dashboard/routine-task/components/columns.tsx +++ b/app/[locale]/(protected)/dashboard/routine-task/components/columns.tsx @@ -228,6 +228,17 @@ const columns: ColumnDef[] = [ }); }; + const [isMabesApprover, setIsMabesApprover] = React.useState(false); + const userId = getCookiesDecrypt("uie"); + const userLevelId = getCookiesDecrypt("ulie"); + const roleId = getCookiesDecrypt("urie"); + + React.useEffect(() => { + if (userLevelId !== undefined && roleId !== undefined) { + setIsMabesApprover(Number(userLevelId) == 216 && Number(roleId) == 3); + } + }, [userLevelId, roleId]); + return ( @@ -240,7 +251,6 @@ const columns: ColumnDef[] = [ - {/* Link "View" yang diperbarui dengan logika kondisional untuk fileTypeSegment */} @@ -249,13 +259,28 @@ const columns: ColumnDef[] = [ Lihat - handleDeleteMedia(row.original.id)} - className="p-2 border-b text-destructive bg-destructive/30 focus:bg-destructive focus:text-destructive-foreground rounded-none" - > - - Hapus - + + {(Number(row.original.uploadedById) === Number(userId) || + isMabesApprover) && ( + + + + Edit + + + )} + + {(row.original.uploadedById === userId || isMabesApprover) && ( + handleDeleteMedia(row.original.id)} + className="p-2 border-b text-destructive bg-destructive/30 focus:bg-destructive focus:text-destructive-foreground rounded-none" + > + + Hapus + + )} ); diff --git a/app/[locale]/(public)/image/filter/page.tsx b/app/[locale]/(public)/image/filter/page.tsx index a41f03f5..eacd0392 100644 --- a/app/[locale]/(public)/image/filter/page.tsx +++ b/app/[locale]/(public)/image/filter/page.tsx @@ -507,7 +507,6 @@ const FilterPage = () => { return (
{/* Header */} -

{t("image", { defaultValue: "Image" })}

{">"}