diff --git a/app/[locale]/(protected)/contributor/task/components/columns.tsx b/app/[locale]/(protected)/contributor/task/components/columns.tsx index 82b1785b..75b68078 100644 --- a/app/[locale]/(protected)/contributor/task/components/columns.tsx +++ b/app/[locale]/(protected)/contributor/task/components/columns.tsx @@ -23,7 +23,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 columns: ColumnDef[] = [ { accessorKey: "no", @@ -124,6 +124,85 @@ const useTableColumns = () => { accessorKey: "action", header: t("action", { defaultValue: "Action" }), enableHiding: false, + // cell: ({ row }) => { + // const router = useRouter(); + // const MySwal = withReactContent(Swal); + + // async function deleteProcess(id: any) { + // loading(); + // const resDelete = await deleteTask(id); + + // if (resDelete?.error) { + // error(resDelete.message); + // return false; + // } + // success(); + // } + + // function success() { + // MySwal.fire({ + // title: "Sukses", + // icon: "success", + // confirmButtonColor: "#3085d6", + // confirmButtonText: "OK", + // }).then((result) => { + // if (result.isConfirmed) { + // window.location.reload(); + // } + // }); + // } + + // const TaskDelete = (id: any) => { + // MySwal.fire({ + // title: "Hapus Data", + // text: "", + // icon: "warning", + // showCancelButton: true, + // cancelButtonColor: "#3085d6", + // confirmButtonColor: "#d33", + // confirmButtonText: "Hapus", + // }).then((result) => { + // if (result.isConfirmed) { + // deleteProcess(id); + // } + // }); + // }; + + // return ( + // + // + // + // + // + // + // + // + // View + // + // + // + // + // + // Edit + // + // + // TaskDelete(row.original.id)} + // className="p-2 border-b text-destructive bg-destructive/30 focus:bg-destructive focus:text-destructive-foreground rounded-none" + // > + // + // Delete + // + // + // + // ); + // }, cell: ({ row }) => { const router = useRouter(); const MySwal = withReactContent(Swal); @@ -168,6 +247,8 @@ const useTableColumns = () => { }); }; + const isDone = row.original.isDone; + return ( @@ -186,19 +267,24 @@ const useTableColumns = () => { View - - - - Edit - - - TaskDelete(row.original.id)} - className="p-2 border-b text-destructive bg-destructive/30 focus:bg-destructive focus:text-destructive-foreground rounded-none" - > - - Delete - + + {!isDone && ( + <> + + + + Edit + + + TaskDelete(row.original.id)} + className="p-2 border-b text-destructive bg-destructive/30 focus:bg-destructive focus:text-destructive-foreground rounded-none" + > + + Delete + + + )} ); diff --git a/app/[locale]/(protected)/contributor/task/page.tsx b/app/[locale]/(protected)/contributor/task/page.tsx index cca1788a..dc065173 100644 --- a/app/[locale]/(protected)/contributor/task/page.tsx +++ b/app/[locale]/(protected)/contributor/task/page.tsx @@ -13,7 +13,7 @@ const TaskPage = () => { const t = useTranslations("AnalyticsDashboard"); useEffect(() => { function initState() { - checkAuthorization("admin"); // Specify the page, e.g., "admin" or another value + checkAuthorization("admin"); checkLoginSession(); }