From 6fa5a05624153e725664fb6134346723a6d82217 Mon Sep 17 00:00:00 2001 From: Sabda Yagra Date: Fri, 1 Aug 2025 15:19:58 +0700 Subject: [PATCH 1/2] fix: hide button edit and delete if status done --- .../contributor/task/components/columns.tsx | 114 +++++++++++++++--- .../(protected)/contributor/task/page.tsx | 2 +- 2 files changed, 101 insertions(+), 15 deletions(-) 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(); } From a1bcadec862c3ecf3bbc967593ea412de034afa1 Mon Sep 17 00:00:00 2001 From: Sabda Yagra Date: Fri, 1 Aug 2025 21:43:39 +0700 Subject: [PATCH 2/2] fix: height video player when video vertical --- components/form/task/task-detail-form.tsx | 2 +- components/main/video-detail.tsx | 13 ++++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/components/form/task/task-detail-form.tsx b/components/form/task/task-detail-form.tsx index d8919a03..7e851ada 100644 --- a/components/form/task/task-detail-form.tsx +++ b/components/form/task/task-detail-form.tsx @@ -1027,7 +1027,7 @@ export default function FormTaskDetail() {
setMainType(value)} // value={String(mainType)} // onValueChange={(value) => setMainType(Number(value))} diff --git a/components/main/video-detail.tsx b/components/main/video-detail.tsx index 0b9e3286..02c00e65 100644 --- a/components/main/video-detail.tsx +++ b/components/main/video-detail.tsx @@ -468,10 +468,21 @@ const DetailVideo = () => {
{/* Bagian Kiri */}
-
+ {/*
+
*/} +
+
+
+ +
+
+
+
{detailDataVideo?.files?.map((file: any, index: number) => (