From 44c6cc6d9d9c3b8ffcb43f3e0c261a8f7ebb7499 Mon Sep 17 00:00:00 2001 From: Sabda Yagra Date: Thu, 29 Jan 2026 18:38:34 +0700 Subject: [PATCH] fix: menus for polres --- .../task-ta/components/columns.tsx | 46 ++-- .../task-ta/components/task-ta-table.tsx | 16 +- .../(protected)/contributor/task/page.tsx | 27 ++- app/[locale]/(protected)/dashboard/page.tsx | 66 ++++-- .../(protected)/shared/contest/page.tsx | 28 ++- components/form/task-ta/task-ta-form.tsx | 24 +- lib/menus.ts | 213 +++++++++--------- 7 files changed, 255 insertions(+), 165 deletions(-) diff --git a/app/[locale]/(protected)/contributor/task-ta/components/columns.tsx b/app/[locale]/(protected)/contributor/task-ta/components/columns.tsx index 8f8f9072..4d88788c 100644 --- a/app/[locale]/(protected)/contributor/task-ta/components/columns.tsx +++ b/app/[locale]/(protected)/contributor/task-ta/components/columns.tsx @@ -22,7 +22,9 @@ import withReactContent from "sweetalert2-react-content"; import Swal from "sweetalert2"; import { useTranslations } from "next-intl"; -const useTableColumns = (activeTab: "ta" | "daily" | "special" |"mabes-koor") => { +const useTableColumns = ( + activeTab: "ta" | "daily" | "special" | "mabes-koor", +) => { const t = useTranslations("Table"); const columns: ColumnDef[] = [ { @@ -190,7 +192,11 @@ const useTableColumns = (activeTab: "ta" | "daily" | "special" |"mabes-koor") => - {(roleId == 11 || roleId == 12 || roleId == 19) && ( + {/* {(roleId == 11 || roleId == 12 || roleId == 19) && ( */} + {(roleId == 11 || + roleId == 12 || + roleId == 19 || + roleId == 3) && ( @@ -198,14 +204,15 @@ const useTableColumns = (activeTab: "ta" | "daily" | "special" |"mabes-koor") => )} - {roleId == 11 && ( - - - - Edit - - - )} + {roleId == 11 || + (roleId == 3 && ( + + + + Edit + + + ))} {(roleId == 12 || roleId == 19) && ( )} - {roleId == 11 && ( - TaskDelete(row.original.id)} - className="p-2 border-b text-destructive bg-destructive/30 focus:bg-destructive focus:text-destructive-foreground rounded-none" - > - - Delete - - )} + {roleId == 11 || + (roleId == 3 && ( + 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-ta/components/task-ta-table.tsx b/app/[locale]/(protected)/contributor/task-ta/components/task-ta-table.tsx index 93a51de3..d7b153a5 100644 --- a/app/[locale]/(protected)/contributor/task-ta/components/task-ta-table.tsx +++ b/app/[locale]/(protected)/contributor/task-ta/components/task-ta-table.tsx @@ -91,7 +91,8 @@ export default function TaskTaTable() { const [page, setPage] = React.useState(1); const [totalPage, setTotalPage] = React.useState(1); - const KOOR_KURATOR_USER_ID = "464"; + // const KOOR_KURATOR_USER_ID = "464"; + const KOOR_KURATOR_USER_IDS = ["464", "8258"]; // ✅ columns based on tab const columns = useTableColumns(activeTab); @@ -135,7 +136,8 @@ export default function TaskTaTable() { activeTab, ]); - const isKoorKurator = String(userId) === KOOR_KURATOR_USER_ID; + // const isKoorKurator = String(userId) === KOOR_KURATOR_USER_ID; + const isKoorKurator = KOOR_KURATOR_USER_IDS.includes(String(userId)); async function fetchData() { const formattedStartDate = dateFilter @@ -208,7 +210,10 @@ export default function TaskTaTable() { if (activeTab === "ta") { contentData = contentData.filter((item: any) => { const assignedUsers = String(item?.assignedToUsers || ""); - return !assignedUsers.split(",").includes(KOOR_KURATOR_USER_ID); + // return !assignedUsers.split(",").includes(KOOR_KURATOR_USER_ID); + return !assignedUsers + .split(",") + .some((id) => KOOR_KURATOR_USER_IDS.includes(id.trim())); }); } @@ -253,7 +258,10 @@ export default function TaskTaTable() { return ( /MABES/i.test(createdByLevel) && - assignedUsers.split(",").includes(KOOR_KURATOR_USER_ID) + // assignedUsers.split(",").includes(KOOR_KURATOR_USER_ID) + assignedUsers + .split(",") + .some((id) => KOOR_KURATOR_USER_IDS.includes(id.trim())) ); }); } diff --git a/app/[locale]/(protected)/contributor/task/page.tsx b/app/[locale]/(protected)/contributor/task/page.tsx index dc065173..174e7409 100644 --- a/app/[locale]/(protected)/contributor/task/page.tsx +++ b/app/[locale]/(protected)/contributor/task/page.tsx @@ -5,7 +5,11 @@ import { Button } from "@/components/ui/button"; import { UploadIcon } from "lucide-react"; import SiteBreadcrumb from "@/components/site-breadcrumb"; import { Link } from "@/components/navigation"; -import { checkAuthorization, checkLoginSession } from "@/lib/utils"; +import { + checkAuthorization, + checkLoginSession, + getCookiesDecrypt, +} from "@/lib/utils"; import React, { useEffect } from "react"; import { useTranslations } from "next-intl"; @@ -13,12 +17,13 @@ const TaskPage = () => { const t = useTranslations("AnalyticsDashboard"); useEffect(() => { function initState() { - checkAuthorization("admin"); + checkAuthorization("admin"); checkLoginSession(); } initState(); }, []); + const levelNumber = getCookiesDecrypt("ulne"); return (
@@ -29,16 +34,28 @@ const TaskPage = () => {
- {t("tabel", { defaultValue: "Tabel" })} {t("task", { defaultValue: "Task" })} + {t("tabel", { defaultValue: "Tabel" })}{" "} + {t("task", { defaultValue: "Task" })}
-
+ {Number(levelNumber) !== 3 && ( +
+ + + +
+ )} + + {/*
-
+
*/}
diff --git a/app/[locale]/(protected)/dashboard/page.tsx b/app/[locale]/(protected)/dashboard/page.tsx index 29ac3426..878846bb 100644 --- a/app/[locale]/(protected)/dashboard/page.tsx +++ b/app/[locale]/(protected)/dashboard/page.tsx @@ -24,6 +24,7 @@ import ReportTable from "../contributor/report/components/report-table"; const DashboardPage = () => { const t = useTranslations("AnalyticsDashboard"); const roleId = getCookiesDecrypt("urie"); + const levelNumber = Number(getCookiesDecrypt("ulne")); return Number(roleId) == 2 || Number(roleId) == 11 || Number(roleId) == 12 ? (
@@ -54,18 +55,23 @@ const DashboardPage = () => { > {t("schedule", { defaultValue: "Schedule" })} - - {t("indeks", { defaultValue: "Indeks" })} - - - {t("report", { defaultValue: "Report" })} - + {levelNumber !== 3 && ( + <> + + {t("indeks", { defaultValue: "Indeks" })} + + + + {t("report", { defaultValue: "Report" })} + + + )} @@ -75,18 +81,24 @@ const DashboardPage = () => {
{ - {t("Total-Content-Production", { defaultValue: "Total Content Production" })} + {t("Total-Content-Production", { + defaultValue: "Total Content Production", + })} @@ -113,7 +127,9 @@ const DashboardPage = () => {
- {t("tabel", { defaultValue: "Tabel" })} + + {t("tabel", { defaultValue: "Tabel" })} + {/* */} @@ -132,14 +148,26 @@ const DashboardPage = () => {
Tabel Penugasan
-
+ {Number(levelNumber) !== 3 && ( +
+ + + +
+ )} + {/*
-
+
*/}
diff --git a/app/[locale]/(protected)/shared/contest/page.tsx b/app/[locale]/(protected)/shared/contest/page.tsx index fa009c36..6fe3ef26 100644 --- a/app/[locale]/(protected)/shared/contest/page.tsx +++ b/app/[locale]/(protected)/shared/contest/page.tsx @@ -13,6 +13,8 @@ import { useTranslations } from "next-intl"; const ContestPage = () => { const [userLevelId, setUserLevelId] = useState(null); const t = useTranslations("Contest"); + const levelNumber = Number(getCookiesDecrypt("ulne")); + useEffect(() => { setUserLevelId(Number(getCookiesDecrypt("ulie"))); }, []); @@ -25,18 +27,36 @@ const ContestPage = () => {
- {t("table", { defaultValue: "Table" })} {t("contest", { defaultValue: "Contest" })} + {t("table", { defaultValue: "Table" })}{" "} + {t("contest", { defaultValue: "Contest" })}
- {userLevelId !== 776 && userLevelId !== null && ( + {userLevelId !== 776 && + userLevelId !== null && + levelNumber !== 3 && ( +
+ + + +
+ )} + + {/* {userLevelId !== 776 && userLevelId !== null && (
- )} + )} */}
diff --git a/components/form/task-ta/task-ta-form.tsx b/components/form/task-ta/task-ta-form.tsx index ddd701f5..b084e59e 100644 --- a/components/form/task-ta/task-ta-form.tsx +++ b/components/form/task-ta/task-ta-form.tsx @@ -98,7 +98,7 @@ const CustomEditor = dynamic( () => { return import("@/components/editor/custom-editor"); }, - { ssr: false } + { ssr: false }, ); export default function FormTaskTa() { @@ -136,7 +136,7 @@ export default function FormTaskTa() { const [userLevels, setUserLevels] = useState(); const [userCompetencies, setUserCompetencies] = useState([]); const [selectedCompetencies, setSelectedCompetencies] = useState>( - new Set() + new Set(), ); const [listExpert, setListExpert] = useState([]); const [checkedLevels, setCheckedLevels] = useState>(new Set()); @@ -245,7 +245,7 @@ export default function FormTaskTa() { } const uniqueExperts = Array.from( - new Map(allExperts.map((e) => [e.id, e])).values() + new Map(allExperts.map((e) => [e.id, e])).values(), ); setListExpert(uniqueExperts); @@ -449,7 +449,7 @@ export default function FormTaskTa() { const requestData = { ...data, // assignedToUsers: isMabesApprover ? "464" : handleExpertChange(), - assignedToUsers: isMabesApprover ? "464" : handleExpertChange(), + assignedToUsers: isMabesApprover ? "464,8258" : handleExpertChange(), assignmentType: taskType, assignmentTypeId: type, expertCompetencies: Array.from(selectedCompetencies).join(","), @@ -467,19 +467,19 @@ export default function FormTaskTa() { const uploads: Promise[] = []; imageFiles.forEach((file, i) => - uploads.push(uploadResumableFile(i, assignmentId, file, "1", "0")) + uploads.push(uploadResumableFile(i, assignmentId, file, "1", "0")), ); videoFiles.forEach((file, i) => - uploads.push(uploadResumableFile(i, assignmentId, file, "2", "0")) + uploads.push(uploadResumableFile(i, assignmentId, file, "2", "0")), ); textFiles.forEach((file, i) => - uploads.push(uploadResumableFile(i, assignmentId, file, "3", "0")) + uploads.push(uploadResumableFile(i, assignmentId, file, "3", "0")), ); audioFiles.forEach((file, i) => - uploads.push(uploadResumableFile(i, assignmentId, file, "4", "0")) + uploads.push(uploadResumableFile(i, assignmentId, file, "4", "0")), ); await Promise.all(uploads); @@ -557,7 +557,7 @@ export default function FormTaskTa() { // Convert Blob to File and add preview const fileWithPreview: FileWithPreview = Object.assign( new File([blob], "voiceNote.webm", { type: "audio/webm" }), - { preview: url } + { preview: url }, ); // Add to state @@ -687,7 +687,7 @@ export default function FormTaskTa() { id: string, file: File, fileTypeId: string, - duration: string + duration: string, ) { return new Promise(async (resolve, reject) => { try { @@ -829,7 +829,7 @@ export default function FormTaskTa() { variant={"outline"} className={cn( "w-[280px] lg:w-[250px] justify-start text-left font-normal border border-slate-300 px-0 md:px-0 lg:px-4", - !date && "text-muted-foreground" + !date && "text-muted-foreground", )} > @@ -928,7 +928,7 @@ export default function FormTaskTa() {
{Array.from(checkedLevels).map((expertId) => { const expert = listExpert?.find( - (exp: any) => exp.id === expertId + (exp: any) => exp.id === expertId, ); return expert ? (