[QUDO-96,QUDO-101,QUDO-100]feat:update

This commit is contained in:
Anang Yusman 2025-05-25 16:03:04 +08:00
parent a25869bb67
commit abdd4c0f67
6 changed files with 146 additions and 74 deletions

View File

@ -210,45 +210,6 @@ const EventModal = ({
fetchDetailData();
}, [event, setValue]);
// useEffect(() => {
// async function fetchPoldaPolres() {
// setIsLoading(true);
// try {
// const response = await getUserLevelForAssignments();
// const levelList = response?.data?.data.list;
// let listFiltered = [];
// if (agendaType == "polda") {
// listFiltered = levelList.filter(
// (level: any) => level.name != "SATKER POLRI"
// );
// } else if (agendaType == "polres") {
// listFiltered = levelList.filter(
// (level: any) => level.name != "SATKER POLRI"
// );
// } else if (agendaType == "satker") {
// listFiltered = levelList.filter(
// (level: any) => level.name == "SATKER POLRI"
// );
// }
// setListDest(listFiltered);
// const initialExpandedState = listFiltered.reduce(
// (acc: any, polda: any) => {
// acc[polda.id] = false;
// return acc;
// },
// {}
// );
// setExpandedPolda(initialExpandedState);
// } catch (error) {
// console.error("Error fetching Polda/Polres data:", error);
// } finally {
// setIsLoading(false);
// }
// }
// fetchPoldaPolres();
// }, [agendaType]);
const handleCheckboxChange = (levelId: number) => {
setCheckedLevels((prev) => {
const updatedLevels = new Set(prev);
@ -261,6 +222,15 @@ const EventModal = ({
});
};
const wilayahValueMap: Record<string, string> = {
semua: "0",
nasional: "1",
polda: "2",
polres: "3",
satker: "4",
international: "5",
};
const toggleWilayah = (key: string) => {
setWilayahPublish((prev: any) => {
const newState = { ...prev, [key]: !prev[key] };
@ -296,20 +266,33 @@ const EventModal = ({
};
const save = async (data: any, publish = false) => {
const publishTo = [];
if (wilayahPublish.semua) publishTo.push("all");
if (wilayahPublish.nasional) publishTo.push("mabes");
if (wilayahPublish.polda) publishTo.push(...selectedPolda);
if (wilayahPublish.polres) publishTo.push(...selectedPolres);
if (wilayahPublish.satker) publishTo.push(...selectedSatker);
if (wilayahPublish.international) publishTo.push("international");
const agendaTypeList: string[] = [];
const assignedToLevelList: string[] = [];
// Mapping dari checkbox wilayah ke agendaType
Object.keys(wilayahPublish).forEach((key) => {
if (wilayahPublish[key as keyof typeof wilayahPublish]) {
agendaTypeList.push(wilayahValueMap[key]);
}
});
// Unit-unit berdasarkan wilayah yang aktif
if (wilayahPublish.polda && selectedPolda.length > 0) {
assignedToLevelList.push(...selectedPolda);
}
if (wilayahPublish.polres && selectedPolres.length > 0) {
assignedToLevelList.push(...selectedPolres);
}
if (wilayahPublish.satker && selectedSatker.length > 0) {
assignedToLevelList.push(...selectedSatker);
}
const reqData = {
id: detailData?.id,
title: data.title,
description: data.description,
agendaType, // Include agendaType in request
publishTo,
agendaType: agendaTypeList.join(","), // <-- ubah array jadi string
assignedToLevel: assignedToLevelList.join(","), // <-- ubah array jadi string
startDate: format(startDate, "yyyy-MM-dd"),
endDate: format(endDate, "yyyy-MM-dd"),
};

View File

@ -161,6 +161,9 @@ export default function FormCollaboration() {
title: data.title,
narration: data.naration,
target: selectedTarget,
isCollaboration: true,
isEscalation: true,
isCollaborationWithNoneTicket: true,
sendToId: selectedOption?.id, // This should work now without the error
};

View File

@ -711,7 +711,7 @@ export default function FormImageDetail() {
)}
<Dialog open={modalOpen} onOpenChange={setModalOpen}>
<DialogContent size="md">
<DialogContent className="min-w-max h-[600px] overflow-y-auto">
<DialogHeader>
<DialogTitle>{t("leave-comment")}</DialogTitle>
</DialogHeader>

View File

@ -4,9 +4,19 @@ import { useParams, usePathname, useRouter } from "next/navigation";
import React, { useEffect, useState } from "react";
import Skeleton, { SkeletonTheme } from "react-loading-skeleton";
import { Link } from "@/i18n/routing";
import { formatDateToIndonesian, getPublicLocaleTimestamp, textEllipsis } from "@/utils/globals";
import {
formatDateToIndonesian,
getPublicLocaleTimestamp,
textEllipsis,
} from "@/utils/globals";
import { Icon } from "@iconify/react/dist/iconify.js";
import { Carousel, CarouselContent, CarouselItem, CarouselNext, CarouselPrevious } from "@/components/ui/carousel";
import {
Carousel,
CarouselContent,
CarouselItem,
CarouselNext,
CarouselPrevious,
} from "@/components/ui/carousel";
import Image from "next/image";
const HeaderBannerSatker = () => {
@ -27,7 +37,17 @@ const HeaderBannerSatker = () => {
// }
async function fetchData() {
const res = await listData("1", "", "", 5, 0, "createdAt", "", "", "satker-" + satkerName);
const res = await listData(
"1",
"",
"",
5,
0,
"createdAt",
"",
"",
"satker-" + satkerName
);
var data = res?.data?.data?.content;
if (data) {
const resStatic = await listStaticBanner(satkerName, false);
@ -96,13 +116,25 @@ const HeaderBannerSatker = () => {
{content?.map((row: any) => (
<CarouselItem key={row?.id}>
<div className="relative h-[310px] lg:h-[420px]">
<Image src={row?.thumbnailLink} alt="" width={1920} height={1080} className="w-full h-[310px] lg:h-[420px] rounded-lg object-cover" />
<Image
src={row?.thumbnailLink}
alt=""
width={1920}
height={1080}
className="w-full h-[310px] lg:h-[420px] rounded-lg object-cover"
/>
<div className="absolute bottom-0 left-0 right-0 bg-transparent backdrop-blur-sm text-white p-4 rounded-b-lg">
<span className="text-white bg-[#bb3523] rounded-md w-full h-full font-semibold uppercase text-sm px-4 py-1">{row?.categoryName}</span>
<span className="text-white bg-[#bb3523] rounded-md w-full h-full font-semibold uppercase text-sm px-4 py-1">
{row?.categoryName}
</span>
<Link
href={
Number(row.fileType?.id) == 1
? `${asPath.includes("/satker/") == true ? asPath : ""}/image/detail/${row.slug}`
? `${
asPath.includes("/satker/") == true
? asPath
: ""
}/image/detail/${row.slug}`
: Number(row.fileType?.id) == 2
? `/video/detail/${row.slug}`
: Number(row.fileType?.id) == 3
@ -113,8 +145,10 @@ const HeaderBannerSatker = () => {
<h3>{row.title}</h3>
</Link>
<p className="text-xs flex flex-row items-center gap-1 mt-1 text-white">
{getPublicLocaleTimestamp(new Date(row?.createdAt))} WIB {" | "}
<Icon icon="formkit:eye" width="15" height="15" /> {row?.clickCount}
{getPublicLocaleTimestamp(new Date(row?.createdAt))} WIB{" "}
{" | "}
<Icon icon="formkit:eye" width="15" height="15" />{" "}
{row?.clickCount}
</p>
</div>
</div>
@ -171,14 +205,24 @@ const HeaderBannerSatker = () => {
{content?.map((item: any) => (
<li key={item?.id} className="flex gap-4 flex-row lg:w-full ">
<div className="flex-shrink-0 w-24 rounded-lg">
<Image width={720} height={480} src={item?.thumbnailLink} alt={item?.title} className="w-full h-[73px] object-cover rounded-lg" />
<Image
width={720}
height={480}
src={item?.thumbnailLink}
alt={item?.title}
className="w-full h-[73px] object-cover rounded-lg"
/>
</div>
<div className="w-[280px] lg:w-auto">
<span className="text-white bg-[#bb3523] px-4 py-1 rounded-lg flex text-[8px] font-bold uppercase w-fit">{item?.categoryName}</span>
<span className="text-white bg-[#bb3523] px-4 py-1 rounded-lg flex text-[8px] font-bold uppercase w-fit">
{item?.categoryName}
</span>
<Link
href={
Number(item?.fileType?.id) == 1
? `${asPath.includes("/satker/") == true ? asPath : ""}/image/detail/${item?.slug}`
? `${
asPath.includes("/satker/") == true ? asPath : ""
}/image/detail/${item?.slug}`
: Number(item?.fileType?.id) == 2
? `/video/detail/${item?.slug}`
: Number(item?.fileType?.id) == 3
@ -186,11 +230,19 @@ const HeaderBannerSatker = () => {
: `/audio/detail/${item?.slug}`
}
>
<h3 className="text-base font-bold mt-2">{textEllipsis(item?.title, 30)}</h3>
<h3 className="text-base font-bold mt-2">
{textEllipsis(item?.title, 30)}
</h3>
</Link>
<p className="text-[10px] flex flex-row items-center gap-1 text-gray-500 mt-1">
{formatDateToIndonesian(new Date(item?.createdAt))} {item?.timezone ? item?.timezone : "WIB"} |{" "}
<svg xmlns="http://www.w3.org/2000/svg" width="1.2em" height="1.2em" viewBox="0 0 24 24">
{formatDateToIndonesian(new Date(item?.createdAt))}{" "}
{item?.timezone ? item?.timezone : "WIB"} |{" "}
<svg
xmlns="http://www.w3.org/2000/svg"
width="1.2em"
height="1.2em"
viewBox="0 0 24 24"
>
<path
fill="currentColor"
d="M11.5 18c4 0 7.46-2.22 9.24-5.5C18.96 9.22 15.5 7 11.5 7s-7.46 2.22-9.24 5.5C4.04 15.78 7.5 18 11.5 18m0-12c4.56 0 8.5 2.65 10.36 6.5C20 16.35 16.06 19 11.5 19S3 16.35 1.14 12.5C3 8.65 6.94 6 11.5 6m0 2C14 8 16 10 16 12.5S14 17 11.5 17S7 15 7 12.5S9 8 11.5 8m0 1A3.5 3.5 0 0 0 8 12.5a3.5 3.5 0 0 0 3.5 3.5a3.5 3.5 0 0 0 3.5-3.5A3.5 3.5 0 0 0 11.5 9"

View File

@ -43,7 +43,19 @@ import "swiper/css";
import "swiper/css/pagination";
import FormSurvey from "./survey";
const HeroModal = ({ onClose }: { onClose: () => void }) => {
type HeroModalProps = {
onClose: () => void;
group: string;
poldaName?: string;
satkerName?: string;
};
const HeroModal = ({
onClose,
group,
poldaName,
satkerName,
}: HeroModalProps) => {
const [heroData, setHeroData] = useState<any>();
const params = useParams();
const locale = params?.locale;
@ -79,9 +91,29 @@ const HeroModal = ({ onClose }: { onClose: () => void }) => {
}, []);
const initFetch = async () => {
const response = await getHeroData();
console.log(response);
setHeroData(response?.data?.data?.content);
// Ambil data banner dari API listStaticBanner
const response = await listStaticBanner(
group === "mabes"
? ""
: group === "polda" && poldaName && String(poldaName)?.length > 1
? poldaName
: group === "satker" && satkerName && String(satkerName)?.length > 1
? "satker-" + satkerName
: ""
);
// Ambil dan bersihkan data media dari response
const banners =
response?.data?.data?.map((item: any) => {
const media = item?.mediaUpload;
if (media?.fileType) {
media.fileTypeId = media.fileType.id;
}
return media;
}) || [];
console.log("banner Modal", banners);
setHeroData(banners); // hanya data dari listStaticBanner
};
return (
<div className="fixed inset-0 flex items-center justify-center backdrop-brightness-50 z-50 ">
@ -293,7 +325,9 @@ const HeroNew = (props: { group?: string }) => {
return (
<div className="flex items-start justify-center mx-auto w-auto">
<div className="relative">
{showModal && <HeroModal onClose={() => setShowModal(false)} />}
{showModal && (
<HeroModal onClose={() => setShowModal(false)} group="mabes" />
)}
{/* {showFormModal && <FormSurvey />} */}
</div>

View File

@ -3146,16 +3146,16 @@ export function getMenuList(pathname: string, t: any): Group[] {
icon: "material-symbols:map-search-outline",
submenus: [
{
href: "/admin/media-tracking/media-online",
label: "Media Online",
active: pathname === "/admin/media-tracking/media-online",
href: "/admin/media-tracking",
label: "Tracking Beritra Hari Ini",
active: pathname === "/admin/media-tracking",
icon: "heroicons:arrow-trending-up",
children: [],
},
{
href: "/admin/media-tracking",
label: "Tracking Beritra Hari Ini",
active: pathname === "/admin/media-tracking",
href: "/admin/media-tracking/media-online",
label: "Media Online",
active: pathname === "/admin/media-tracking/media-online",
icon: "heroicons:arrow-trending-up",
children: [],
},