Merge branch 'dev-anang' of https://gitlab.com/hanifsalafi/mediahub_redesign
This commit is contained in:
commit
55967e8831
|
|
@ -119,6 +119,9 @@ const CalendarView = ({ categories }: CalendarViewProps) => {
|
|||
);
|
||||
const [selectedEventDate, setSelectedEventDate] = useState<Date | null>(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<CalendarEvent[]>([]);
|
||||
const [Isloading, setLoading] = useState<boolean>(false);
|
||||
const [draggableInitialized, setDraggableInitialized] =
|
||||
|
|
@ -574,11 +577,11 @@ const CalendarView = ({ categories }: CalendarViewProps) => {
|
|||
<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">
|
||||
<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 ? (
|
||||
<Button
|
||||
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" />
|
||||
{t("addEvent")}
|
||||
|
|
@ -589,8 +592,8 @@ const CalendarView = ({ categories }: CalendarViewProps) => {
|
|||
<div>
|
||||
<Dialog open={open} onOpenChange={setOpen}>
|
||||
<DialogTrigger asChild>
|
||||
{roleId == 2 ? (
|
||||
<Button className="dark:bg-background dark:text-foreground ">
|
||||
{roleId === 3 && userLevelId === 216 ? (
|
||||
<Button className="dark:bg-background dark:text-foreground w-[250px]">
|
||||
<Book className="w-4 h-4" />
|
||||
{t("bag-pa-monitoring-results")}
|
||||
</Button>
|
||||
|
|
|
|||
|
|
@ -110,53 +110,29 @@ const columns: ColumnDef<any>[] = [
|
|||
);
|
||||
},
|
||||
},
|
||||
//
|
||||
{
|
||||
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<string, string> = {
|
||||
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 (
|
||||
<Badge
|
||||
className={cn(
|
||||
"rounded-full px-5 w-full whitespace-nowrap",
|
||||
statusClass
|
||||
statusStyles
|
||||
)}
|
||||
>
|
||||
{statusName}
|
||||
{status} {/* Tetap tampilkan nilai asli */}
|
||||
</Badge>
|
||||
);
|
||||
},
|
||||
|
|
|
|||
|
|
@ -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<number>(1);
|
||||
const [sorting, setSorting] = React.useState<SortingState>([]);
|
||||
const [columnFilters, setColumnFilters] = React.useState<ColumnFiltersState>(
|
||||
|
|
@ -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 = () => {
|
|||
<div className="flex flex-row justify-between my-1 mx-1">
|
||||
<p>Filter</p>
|
||||
</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>
|
||||
<div className="flex items-center px-4 py-1">
|
||||
<input
|
||||
|
|
|
|||
|
|
@ -98,26 +98,28 @@ const columns: ColumnDef<any>[] = [
|
|||
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;
|
||||
|
||||
return (
|
||||
<Badge
|
||||
className={`whitespace-nowrap px-2 py-1 rounded-full ${
|
||||
isPending
|
||||
? "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"
|
||||
}`}
|
||||
>
|
||||
{isPending ? "Pending" : "Publish"}
|
||||
{isPending ? "Pending" : isTerkirim ? "Terkirim" : "Publish"}
|
||||
</Badge>
|
||||
);
|
||||
},
|
||||
|
|
|
|||
|
|
@ -543,16 +543,25 @@ export default function DetailImage() {
|
|||
{/* Polda Checkbox */}
|
||||
<label className=" cursor-pointer flex items-center gap-2">
|
||||
<Checkbox
|
||||
checked={data.placements === "polda"} // Automatically checks if placement matches
|
||||
checked={data.placements === "polda"}
|
||||
disabled
|
||||
/>
|
||||
<span>Wilayah</span>
|
||||
</label>
|
||||
|
||||
{/* Satker Checkbox */}
|
||||
<label className=" cursor-pointer flex items-center gap-2">
|
||||
<Checkbox
|
||||
checked={data.placements === "satker"}
|
||||
disabled
|
||||
/>
|
||||
<span>Satker</span>
|
||||
</label>
|
||||
|
||||
{/* International Checkbox */}
|
||||
<label className=" cursor-pointer flex items-center gap-2">
|
||||
<Checkbox
|
||||
checked={data.placements === "international"} // Automatically checks if placement matches
|
||||
checked={data.placements === "international"}
|
||||
disabled
|
||||
/>
|
||||
<span>International</span>
|
||||
|
|
|
|||
|
|
@ -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) => {
|
||||
|
|
|
|||
284
lib/menus.ts
284
lib/menus.ts
|
|
@ -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 =====
|
||||
// {
|
||||
// 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) {
|
||||
menusSelected = [
|
||||
|
|
@ -2723,20 +2851,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",
|
||||
|
|
@ -3159,35 +3287,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: [],
|
||||
// },
|
||||
// ],
|
||||
// },
|
||||
// ],
|
||||
// },
|
||||
{
|
||||
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 {
|
||||
menusSelected = [
|
||||
|
|
@ -3273,6 +3436,41 @@ export function getMenuList(pathname: string, t: any): Group[] {
|
|||
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: [],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
|
|
|
|||
|
|
@ -129,10 +129,11 @@ export async function listSPIT(
|
|||
page: any,
|
||||
limit: any,
|
||||
title = "",
|
||||
contentCreatedDate = "",
|
||||
isPublish: any
|
||||
) {
|
||||
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}`
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue