diff --git a/app/[locale]/(protected)/contributor/schedule/calendar-polri/component/columns.tsx b/app/[locale]/(protected)/contributor/schedule/calendar-polri/component/columns.tsx index c0672f25..4d2a9f23 100644 --- a/app/[locale]/(protected)/contributor/schedule/calendar-polri/component/columns.tsx +++ b/app/[locale]/(protected)/contributor/schedule/calendar-polri/component/columns.tsx @@ -101,10 +101,8 @@ const useTableColumns = () => { enableHiding: false, cell: ({ row }) => { const MySwal = withReactContent(Swal); - const levelNumber = Number(getCookiesDecrypt("ulne")); // 1 = Mabes, 2 = Polda - const calendarOwnerLevel = Number(row.original.assignedToLevel); // dari API - const calendarOwner = row.original.assignedTo; // ID unit Polda/Mabes dari API - const myUnit = getCookiesDecrypt("unitId"); // misal ID unit Polda login + const levelNumber = Number(getCookiesDecrypt("ulne")); + const userId = Number(getCookiesDecrypt("uie")); async function doDelete(id: any) { const response = await deleteCalendar(id); @@ -143,29 +141,6 @@ const useTableColumns = () => { } }); }; - - // === RULE AKSI === - let canEdit = false; - let canDelete = false; - const canView = true; - - if (levelNumber === 1) { - // Mabes -> bebas - canEdit = true; - canDelete = true; - } else if (levelNumber === 2) { - // Polda - if (calendarOwnerLevel === 1) { - // kalender Mabes -> hanya view - canEdit = false; - canDelete = false; - } else if (calendarOwnerLevel === 2 && calendarOwner === myUnit) { - // kalender polda sendiri -> bisa edit/delete - canEdit = true; - canDelete = true; - } - } - return ( @@ -178,7 +153,7 @@ const useTableColumns = () => { - {canView && ( + @@ -187,9 +162,9 @@ const useTableColumns = () => { Detail - )} + - {canEdit && ( + {row.original.createdById === userId && ( @@ -200,7 +175,7 @@ const useTableColumns = () => { )} - {canDelete && ( + {row.original.createdById === userId && ( handleDeleteCalendars(row.original.id)} className="p-2 border-b text-destructive bg-destructive/30 focus:bg-destructive focus:text-destructive-foreground rounded-none" @@ -214,7 +189,7 @@ const useTableColumns = () => { ); }, }, - + // { // id: "actions", // accessorKey: "action", diff --git a/components/form/broadcast/content-blast-form.tsx b/components/form/broadcast/content-blast-form.tsx index 402cc9c7..ad4897a9 100644 --- a/components/form/broadcast/content-blast-form.tsx +++ b/components/form/broadcast/content-blast-form.tsx @@ -27,7 +27,7 @@ import { saveMediaBlastCampaign, } from "@/service/broadcast/broadcast"; import { error } from "@/config/swal"; -import { useRouter } from "@/i18n/routing"; +import { Link, useRouter } from "@/i18n/routing"; import { useEffect, useRef, useState } from "react"; import { useParams } from "next/navigation"; @@ -78,6 +78,11 @@ const FormSchema = z.object({ }), }); +interface Campaign { + id: string; + name: string; +} + export default function ContentBlast(props: { type: string }) { const editor = useRef(null); const id = useParams()?.id; @@ -85,7 +90,7 @@ export default function ContentBlast(props: { type: string }) { const router = useRouter(); const { type } = props; - const [dataSelectCampaign, setDataSelectCampaign] = useState([]); + const [dataSelectCampaign, setDataSelectCampaign] = useState([]); const [openModal, setOpenModal] = useState(false); const form = useForm>({ @@ -295,9 +300,16 @@ export default function ContentBlast(props: { type: string }) { Untuk melihat Email Terkirim silahkan cek menu “Sent”! - + + + +