This commit is contained in:
hanif salafi 2025-02-27 10:28:27 +07:00
commit 55967e8831
8 changed files with 308 additions and 99 deletions

View File

@ -119,6 +119,9 @@ const CalendarView = ({ categories }: CalendarViewProps) => {
); );
const [selectedEventDate, setSelectedEventDate] = useState<Date | null>(null); const [selectedEventDate, setSelectedEventDate] = useState<Date | null>(null);
const roleId = Number(getCookiesDecrypt("urie")) || 0; const roleId = Number(getCookiesDecrypt("urie")) || 0;
const userLevelId = Number(getCookiesDecrypt("ulie")) || 0;
console.log("roleId", roleId);
console.log("userlevel", userLevelId);
const [apiEvents, setApiEvents] = useState<CalendarEvent[]>([]); const [apiEvents, setApiEvents] = useState<CalendarEvent[]>([]);
const [Isloading, setLoading] = useState<boolean>(false); const [Isloading, setLoading] = useState<boolean>(false);
const [draggableInitialized, setDraggableInitialized] = const [draggableInitialized, setDraggableInitialized] =
@ -574,11 +577,11 @@ const CalendarView = ({ categories }: CalendarViewProps) => {
<div className="grid grid-cols-12 gap-6 divide-x divide-border"> <div className="grid grid-cols-12 gap-6 divide-x divide-border">
<Card className="col-span-12 lg:col-span-4 2xl:col-span-3 pb-5"> <Card className="col-span-12 lg:col-span-4 2xl:col-span-3 pb-5">
<CardContent className="p-0"> <CardContent className="p-0">
<CardHeader className="border-none mb-2 pt-5"> <CardHeader className="border-none mb-2 pt-5 ">
{roleId == 3 || roleId == 11 || roleId == 2 || roleId == 12 ? ( {roleId == 3 || roleId == 11 || roleId == 2 || roleId == 12 ? (
<Button <Button
onClick={handleDateClick} onClick={handleDateClick}
className="dark:bg-background dark:text-foreground" className="dark:bg-background dark:text-foreground w-[250px]"
> >
<Plus className="w-4 h-4 me-1" /> <Plus className="w-4 h-4 me-1" />
{t("addEvent")} {t("addEvent")}
@ -589,8 +592,8 @@ const CalendarView = ({ categories }: CalendarViewProps) => {
<div> <div>
<Dialog open={open} onOpenChange={setOpen}> <Dialog open={open} onOpenChange={setOpen}>
<DialogTrigger asChild> <DialogTrigger asChild>
{roleId == 2 ? ( {roleId === 3 && userLevelId === 216 ? (
<Button className="dark:bg-background dark:text-foreground "> <Button className="dark:bg-background dark:text-foreground w-[250px]">
<Book className="w-4 h-4" /> <Book className="w-4 h-4" />
{t("bag-pa-monitoring-results")} {t("bag-pa-monitoring-results")}
</Button> </Button>

View File

@ -110,53 +110,29 @@ const columns: ColumnDef<any>[] = [
); );
}, },
}, },
//
{ {
accessorKey: "statusId", accessorKey: "statusName",
header: "Status", header: "Status",
cell: ({ row }) => { cell: ({ row }) => {
const userLevelId = 2; // Gantilah sesuai dengan konteks aplikasi const statusColors: Record<string, string> = {
const statusId = Number(row.getValue("statusId")); diterima: "bg-green-100 text-green-600",
const reviewedAtLevel = row.original.reviewedAtLevel as string | null; "menunggu review": "bg-orange-100 text-orange-600",
const needApprovalFromLevel = Number(row.original.needApprovalFromLevel); };
let statusName = row.getValue("statusName") as string; const status = row.getValue("statusName") as string;
let icon = "fa:times-circle"; const statusName = status?.toLocaleLowerCase();
let statusClass = "bg-gray-100 text-gray-600"; const statusStyles =
statusColors[statusName] || "bg-red-200 text-red-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";
}
return ( return (
<Badge <Badge
className={cn( className={cn(
"rounded-full px-5 w-full whitespace-nowrap", "rounded-full px-5 w-full whitespace-nowrap",
statusClass statusStyles
)} )}
> >
{statusName} {status} {/* Tetap tampilkan nilai asli */}
</Badge> </Badge>
); );
}, },

View File

@ -47,6 +47,8 @@ import {
DropdownMenuTrigger, DropdownMenuTrigger,
} from "@/components/ui/dropdown-menu"; } from "@/components/ui/dropdown-menu";
import { Label } from "@/components/ui/label"; import { Label } from "@/components/ui/label";
import { useTranslations } from "next-intl";
import { format } from "date-fns";
// export type CompanyData = { // export type CompanyData = {
// no: number; // no: number;
@ -77,7 +79,8 @@ const TableSPIT = () => {
const [search, setSearch] = React.useState(""); const [search, setSearch] = React.useState("");
const userId = getCookiesDecrypt("uie"); const userId = getCookiesDecrypt("uie");
const userLevelId = getCookiesDecrypt("ulie"); const userLevelId = getCookiesDecrypt("ulie");
const t = useTranslations("AnalyticsDashboard");
const [dateFilter, setDateFilter] = React.useState("");
const [totalData, setTotalData] = React.useState<number>(1); const [totalData, setTotalData] = React.useState<number>(1);
const [sorting, setSorting] = React.useState<SortingState>([]); const [sorting, setSorting] = React.useState<SortingState>([]);
const [columnFilters, setColumnFilters] = React.useState<ColumnFiltersState>( const [columnFilters, setColumnFilters] = React.useState<ColumnFiltersState>(
@ -117,7 +120,7 @@ const TableSPIT = () => {
React.useEffect(() => { React.useEffect(() => {
fetchData(); fetchData();
}, [page, limit, search, statusFilter]); }, [page, limit, search, statusFilter, dateFilter]);
async function fetchData() { async function fetchData() {
let isPublish; let isPublish;
@ -129,8 +132,18 @@ const TableSPIT = () => {
isPublish = statusFilter.includes(1) ? false : true; isPublish = statusFilter.includes(1) ? false : true;
} }
const formattedStartDate = dateFilter
? format(new Date(dateFilter), "yyyy-MM-dd")
: "";
try { 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 data = res?.data?.data;
const contentData = data?.content || []; const contentData = data?.content || [];
@ -192,6 +205,15 @@ const TableSPIT = () => {
<div className="flex flex-row justify-between my-1 mx-1"> <div className="flex flex-row justify-between my-1 mx-1">
<p>Filter</p> <p>Filter</p>
</div> </div>
<div className="mx-2 my-1">
<Label>{t("date")}</Label>
<Input
type="date"
value={dateFilter}
onChange={(e) => setDateFilter(e.target.value)}
className="max-w-sm"
/>
</div>
<Label className="ml-2 mt-2">Status</Label> <Label className="ml-2 mt-2">Status</Label>
<div className="flex items-center px-4 py-1"> <div className="flex items-center px-4 py-1">
<input <input

View File

@ -98,26 +98,28 @@ const columns: ColumnDef<any>[] = [
const userRoleId: number = Number(getCookiesDecrypt("urie")); const userRoleId: number = Number(getCookiesDecrypt("urie"));
const userLevelNumber: number = Number(getCookiesDecrypt("ulne")); const userLevelNumber: number = Number(getCookiesDecrypt("ulne"));
// Mengambil data dari row.original agar lebih aman
const isPublishForAll: boolean = Boolean(row.original.isPublishForAll); const isPublishForAll: boolean = Boolean(row.original.isPublishForAll);
const isPublishForMabes: boolean = Boolean( const isPublishForMabes: boolean = Boolean(
row.original.isPublishForMabes row.original.isPublishForMabes
); );
// Logika status berdasarkan role dan data dari API
const isPending: boolean = const isPending: boolean =
(userRoleId === 3 && userLevelNumber === 1 && !isPublishForAll) || // Role 3 dengan level 1 hanya publish jika isPublishForAll true (userRoleId === 3 && userLevelNumber === 1 && !isPublishForAll) ||
((userRoleId === 11 || userRoleId === 12) && !isPublishForMabes); // Role 11 dan 12 hanya publish jika isPublishForMabes true ((userRoleId === 11 || userRoleId === 12) && !isPublishForMabes);
const isTerkirim: boolean = isPublishForMabes && !isPublishForAll;
return ( return (
<Badge <Badge
className={`whitespace-nowrap px-2 py-1 rounded-full ${ className={`whitespace-nowrap px-2 py-1 rounded-full ${
isPending isPending
? "bg-orange-100 text-orange-600" // Warna kuning untuk "Pending" ? "bg-orange-100 text-orange-600" // Warna kuning untuk "Pending"
: isTerkirim
? "bg-blue-100 text-blue-600" // Warna biru untuk "Terkirim"
: "bg-green-100 text-green-600" // Warna hijau untuk "Publish" : "bg-green-100 text-green-600" // Warna hijau untuk "Publish"
}`} }`}
> >
{isPending ? "Pending" : "Publish"} {isPending ? "Pending" : isTerkirim ? "Terkirim" : "Publish"}
</Badge> </Badge>
); );
}, },

View File

@ -543,16 +543,25 @@ export default function DetailImage() {
{/* Polda Checkbox */} {/* Polda Checkbox */}
<label className=" cursor-pointer flex items-center gap-2"> <label className=" cursor-pointer flex items-center gap-2">
<Checkbox <Checkbox
checked={data.placements === "polda"} // Automatically checks if placement matches checked={data.placements === "polda"}
disabled disabled
/> />
<span>Wilayah</span> <span>Wilayah</span>
</label> </label>
{/* Satker Checkbox */}
<label className=" cursor-pointer flex items-center gap-2">
<Checkbox
checked={data.placements === "satker"}
disabled
/>
<span>Satker</span>
</label>
{/* International Checkbox */} {/* International Checkbox */}
<label className=" cursor-pointer flex items-center gap-2"> <label className=" cursor-pointer flex items-center gap-2">
<Checkbox <Checkbox
checked={data.placements === "international"} // Automatically checks if placement matches checked={data.placements === "international"}
disabled disabled
/> />
<span>International</span> <span>International</span>

View File

@ -224,10 +224,8 @@ export default function FormContestDetail() {
}, [detail?.targetOutput]); }, [detail?.targetOutput]);
useEffect(() => { useEffect(() => {
if (detail?.targetParticipantTopLevel) { if (detail?.targetOutput) {
const outputSet = new Set( const outputSet = new Set(detail.targetOutput.split(",").map(Number));
detail.targetParticipantTopLevel.split(",").map(Number)
);
setUnitSelection({ setUnitSelection({
allUnit: outputSet.has(0), allUnit: outputSet.has(0),
mabes: outputSet.has(1), mabes: outputSet.has(1),
@ -235,7 +233,7 @@ export default function FormContestDetail() {
polres: outputSet.has(3), polres: outputSet.has(3),
}); });
} }
}, [detail?.targetParticipantTopLevel]); }, [detail?.targetOutput]);
const handleCheckboxChange = (levelId: number) => { const handleCheckboxChange = (levelId: number) => {
setCheckedLevels((prev) => { setCheckedLevels((prev) => {

View File

@ -260,6 +260,70 @@ export function getMenuList(pathname: string, t: any): Group[] {
}, },
], ],
}, },
{
groupLabel: "",
id: "settings",
menus: [
{
id: "settings",
href: "/admin/settings",
label: t("settings"),
active: pathname.includes("/settinng"),
icon: "material-symbols:settings",
submenus: [
{
href: "/admin/settings/category",
label: t("category"),
active: pathname === "/admin/settings/category",
icon: "heroicons:arrow-trending-up",
children: [],
},
{
href: "/admin/settings/tag",
label: "Tag",
active: pathname === "/admin/settings/tag",
icon: "heroicons:arrow-trending-up",
children: [],
},
{
href: "/admin/settings/banner",
label: "Banner",
active: pathname === "/admin/settings/banner",
icon: "heroicons:arrow-trending-up",
children: [],
},
{
href: "/admin/settings/feedback",
label: "Feedback",
active: pathname === "/admin/settings/feedback",
icon: "heroicons:arrow-trending-up",
children: [],
},
{
href: "/admin/settings/faq",
label: "FAQ",
active: pathname === "/admin/settings/faq",
icon: "heroicons:arrow-trending-up",
children: [],
},
{
href: "https://nat-mediahub.polri.go.id/",
label: "Mediahub 2022",
active: pathname === "/admin/settings/mediahub-2022",
icon: "heroicons:arrow-trending-up",
children: [],
},
{
href: "/admin/settings/privacy",
label: t("privacy"),
active: pathname === "/admin/settings/privacy",
icon: "heroicons:arrow-trending-up",
children: [],
},
],
},
],
},
// ===== MENU TEMPLATE DASHCODE ===== // ===== MENU TEMPLATE DASHCODE =====
// { // {
// groupLabel: t("apps"), // groupLabel: t("apps"),
@ -1790,6 +1854,70 @@ export function getMenuList(pathname: string, t: any): Group[] {
}, },
], ],
}, },
{
groupLabel: "",
id: "settings",
menus: [
{
id: "settings",
href: "/admin/settings",
label: t("settings"),
active: pathname.includes("/settinng"),
icon: "material-symbols:settings",
submenus: [
{
href: "/admin/settings/category",
label: t("category"),
active: pathname === "/admin/settings/category",
icon: "heroicons:arrow-trending-up",
children: [],
},
{
href: "/admin/settings/tag",
label: "Tag",
active: pathname === "/admin/settings/tag",
icon: "heroicons:arrow-trending-up",
children: [],
},
{
href: "/admin/settings/banner",
label: "Banner",
active: pathname === "/admin/settings/banner",
icon: "heroicons:arrow-trending-up",
children: [],
},
{
href: "/admin/settings/feedback",
label: "Feedback",
active: pathname === "/admin/settings/feedback",
icon: "heroicons:arrow-trending-up",
children: [],
},
{
href: "/admin/settings/faq",
label: "FAQ",
active: pathname === "/admin/settings/faq",
icon: "heroicons:arrow-trending-up",
children: [],
},
{
href: "https://nat-mediahub.polri.go.id/",
label: "Mediahub 2022",
active: pathname === "/admin/settings/mediahub-2022",
icon: "heroicons:arrow-trending-up",
children: [],
},
{
href: "/admin/settings/privacy",
label: t("privacy"),
active: pathname === "/admin/settings/privacy",
icon: "heroicons:arrow-trending-up",
children: [],
},
],
},
],
},
]; ];
} else if (Number(userLevelId) == 761) { } else if (Number(userLevelId) == 761) {
menusSelected = [ menusSelected = [
@ -2723,20 +2851,20 @@ export function getMenuList(pathname: string, t: any): Group[] {
}, },
], ],
}, },
{ // {
groupLabel: "", // groupLabel: "",
id: "agenda-setting", // id: "agenda-setting",
menus: [ // menus: [
{ // {
id: "agenda-setting", // id: "agenda-setting",
href: "/contributor/agenda-setting", // href: "/contributor/agenda-setting",
label: t("agenda-setting"), // label: t("agenda-setting"),
active: pathname.includes("/agenda-setting"), // active: pathname.includes("/agenda-setting"),
icon: "iconoir:journal-page", // icon: "iconoir:journal-page",
submenus: [], // submenus: [],
}, // },
], // ],
}, // },
{ {
groupLabel: "", groupLabel: "",
id: "management-user", id: "management-user",
@ -3159,35 +3287,70 @@ export function getMenuList(pathname: string, t: any): Group[] {
}, },
], ],
}, },
// { {
// groupLabel: "", groupLabel: "",
// id: "settings", id: "settings",
// menus: [ menus: [
// { {
// id: "settings", id: "settings",
// href: "/admin/settings", href: "/admin/settings",
// label: t("settings"), label: t("settings"),
// active: pathname.includes("/settinng"), active: pathname.includes("/settinng"),
// icon: "material-symbols:settings", icon: "material-symbols:settings",
// submenus: [ submenus: [
// { {
// href: "/admin/settings/category", href: "/admin/settings/category",
// label: t("category"), label: t("category"),
// active: pathname === "/admin/settings/category", active: pathname === "/admin/settings/category",
// icon: "heroicons:arrow-trending-up", icon: "heroicons:arrow-trending-up",
// children: [], children: [],
// }, },
// { {
// href: "/admin/settings/tag", href: "/admin/settings/tag",
// label: "Tag", label: "Tag",
// active: pathname === "/admin/settings/tag", active: pathname === "/admin/settings/tag",
// icon: "heroicons:arrow-trending-up", icon: "heroicons:arrow-trending-up",
// children: [], children: [],
// }, },
// ], {
// }, href: "/admin/settings/banner",
// ], label: "Banner",
// }, active: pathname === "/admin/settings/banner",
icon: "heroicons:arrow-trending-up",
children: [],
},
{
href: "/admin/settings/feedback",
label: "Feedback",
active: pathname === "/admin/settings/feedback",
icon: "heroicons:arrow-trending-up",
children: [],
},
{
href: "/admin/settings/faq",
label: "FAQ",
active: pathname === "/admin/settings/faq",
icon: "heroicons:arrow-trending-up",
children: [],
},
{
href: "https://nat-mediahub.polri.go.id/",
label: "Mediahub 2022",
active: pathname === "/admin/settings/mediahub-2022",
icon: "heroicons:arrow-trending-up",
children: [],
},
{
href: "/admin/settings/privacy",
label: t("privacy"),
active: pathname === "/admin/settings/privacy",
icon: "heroicons:arrow-trending-up",
children: [],
},
],
},
],
},
]; ];
} else { } else {
menusSelected = [ menusSelected = [
@ -3273,6 +3436,41 @@ export function getMenuList(pathname: string, t: any): Group[] {
icon: "heroicons:arrow-trending-up", icon: "heroicons:arrow-trending-up",
children: [], children: [],
}, },
{
href: "/admin/settings/banner",
label: "Banner",
active: pathname === "/admin/settings/banner",
icon: "heroicons:arrow-trending-up",
children: [],
},
{
href: "/admin/settings/feedback",
label: "Feedback",
active: pathname === "/admin/settings/feedback",
icon: "heroicons:arrow-trending-up",
children: [],
},
{
href: "/admin/settings/faq",
label: "FAQ",
active: pathname === "/admin/settings/faq",
icon: "heroicons:arrow-trending-up",
children: [],
},
{
href: "https://nat-mediahub.polri.go.id/",
label: "Mediahub 2022",
active: pathname === "/admin/settings/mediahub-2022",
icon: "heroicons:arrow-trending-up",
children: [],
},
{
href: "/admin/settings/privacy",
label: t("privacy"),
active: pathname === "/admin/settings/privacy",
icon: "heroicons:arrow-trending-up",
children: [],
},
], ],
}, },
], ],

View File

@ -129,10 +129,11 @@ export async function listSPIT(
page: any, page: any,
limit: any, limit: any,
title = "", title = "",
contentCreatedDate = "",
isPublish: any isPublish: any
) { ) {
return await httpGetInterceptor( return await httpGetInterceptor(
`media/spit/pagination?enablePage=1&page=${page}&size=${limit}&sort=desc&sortBy=contentTitleId&title=${title}&isPublish=${isPublish}` `media/spit/pagination?enablePage=1&page=${page}&size=${limit}&sort=desc&sortBy=contentTitleId&title=${title}& contentCreatedDate=${contentCreatedDate}&isPublish=${isPublish}`
); );
} }