diff --git a/app/[locale]/(protected)/contributor/agenda-setting/calender-view.tsx b/app/[locale]/(protected)/contributor/agenda-setting/calender-view.tsx index 78c2d012..833a2129 100644 --- a/app/[locale]/(protected)/contributor/agenda-setting/calender-view.tsx +++ b/app/[locale]/(protected)/contributor/agenda-setting/calender-view.tsx @@ -415,6 +415,7 @@ const CalendarView = ({ categories }: CalendarViewProps) => { mabes: "bg-yellow-500", polda: "bg-blue-400", polres: "bg-slate-400", + satker: "bg-orange-500", international: "bg-green-400", }; return colors[type]; @@ -635,7 +636,7 @@ const CalendarView = ({ categories }: CalendarViewProps) => { if (selectedCategory?.length === categories?.length) { setSelectedCategory([]); } else { - setSelectedCategory(categories.map((c) => c.value)); + setSelectedCategory(categories?.map((c) => c.value)); } }} /> diff --git a/app/[locale]/(protected)/contributor/agenda-setting/data.ts b/app/[locale]/(protected)/contributor/agenda-setting/data.ts index fddde01a..3cab4af9 100644 --- a/app/[locale]/(protected)/contributor/agenda-setting/data.ts +++ b/app/[locale]/(protected)/contributor/agenda-setting/data.ts @@ -125,7 +125,6 @@ export const categories = [ { label: "Polda", value: "polda", - className: "data-[state=checked]:bg-blue-400 data-[state=checked]:ring-blue-400", }, diff --git a/app/[locale]/(protected)/contributor/agenda-setting/event-modal.tsx b/app/[locale]/(protected)/contributor/agenda-setting/event-modal.tsx index 6d214941..e4abf2e9 100644 --- a/app/[locale]/(protected)/contributor/agenda-setting/event-modal.tsx +++ b/app/[locale]/(protected)/contributor/agenda-setting/event-modal.tsx @@ -396,7 +396,7 @@ const EventModal = ({ setStartDate(event?.event?.start); setEndDate(event?.event?.end); const eventCalendar = event?.event?.extendedProps?.calendar; - setAgendaType(eventCalendar || categories[0].value); + setAgendaType(eventCalendar || categories?.length > 0 && categories[0].value); } setValue("title", event?.event?.title || ""); setValue("description", event?.event?.description || ""); diff --git a/app/[locale]/(protected)/contributor/agenda-setting/page.tsx b/app/[locale]/(protected)/contributor/agenda-setting/page.tsx index a9235b2d..4f88d946 100644 --- a/app/[locale]/(protected)/contributor/agenda-setting/page.tsx +++ b/app/[locale]/(protected)/contributor/agenda-setting/page.tsx @@ -1,17 +1,49 @@ +"use client" + import { getEvents, getCategories } from "./utils"; import { calendarEvents, Category } from "./data"; import CalendarView from "./calender-view"; +import { getCookiesDecrypt } from "@/lib/utils"; +import { useEffect, useState } from "react"; +import { CalendarCategory } from "./data"; + +const CalenderPage = () => { + + const [categories, setCategories] = useState([]); + const userLevelNumber = Number(getCookiesDecrypt("ulne")) || 0; + const userLevelId = Number(getCookiesDecrypt("ulie")) || 0; + const userParentLevelId = Number(getCookiesDecrypt("uplie")) || 0; + + useEffect(() => { + initData(); + + async function initData() { + const events = await getEvents(); + const categories = await getCategories(); + let valueShowed : string[] = []; + if (userLevelNumber == 1) { + valueShowed = ['mabes', 'polda', 'polres', 'satker', 'international']; + } else if (userLevelNumber == 2 && userLevelId != 761) { + valueShowed = ['polda', 'polres']; + } else if ((userLevelNumber == 2 && userLevelId == 761) || (userLevelNumber == 3 && userParentLevelId == 761)) { + valueShowed = ['satker']; + } else if (userLevelNumber == 3 && userParentLevelId != 761) { + valueShowed = ['polres']; + } + + const formattedCategories = categories.filter((category: Category) => valueShowed.includes(category.value)) + .map((category: Category) => ({ + ...category, + activeClass: "", + })); + console.log(formattedCategories); + setCategories(formattedCategories); + } + }, []); -const CalenderPage = async () => { - const events = await getEvents(); - const categories = await getCategories(); - const formattedCategories = categories.map((category: Category) => ({ - ...category, - activeClass: "", - })); return (
- + {categories && }
); }; diff --git a/components/form/task/task-detail-form.tsx b/components/form/task/task-detail-form.tsx index 82aaea5d..18154507 100644 --- a/components/form/task/task-detail-form.tsx +++ b/components/form/task/task-detail-form.tsx @@ -177,6 +177,7 @@ interface UploadResult { fileType: { name: string }; uploadStatus: { name: string }; creatorName: string; + creatorGroup: string; } interface FileUploaded { @@ -395,6 +396,7 @@ export default function FormTaskDetail() { } } initState(); + // fetchFilteredData(); }, [id, refresh]); const handleUrlChange = (index: number, newUrl: string) => {