From e7ca5def8cbe24df5918964e5ddad12dac85461a Mon Sep 17 00:00:00 2001 From: Anang Yusman Date: Tue, 25 Feb 2025 00:37:17 +0800 Subject: [PATCH 1/2] feat:status contest,delete agenda setting admin --- .../shared/contest/components/columns.tsx | 6 +++- .../form/contest/contest-detail-form.tsx | 8 ++---- lib/menus.ts | 28 +++++++++---------- 3 files changed, 22 insertions(+), 20 deletions(-) diff --git a/app/[locale]/(protected)/shared/contest/components/columns.tsx b/app/[locale]/(protected)/shared/contest/components/columns.tsx index 5db22073..85ced8c3 100644 --- a/app/[locale]/(protected)/shared/contest/components/columns.tsx +++ b/app/[locale]/(protected)/shared/contest/components/columns.tsx @@ -109,15 +109,19 @@ const columns: ColumnDef[] = [ (userRoleId === 3 && userLevelNumber === 1 && !isPublishForAll) || // Role 3 dengan level 1 hanya publish jika isPublishForAll true ((userRoleId === 11 || userRoleId === 12) && !isPublishForMabes); // Role 11 dan 12 hanya publish jika isPublishForMabes true + const isTerkirim: boolean = isPublishForMabes && !isPublishForAll; + return ( - {isPending ? "Pending" : "Publish"} + {isPending ? "Pending" : isTerkirim ? "Terkirim" : "Publish"} ); }, diff --git a/components/form/contest/contest-detail-form.tsx b/components/form/contest/contest-detail-form.tsx index 13a1e13b..2dfef0bd 100644 --- a/components/form/contest/contest-detail-form.tsx +++ b/components/form/contest/contest-detail-form.tsx @@ -224,10 +224,8 @@ export default function FormContestDetail() { }, [detail?.targetOutput]); useEffect(() => { - if (detail?.targetParticipantTopLevel) { - const outputSet = new Set( - detail.targetParticipantTopLevel.split(",").map(Number) - ); + if (detail?.targetOutput) { + const outputSet = new Set(detail.targetOutput.split(",").map(Number)); setUnitSelection({ allUnit: outputSet.has(0), mabes: outputSet.has(1), @@ -235,7 +233,7 @@ export default function FormContestDetail() { polres: outputSet.has(3), }); } - }, [detail?.targetParticipantTopLevel]); + }, [detail?.targetOutput]); const handleCheckboxChange = (levelId: number) => { setCheckedLevels((prev) => { diff --git a/lib/menus.ts b/lib/menus.ts index e4cf05f3..c1ae7464 100644 --- a/lib/menus.ts +++ b/lib/menus.ts @@ -2723,20 +2723,20 @@ export function getMenuList(pathname: string, t: any): Group[] { }, ], }, - { - groupLabel: "", - id: "agenda-setting", - menus: [ - { - id: "agenda-setting", - href: "/contributor/agenda-setting", - label: t("agenda-setting"), - active: pathname.includes("/agenda-setting"), - icon: "iconoir:journal-page", - submenus: [], - }, - ], - }, + // { + // groupLabel: "", + // id: "agenda-setting", + // menus: [ + // { + // id: "agenda-setting", + // href: "/contributor/agenda-setting", + // label: t("agenda-setting"), + // active: pathname.includes("/agenda-setting"), + // icon: "iconoir:journal-page", + // submenus: [], + // }, + // ], + // }, { groupLabel: "", id: "management-user", From 72c699a42ad8825d570f3970ddeaaf446f1249fe Mon Sep 17 00:00:00 2001 From: Anang Yusman Date: Tue, 25 Feb 2025 20:50:47 +0800 Subject: [PATCH 2/2] feat:ui agenda,curated content,filter spit --- .../agenda-setting/calender-view.tsx | 11 +- .../content/image/components/columns.tsx | 48 +--- .../content/spit/table-spit/table-spit.tsx | 28 +- .../shared/contest/components/columns.tsx | 6 +- .../giat-routine/image/detail/[id]/page.tsx | 13 +- lib/menus.ts | 256 ++++++++++++++++-- service/content/content.ts | 3 +- 7 files changed, 286 insertions(+), 79 deletions(-) diff --git a/app/[locale]/(protected)/contributor/agenda-setting/calender-view.tsx b/app/[locale]/(protected)/contributor/agenda-setting/calender-view.tsx index c72dfaef..7068813f 100644 --- a/app/[locale]/(protected)/contributor/agenda-setting/calender-view.tsx +++ b/app/[locale]/(protected)/contributor/agenda-setting/calender-view.tsx @@ -119,6 +119,9 @@ const CalendarView = ({ categories }: CalendarViewProps) => { ); const [selectedEventDate, setSelectedEventDate] = useState(null); const roleId = Number(getCookiesDecrypt("urie")) || 0; + const userLevelId = Number(getCookiesDecrypt("ulie")) || 0; + console.log("roleId", roleId); + console.log("userlevel", userLevelId); const [apiEvents, setApiEvents] = useState([]); const [Isloading, setLoading] = useState(false); const [draggableInitialized, setDraggableInitialized] = @@ -574,11 +577,11 @@ const CalendarView = ({ categories }: CalendarViewProps) => {
- + {roleId == 3 || roleId == 11 || roleId == 2 || roleId == 12 ? ( diff --git a/app/[locale]/(protected)/contributor/content/image/components/columns.tsx b/app/[locale]/(protected)/contributor/content/image/components/columns.tsx index 48819b15..e6afa317 100644 --- a/app/[locale]/(protected)/contributor/content/image/components/columns.tsx +++ b/app/[locale]/(protected)/contributor/content/image/components/columns.tsx @@ -110,53 +110,29 @@ const columns: ColumnDef[] = [ ); }, }, + // { - accessorKey: "statusId", + accessorKey: "statusName", header: "Status", cell: ({ row }) => { - const userLevelId = 2; // Gantilah sesuai dengan konteks aplikasi - const statusId = Number(row.getValue("statusId")); - const reviewedAtLevel = row.original.reviewedAtLevel as string | null; - const needApprovalFromLevel = Number(row.original.needApprovalFromLevel); + const statusColors: Record = { + diterima: "bg-green-100 text-green-600", + "menunggu review": "bg-orange-100 text-orange-600", + }; - let statusName = row.getValue("statusName") as string; - let icon = "fa:times-circle"; - let statusClass = "bg-gray-100 text-gray-600"; - - if ( - (statusId === 2 && - reviewedAtLevel !== null && - !reviewedAtLevel.includes(`:${userLevelId}:`)) || - (statusId === 1 && needApprovalFromLevel === userLevelId) - ) { - statusName = "Menunggu Review"; - icon = "fa:hourglass-end"; - statusClass = "bg-orange-100 text-orange-600"; - } else if ( - statusId === 2 && - reviewedAtLevel?.includes(`:${userLevelId}:`) - ) { - icon = "fa:check-circle"; - statusClass = "bg-green-100 text-green-600"; - } else if (statusId === 2) { - icon = "fa:check-circle"; - statusClass = "bg-green-100 text-green-600"; - } else if (statusId === 3) { - icon = "fa:comment"; - statusClass = "bg-blue-100 text-blue-600"; - } else if (statusId === 1) { - icon = "fa:hourglass-end"; - statusClass = "bg-orange-100 text-orange-600"; - } + const status = row.getValue("statusName") as string; + const statusName = status?.toLocaleLowerCase(); + const statusStyles = + statusColors[statusName] || "bg-red-200 text-red-600"; return ( - {statusName} + {status} {/* Tetap tampilkan nilai asli */} ); }, diff --git a/app/[locale]/(protected)/contributor/content/spit/table-spit/table-spit.tsx b/app/[locale]/(protected)/contributor/content/spit/table-spit/table-spit.tsx index 01ed5e95..edb57893 100644 --- a/app/[locale]/(protected)/contributor/content/spit/table-spit/table-spit.tsx +++ b/app/[locale]/(protected)/contributor/content/spit/table-spit/table-spit.tsx @@ -47,6 +47,8 @@ import { DropdownMenuTrigger, } from "@/components/ui/dropdown-menu"; import { Label } from "@/components/ui/label"; +import { useTranslations } from "next-intl"; +import { format } from "date-fns"; // export type CompanyData = { // no: number; @@ -77,7 +79,8 @@ const TableSPIT = () => { const [search, setSearch] = React.useState(""); const userId = getCookiesDecrypt("uie"); const userLevelId = getCookiesDecrypt("ulie"); - + const t = useTranslations("AnalyticsDashboard"); + const [dateFilter, setDateFilter] = React.useState(""); const [totalData, setTotalData] = React.useState(1); const [sorting, setSorting] = React.useState([]); const [columnFilters, setColumnFilters] = React.useState( @@ -117,7 +120,7 @@ const TableSPIT = () => { React.useEffect(() => { fetchData(); - }, [page, limit, search, statusFilter]); + }, [page, limit, search, statusFilter, dateFilter]); async function fetchData() { let isPublish; @@ -129,8 +132,18 @@ const TableSPIT = () => { isPublish = statusFilter.includes(1) ? false : true; } + const formattedStartDate = dateFilter + ? format(new Date(dateFilter), "yyyy-MM-dd") + : ""; + try { - const res = await listSPIT(page - 1, limit, search, isPublish); + const res = await listSPIT( + page - 1, + limit, + search, + formattedStartDate, + isPublish + ); const data = res?.data?.data; const contentData = data?.content || []; @@ -192,6 +205,15 @@ const TableSPIT = () => {

Filter

+
+ + setDateFilter(e.target.value)} + className="max-w-sm" + /> +
[] = [ const userRoleId: number = Number(getCookiesDecrypt("urie")); const userLevelNumber: number = Number(getCookiesDecrypt("ulne")); - // Mengambil data dari row.original agar lebih aman const isPublishForAll: boolean = Boolean(row.original.isPublishForAll); const isPublishForMabes: boolean = Boolean( row.original.isPublishForMabes ); - // Logika status berdasarkan role dan data dari API const isPending: boolean = - (userRoleId === 3 && userLevelNumber === 1 && !isPublishForAll) || // Role 3 dengan level 1 hanya publish jika isPublishForAll true - ((userRoleId === 11 || userRoleId === 12) && !isPublishForMabes); // Role 11 dan 12 hanya publish jika isPublishForMabes true + (userRoleId === 3 && userLevelNumber === 1 && !isPublishForAll) || + ((userRoleId === 11 || userRoleId === 12) && !isPublishForMabes); const isTerkirim: boolean = isPublishForMabes && !isPublishForAll; diff --git a/app/[locale]/(protected)/shared/curated-content/giat-routine/image/detail/[id]/page.tsx b/app/[locale]/(protected)/shared/curated-content/giat-routine/image/detail/[id]/page.tsx index 133d85c1..8158413b 100644 --- a/app/[locale]/(protected)/shared/curated-content/giat-routine/image/detail/[id]/page.tsx +++ b/app/[locale]/(protected)/shared/curated-content/giat-routine/image/detail/[id]/page.tsx @@ -543,16 +543,25 @@ export default function DetailImage() { {/* Polda Checkbox */} + {/* Satker Checkbox */} + + {/* International Checkbox */}