diff --git a/app/[locale]/(protected)/contributor/agenda-setting/calender-view.tsx b/app/[locale]/(protected)/contributor/agenda-setting/calender-view.tsx index 2ce35a53..851d9a9b 100644 --- a/app/[locale]/(protected)/contributor/agenda-setting/calender-view.tsx +++ b/app/[locale]/(protected)/contributor/agenda-setting/calender-view.tsx @@ -32,15 +32,15 @@ const INITIAL_MONTH = dayjs().format("M"); export interface AgendaSettingsAPIResponse { id: number; title: string; + createdByName: string; description: string; agendaType: string; - startDate: string; // API mengembalikan tanggal dalam bentuk string + startDate: string; endDate: string; isActive: boolean; createdAt: string; updatedAt: string; createdById: number | null; - createdByName: string | null; } interface APIResponse { @@ -89,12 +89,15 @@ const CalendarView = ({ categories }: CalendarViewProps) => { const events = res?.data?.data.map((event: any) => ({ id: event.id.toString(), title: event.title, + createBy: "Mabes Polri - Approver", + createdByName: event.createdByName, start: new Date(event.startDate), end: new Date(event.endDate), - allDay: true, // Assuming all events are all-day by default + allDay: true, extendedProps: { - calendar: event.agendaType, // Map agendaType to the calendar category + calendar: event.agendaType, description: event.description, + createdByName: event.createdByName, }, })); @@ -130,25 +133,25 @@ const CalendarView = ({ categories }: CalendarViewProps) => { const month = (selectedMonth.getMonth() + 1).toString(); const typeFilter = ""; // Replace with your type filter logic if needed - const response = await getAgendaSettingsList( - year, - month, - typeFilter - ); + const response = await getAgendaSettingsList(year, month, typeFilter); if (response?.data && Array.isArray(response?.data)) { // Transform API data to match CalendarEvent type - const eventsFromAPI: CalendarEvent[] = response?.data?.map((item) => ({ - id: item.id.toString(), - title: item.title, - start: new Date(item.startDate), - end: new Date(item.endDate), - allDay: true, // Sesuaikan jika memang ada event sepanjang hari - extendedProps: { - calendar: item.agendaType, - description: item.description, - }, - })); + const eventsFromAPI: CalendarEvent[] = response?.data?.map( + (item) => ({ + id: item.id.toString(), + title: item.title, + createBy: "Mabes Polri - Approver", + createdByName: item.createdByName, + start: new Date(item.startDate), + end: new Date(item.endDate), + allDay: true, // Sesuaikan jika memang ada event sepanjang hari + extendedProps: { + calendar: item.agendaType, + description: item.description, + }, + }) + ); setApiEvents(eventsFromAPI); } else { @@ -235,6 +238,18 @@ const CalendarView = ({ categories }: CalendarViewProps) => { } }; + const renderEventContent = (eventInfo: any) => { + const { title } = eventInfo.event; + const { createdByName } = eventInfo.event.extendedProps; // Akses dari extendedProps + + return ( + <> +

{title}

+

Create By: {createdByName}

+ + ); + }; + const handleClassName = (arg: EventContentArg) => { if (arg.event.extendedProps.calendar === "mabes") { return "primary"; @@ -342,6 +357,7 @@ const CalendarView = ({ categories }: CalendarViewProps) => { dateClick={handleDateClick} eventClick={handleEventClick} initialView="dayGridMonth" + eventContent={renderEventContent} /> @@ -364,6 +380,8 @@ export type CalendarEvent = { title: string; start: Date; end: Date; + createBy: string; + createdByName: string; allDay: boolean; extendedProps: { calendar: string; diff --git a/app/[locale]/(protected)/contributor/agenda-setting/data.ts b/app/[locale]/(protected)/contributor/agenda-setting/data.ts index 15c4967b..fddde01a 100644 --- a/app/[locale]/(protected)/contributor/agenda-setting/data.ts +++ b/app/[locale]/(protected)/contributor/agenda-setting/data.ts @@ -120,20 +120,20 @@ export const categories = [ label: "Nasional", value: "mabes", className: - "data-[state=checked]:bg-primary data-[state=checked]:ring-primary", + "data-[state=checked]:bg-yellow-500 data-[state=checked]:ring-yellow-500", }, { label: "Polda", value: "polda", className: - "data-[state=checked]:bg-success data-[state=checked]:ring-success", + "data-[state=checked]:bg-blue-400 data-[state=checked]:ring-blue-400", }, { label: "Polres", value: "polres", className: - "data-[state=checked]:bg-destructive data-[state=checked]:ring-destructive ", + "data-[state=checked]:bg-slate-400 data-[state=checked]:ring-slate-400 ", }, { label: "Satker", @@ -144,7 +144,8 @@ export const categories = [ { label: "Internasional", value: "international", - className: "data-[state=checked]:bg-info data-[state=checked]:ring-info ", + className: + "data-[state=checked]:bg-green-500 data-[state=checked]:ring-green-500 ", }, ]; diff --git a/app/[locale]/(protected)/contributor/agenda-setting/event-modal.tsx b/app/[locale]/(protected)/contributor/agenda-setting/event-modal.tsx index 0010f772..513c743f 100644 --- a/app/[locale]/(protected)/contributor/agenda-setting/event-modal.tsx +++ b/app/[locale]/(protected)/contributor/agenda-setting/event-modal.tsx @@ -1,5 +1,10 @@ // "use client"; -import React, { useState, useEffect } from "react"; +import React, { + useState, + useEffect, + useRef, + Fragment, +} from "react"; import { Button } from "@/components/ui/button"; import { Input } from "@/components/ui/input"; import { Label } from "@/components/ui/label"; @@ -32,7 +37,7 @@ import { DialogTrigger, } from "@/components/ui/dialog"; import { Textarea } from "@/components/ui/textarea"; -import { error, loading } from "@/lib/swal"; +import { error, loading, success } from "@/lib/swal"; import Cookies from "js-cookie"; import Swal from "sweetalert2"; import withReactContent from "sweetalert2-react-content"; @@ -42,12 +47,18 @@ import { saveAgendaSettings } from "@/service/agenda-setting/agenda-setting"; import { Checkbox } from "@/components/ui/checkbox"; import { getUserLevelForAssignments } from "@/service/task"; import { AudioRecorder } from "react-audio-voice-recorder"; +import FileUploader from "@/components/form/shared/file-uploader"; +import { Upload } from "tus-js-client"; const schema = z.object({ title: z.string().min(3, { message: "Required" }), description: z.string().min(3, { message: "Required" }), }); +interface FileWithPreview extends File { + preview: string; +} + const EventModal = ({ open, onClose, @@ -64,7 +75,7 @@ const EventModal = ({ const [startDate, setStartDate] = useState(new Date()); const [endDate, setEndDate] = useState(new Date()); const [isPending, startTransition] = React.useTransition(); - const [calendarProps, setCalendarProps] = React.useState( + const [agendaType, setAgendaType] = React.useState( categories[0].value ); const [listDest, setListDest] = useState([]); @@ -78,6 +89,14 @@ const EventModal = ({ const [audioFile, setAudioFile] = useState(null); const [isRecording, setIsRecording] = useState(false); const [timer, setTimer] = useState(120); + const [imageFiles, setImageFiles] = useState([]); + const [videoFiles, setVideoFiles] = useState([]); + const [textFiles, setTextFiles] = useState([]); + const [audioFiles, setAudioFiles] = useState([]); + const [isImageUploadFinish, setIsImageUploadFinish] = useState(false); + const [isVideoUploadFinish, setIsVideoUploadFinish] = useState(false); + const [isTextUploadFinish, setIsTextUploadFinish] = useState(false); + const [isAudioUploadFinish, setIsAudioUploadFinish] = useState(false); const { register, @@ -96,8 +115,17 @@ const EventModal = ({ setIsLoading(true); try { const response = await getUserLevelForAssignments(); - setListDest(response?.data?.data.list); - const initialExpandedState = response?.data?.data.list.reduce( + 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; @@ -105,7 +133,6 @@ const EventModal = ({ {} ); setExpandedPolda(initialExpandedState); - console.log("polres", initialExpandedState); } catch (error) { console.error("Error fetching Polda/Polres data:", error); } finally { @@ -113,7 +140,8 @@ const EventModal = ({ } } fetchPoldaPolres(); - }, []); + console.log("Event", event); + }, [agendaType]); const handleCheckboxChange = (levelId: number) => { setCheckedLevels((prev) => { @@ -128,18 +156,15 @@ const EventModal = ({ }; const save = async (data: any) => { - if (!audioFile) return; - - const formData = new FormData(); - formData.append("voiceNote", audioFile); + // const formData = new FormData(); + // formData.append("voiceNote", audioFile); const reqData = { title: data.title, description: data.description, - agendaType: calendarProps, + agendaType: agendaType, startDate: format(startDate, "yyyy-MM-dd"), endDate: format(endDate, "yyyy-MM-dd"), - voiceNote: formData, }; console.log("Submitted Data:", reqData); @@ -150,20 +175,70 @@ const EventModal = ({ return false; } - Cookies.set("AgendaSetting", response?.data?.data.id, { - expires: 1, + const id = response?.data?.data.id; + + if (imageFiles?.length == 0) { + setIsImageUploadFinish(true); + } + imageFiles?.map(async (item: any, index: number) => { + await uploadResumableFile( + index, + String(id), + item, + "1", + "0" + ); + }); + + if (videoFiles?.length == 0) { + setIsVideoUploadFinish(true); + } + videoFiles?.map(async (item: any, index: number) => { + await uploadResumableFile( + index, + String(id), + item, + "2", + "0" + ); + }); + + if (textFiles?.length == 0) { + setIsTextUploadFinish(true); + } + textFiles?.map(async (item: any, index: number) => { + await uploadResumableFile( + index, + String(id), + item, + "3", + "0" + ); + }); + + if (audioFiles?.length == 0) { + setIsAudioUploadFinish(true); + } + audioFiles?.map(async (item: any, index: number) => { + await uploadResumableFile( + index, + String(id), + item, + "4", + "0" + ); }); // Optional: Use Swal for success feedback - MySwal.fire({ - title: "Sukses", - text: "Data berhasil disimpan.", - icon: "success", - confirmButtonColor: "#3085d6", - confirmButtonText: "OK", - }).then(() => { - router.push("en/contributor/agenda-setting"); - }); + // MySwal.fire({ + // title: "Sukses", + // text: "Data berhasil disimpan.", + // icon: "success", + // confirmButtonColor: "#3085d6", + // confirmButtonText: "OK", + // }).then(() => { + // router.push("en/contributor/agenda-setting"); + // }); }; const onSubmit = (data: any) => { @@ -179,7 +254,7 @@ const EventModal = ({ setStartDate(event?.event?.start); setEndDate(event?.event?.end); const eventCalendar = event?.event?.extendedProps?.calendar; - setCalendarProps(eventCalendar || categories[0].value); + setAgendaType(eventCalendar || categories[0].value); } setValue("title", event?.event?.title || ""); setValue("description", event?.event?.description || ""); @@ -197,6 +272,7 @@ const EventModal = ({ }; const toggleExpand = (poldaId: any) => { + console.log("Toogle : ", expandedPolda); setExpandedPolda((prev: any) => ({ ...prev, [poldaId]: !prev[poldaId], @@ -248,6 +324,89 @@ const EventModal = ({ audioElements.forEach((audio) => audio.remove()); }; + async function uploadResumableFile( + idx: number, + id: string, + file: any, + fileTypeId: string, + duration: string + ) { + console.log(idx, id, file, fileTypeId, duration); + + // const placements = getPlacement(file.placements); + // console.log("Placementttt: : ", placements); + + const upload = new Upload(file, { + endpoint: `${process.env.NEXT_PUBLIC_API}/agenda-settings/file/upload`, + retryDelays: [0, 3000, 6000, 12_000, 24_000], + chunkSize: 20_000, + metadata: { + agendaSettingId: id, + filename: file.name, + filetype: file.type, + fileTypeId: fileTypeId, + duration: "", + isWatermark: "true", // hardcode + }, + onError: async (e: any) => { + console.log("Error upload :", e); + error(e); + }, + onChunkComplete: ( + chunkSize: any, + bytesAccepted: any, + bytesTotal: any + ) => { + const uploadPersen = Math.floor((bytesAccepted / bytesTotal) * 100); + // progressInfo[idx].percentage = uploadPersen; + // counterUpdateProgress++; + // console.log(counterUpdateProgress); + // setProgressList(progressInfo); + // setCounterProgress(counterUpdateProgress); + }, + onSuccess: async () => { + // uploadPersen = 100; + // progressInfo[idx].percentage = 100; + // counterUpdateProgress++; + // setCounterProgress(counterUpdateProgress); + successTodo(); + if (fileTypeId == '1'){ + setIsImageUploadFinish(true); + } else if (fileTypeId == '2'){ + setIsVideoUploadFinish(true); + } if (fileTypeId == '3'){ + setIsTextUploadFinish(true); + } if (fileTypeId == '4'){ + setIsAudioUploadFinish(true); + } + }, + }); + + upload.start(); + } + + useEffect(() => { + successTodo(); + }, [isImageUploadFinish, isVideoUploadFinish, isAudioUploadFinish, isTextUploadFinish]) + + function successTodo() { + if (isImageUploadFinish && isVideoUploadFinish && isAudioUploadFinish && isTextUploadFinish) { + successSubmit("/in/contributor/agenda-setting"); + } + } + + const successSubmit = (redirect: string) => { + MySwal.fire({ + title: "Sukses", + text: "Data berhasil disimpan.", + icon: "success", + confirmButtonColor: "#3085d6", + confirmButtonText: "OK", + }).then(() => { + router.push(redirect); + }); + }; + return ( <> - {event ? "Edit Agenda Setting" : "Create Agenda Setting"}{" "} + {event?.length > 1 ? "Edit Agenda Setting" : "Create Agenda Setting"}{" "} {event?.title} @@ -366,14 +525,14 @@ const EventModal = ({
- + ( setImageFiles(files)} />
- setImageFiles(files)} />
- setTextFiles(files)} />
@@ -542,6 +708,16 @@ const EventModal = ({ downloadOnSavePress={true} downloadFileExtension="webm" /> + setAudioFiles(files)} + className="mt-2" + />
{audioFile && (
@@ -568,15 +744,15 @@ const EventModal = ({ {isPending ? ( <> - {event ? "Updating..." : "Adding..."} + {event?.length > 1 ? "Updating..." : "Adding..."} - ) : event ? ( + ) : event?.length > 1 ? ( "Update Agenda Setting" ) : ( "Simpan Agenda Setting" )} - {event && ( + {event?.length > 1 && ( -
+ + {status} {/* Tetap tampilkan nilai asli */} + ); }, }, @@ -139,12 +147,18 @@ const columns: ColumnDef[] = [ - + View - + + + + + Edit + + Delete diff --git a/app/[locale]/(protected)/contributor/content/audio/detail/[id]/page.tsx b/app/[locale]/(protected)/contributor/content/audio/detail/[id]/page.tsx new file mode 100644 index 00000000..c3d08051 --- /dev/null +++ b/app/[locale]/(protected)/contributor/content/audio/detail/[id]/page.tsx @@ -0,0 +1,16 @@ +import SiteBreadcrumb from "@/components/site-breadcrumb"; +import FormImageDetail from "@/components/form/content/image-detail-form"; +import FormAudioDetail from "@/components/form/content/audio-detail-form"; + +const AudioDetailPage = async () => { + return ( +
+ +
+ +
+
+ ); +}; + +export default AudioDetailPage; diff --git a/app/[locale]/(protected)/contributor/content/audio/update/[id]/page.tsx b/app/[locale]/(protected)/contributor/content/audio/update/[id]/page.tsx new file mode 100644 index 00000000..c0690cb7 --- /dev/null +++ b/app/[locale]/(protected)/contributor/content/audio/update/[id]/page.tsx @@ -0,0 +1,17 @@ +import SiteBreadcrumb from "@/components/site-breadcrumb"; +import FormImageDetail from "@/components/form/content/image-detail-form"; +import FormImageUpdate from "@/components/form/content/image-update-form"; +import FormAudioUpdate from "@/components/form/content/audio-update-form"; + +const AudioUpdatePage = async () => { + return ( +
+ +
+ +
+
+ ); +}; + +export default AudioUpdatePage; diff --git a/app/[locale]/(protected)/contributor/content/image/components/columns.tsx b/app/[locale]/(protected)/contributor/content/image/components/columns.tsx index d6b0328c..1eb9a3df 100644 --- a/app/[locale]/(protected)/contributor/content/image/components/columns.tsx +++ b/app/[locale]/(protected)/contributor/content/image/components/columns.tsx @@ -100,7 +100,6 @@ const columns: ColumnDef[] = [ ); }, }, - { accessorKey: "statusName", header: "Status", @@ -109,12 +108,8 @@ const columns: ColumnDef[] = [ diterima: "bg-green-100 text-green-600", "menunggu review": "bg-orange-100 text-orange-600", }; - - // Mengambil `statusName` dari data API const status = row.getValue("statusName") as string; - const statusName = status?.toLocaleLowerCase(); // Ubah ke huruf kecil - - // Gunakan `statusName` untuk pencocokan + const statusName = status?.toLocaleLowerCase(); const statusStyles = statusColors[statusName] || "bg-gray-100 text-gray-600"; @@ -125,7 +120,7 @@ const columns: ColumnDef[] = [ statusStyles )} > - {status} {/* Tetap tampilkan nilai asli */} + {status} ); }, diff --git a/app/[locale]/(protected)/contributor/content/teks/components/columns.tsx b/app/[locale]/(protected)/contributor/content/teks/components/columns.tsx index 3e3af62b..bb3cfc77 100644 --- a/app/[locale]/(protected)/contributor/content/teks/components/columns.tsx +++ b/app/[locale]/(protected)/contributor/content/teks/components/columns.tsx @@ -102,23 +102,31 @@ const columns: ColumnDef[] = [ }, { - accessorKey: "isDone", + accessorKey: "statusName", header: "Status", cell: ({ row }) => { - const isDone = row.getValue("isDone"); + const statusColors: Record = { + diterima: "bg-green-100 text-green-600", + "menunggu review": "bg-orange-100 text-orange-600", + }; + + // Mengambil `statusName` dari data API + const status = row.getValue("statusName") as string; + const statusName = status?.toLocaleLowerCase(); // Ubah ke huruf kecil + + // Gunakan `statusName` untuk pencocokan + const statusStyles = + statusColors[statusName] || "bg-gray-100 text-gray-600"; + return ( -
- -
+ + {status} {/* Tetap tampilkan nilai asli */} + ); }, }, diff --git a/app/[locale]/(protected)/contributor/content/video/components/columns.tsx b/app/[locale]/(protected)/contributor/content/video/components/columns.tsx index b58dd079..9a92144a 100644 --- a/app/[locale]/(protected)/contributor/content/video/components/columns.tsx +++ b/app/[locale]/(protected)/contributor/content/video/components/columns.tsx @@ -102,23 +102,31 @@ const columns: ColumnDef[] = [ }, { - accessorKey: "isDone", + accessorKey: "statusName", header: "Status", cell: ({ row }) => { - const isDone = row.getValue("isDone"); + const statusColors: Record = { + diterima: "bg-green-100 text-green-600", + "menunggu review": "bg-orange-100 text-orange-600", + }; + + // Mengambil `statusName` dari data API + const status = row.getValue("statusName") as string; + const statusName = status?.toLocaleLowerCase(); // Ubah ke huruf kecil + + // Gunakan `statusName` untuk pencocokan + const statusStyles = + statusColors[statusName] || "bg-gray-100 text-gray-600"; + return ( -
- -
+ + {status} {/* Tetap tampilkan nilai asli */} + ); }, }, diff --git a/app/[locale]/(protected)/contributor/planning/mediahub/components/columns.tsx b/app/[locale]/(protected)/contributor/planning/mediahub/components/columns.tsx index eb08dbd9..666d3856 100644 --- a/app/[locale]/(protected)/contributor/planning/mediahub/components/columns.tsx +++ b/app/[locale]/(protected)/contributor/planning/mediahub/components/columns.tsx @@ -66,7 +66,7 @@ const columns: ColumnDef[] = [ return (
{isActive ? ( - Terkirim + Terkirim ) : ( Belum Terkirim )} diff --git a/app/[locale]/(protected)/contributor/planning/medsos-mediahub/components/columns.tsx b/app/[locale]/(protected)/contributor/planning/medsos-mediahub/components/columns.tsx index f7820c16..5adee17a 100644 --- a/app/[locale]/(protected)/contributor/planning/medsos-mediahub/components/columns.tsx +++ b/app/[locale]/(protected)/contributor/planning/medsos-mediahub/components/columns.tsx @@ -66,7 +66,7 @@ const columns: ColumnDef[] = [ return (
{isActive ? ( - Terkirim + Terkirim ) : ( Belum Terkirim )} diff --git a/app/[locale]/(protected)/shared/contest/components/columns.tsx b/app/[locale]/(protected)/shared/contest/components/columns.tsx index ff85fdcb..505f5c4e 100644 --- a/app/[locale]/(protected)/shared/contest/components/columns.tsx +++ b/app/[locale]/(protected)/shared/contest/components/columns.tsx @@ -84,10 +84,17 @@ const columns: ColumnDef[] = [ accessorKey: "isPublishForAll", header: "Status", cell: ({ row }) => { + const isPublishForAll = row.getValue("isPublishForAll"); return ( - - {row.getValue("isPublishForAll")} - + + {isPublishForAll ? "Publish" : "Pending"} + ); }, }, diff --git a/app/[locale]/(public)/all/filter/page.tsx b/app/[locale]/(public)/all/filter/page.tsx index 9b1a7c0c..0651dabc 100644 --- a/app/[locale]/(public)/all/filter/page.tsx +++ b/app/[locale]/(public)/all/filter/page.tsx @@ -5,25 +5,8 @@ import { Checkbox } from "@/components/ui/checkbox"; import { Icon } from "@iconify/react/dist/iconify.js"; import { getOnlyDate, getOnlyMonthAndYear } from "@/utils/globals"; import { useParams, usePathname, useSearchParams } from "next/navigation"; -import { - getUserLevelListByParent, - listCategory, - listData, - listDataAll, - listDataRegional, -} from "@/service/landing/landing"; -import { - ColumnDef, - ColumnFiltersState, - PaginationState, - SortingState, - VisibilityState, - getCoreRowModel, - getFilteredRowModel, - getPaginationRowModel, - getSortedRowModel, - useReactTable, -} from "@tanstack/react-table"; +import { getUserLevelListByParent, listCategory, listData, listDataAll, listDataRegional } from "@/service/landing/landing"; +import { ColumnDef, ColumnFiltersState, PaginationState, SortingState, VisibilityState, getCoreRowModel, getFilteredRowModel, getPaginationRowModel, getSortedRowModel, useReactTable } from "@tanstack/react-table"; import { Reveal } from "@/components/landing-page/Reveal"; import { Link, useRouter } from "@/i18n/routing"; import { Input } from "@/components/ui/input"; @@ -45,11 +28,8 @@ export default function FilterPage() { const [totalData, setTotalData] = React.useState(1); const [totalPage, setTotalPage] = React.useState(1); const [sorting, setSorting] = React.useState([]); - const [columnFilters, setColumnFilters] = React.useState( - [] - ); - const [columnVisibility, setColumnVisibility] = - React.useState({}); + const [columnFilters, setColumnFilters] = React.useState([]); + const [columnVisibility, setColumnVisibility] = React.useState({}); const [rowSelection, setRowSelection] = React.useState({}); const [pagination, setPagination] = React.useState({ pageIndex: 0, @@ -71,9 +51,7 @@ export default function FilterPage() { const [categoryFilter, setCategoryFilter] = useState([]); const [monthYearFilter, setMonthYearFilter] = useState(); const [searchTitle, setSearchTitle] = useState(""); - const [sortByOpt, setSortByOpt] = useState( - sortBy === "popular" ? "clickCount" : "createdAt" - ); + const [sortByOpt, setSortByOpt] = useState(sortBy === "popular" ? "clickCount" : "createdAt"); const isRegional = asPath?.includes("regional"); const isSatker = asPath?.includes("satker"); const [formatFilter, setFormatFilter] = useState([]); @@ -110,14 +88,8 @@ export default function FilterPage() { useEffect(() => { if (categorie) { - setCategoryFilter( - categorie?.split("&")?.length > 1 ? categorie?.split("&") : [categorie] - ); - console.log( - "Kategori", - categorie, - categorie?.split("&")?.length > 1 ? categorie?.split("&") : [categorie] - ); + setCategoryFilter(categorie?.split("&")?.length > 1 ? categorie?.split("&") : [categorie]); + console.log("Kategori", categorie, categorie?.split("&")?.length > 1 ? categorie?.split("&") : [categorie]); } }, [categorie]); @@ -135,17 +107,7 @@ export default function FilterPage() { } console.log(monthYearFilter, "monthFilter"); initState(); - }, [ - change, - monthYearFilter, - sortBy, - sortByOpt, - title, - startDateString, - endDateString, - categorie, - formatFilter, - ]); + }, [change, monthYearFilter, sortBy, sortByOpt, title, startDateString, endDateString, categorie, formatFilter]); async function getCategories() { const category = await listCategory("1"); @@ -168,10 +130,7 @@ export default function FilterPage() { async function getData() { if (asPath?.includes("/polda/") == true) { if (asPath?.split("/")[2] !== "[polda_name]") { - const filter = - categoryFilter?.length > 0 - ? categoryFilter?.sort().join(",") - : categorie || ""; + const filter = categoryFilter?.length > 0 ? categoryFilter?.sort().join(",") : categorie || ""; const name = title == undefined ? "" : title; const format = formatFilter == undefined ? "" : formatFilter?.join(","); @@ -186,14 +145,8 @@ export default function FilterPage() { filterGroup, startDateString, endDateString, - monthYearFilter - ? getOnlyMonthAndYear(monthYearFilter) - ?.split("/")[0] - ?.replace("0", "") - : "", - monthYearFilter - ? getOnlyMonthAndYear(monthYearFilter)?.split("/")[1] - : "" + monthYearFilter ? getOnlyMonthAndYear(monthYearFilter)?.split("/")[0]?.replace("0", "") : "", + monthYearFilter ? getOnlyMonthAndYear(monthYearFilter)?.split("/")[1] : "" ); close(); // setGetTotalPage(response?.data?.data?.totalPages); @@ -208,10 +161,7 @@ export default function FilterPage() { setTotalContent(response?.data?.data?.totalElements); } } else { - const filter = - categoryFilter?.length > 0 - ? categoryFilter?.sort().join(",") - : categorie || ""; + const filter = categoryFilter?.length > 0 ? categoryFilter?.sort().join(",") : categorie || ""; const name = title == undefined ? "" : title; const format = formatFilter == undefined ? "" : formatFilter?.join(","); @@ -225,14 +175,8 @@ export default function FilterPage() { tag, startDateString, endDateString, - monthYearFilter - ? getOnlyMonthAndYear(monthYearFilter) - ?.split("/")[0] - ?.replace("0", "") - : "", - monthYearFilter - ? getOnlyMonthAndYear(monthYearFilter)?.split("/")[1] - : "" + monthYearFilter ? getOnlyMonthAndYear(monthYearFilter)?.split("/")[0]?.replace("0", "") : "", + monthYearFilter ? getOnlyMonthAndYear(monthYearFilter)?.split("/")[1] : "" ); close(); // setGetTotalPage(response?.data?.data?.totalPages); @@ -283,10 +227,7 @@ export default function FilterPage() { }; async function getDataRegional() { - const filter = - categoryFilter?.length > 0 - ? categoryFilter?.sort().join(",") - : categorie || ""; + const filter = categoryFilter?.length > 0 ? categoryFilter?.sort().join(",") : categorie || ""; const name = title == undefined ? "" : title; const format = formatFilter == undefined ? "" : formatFilter?.join(","); @@ -299,12 +240,8 @@ export default function FilterPage() { "", startDateString, endDateString, - monthYearFilter - ? getOnlyMonthAndYear(monthYearFilter)?.split("/")[0]?.replace("", "") - : "", - monthYearFilter - ? getOnlyMonthAndYear(monthYearFilter)?.split("/")[1] - : "", + monthYearFilter ? getOnlyMonthAndYear(monthYearFilter)?.split("/")[0]?.replace("", "") : "", + monthYearFilter ? getOnlyMonthAndYear(monthYearFilter)?.split("/")[1] : "", 12, pages, sortByOpt @@ -410,10 +347,7 @@ export default function FilterPage() {
-
+
{/* Comment */}
diff --git a/app/[locale]/(public)/document/filter/page.tsx b/app/[locale]/(public)/document/filter/page.tsx index 974b5598..edd10c88 100644 --- a/app/[locale]/(public)/document/filter/page.tsx +++ b/app/[locale]/(public)/document/filter/page.tsx @@ -14,6 +14,7 @@ import { Input } from "@/components/ui/input"; import ReactDatePicker from "react-datepicker"; import "react-datepicker/dist/react-datepicker.css"; import { close, loading } from "@/config/swal"; +import { useTranslations } from "next-intl"; const columns: ColumnDef[] = [ { @@ -48,6 +49,7 @@ const FilterPage = () => { const categorie = searchParams?.get("category"); const group = searchParams?.get("group"); const [, setGetTotalPage] = useState(); + const t = useTranslations("FilterPage"); let typingTimer: any; const doneTypingInterval = 1500; const [contentDocument, setContentDocument] = useState([]); @@ -371,15 +373,15 @@ const FilterPage = () => {

{" "} - Teks {">"} Semua Teks + {t("text")} {">"} {t("allText")}

|

-

{`Terdapat ${totalContent} artikel berisi Teks yang dapat diunduh`}

+

{`${t("thereIs")} ${totalContent} ${t("downloadableText")}`}

{/* Left */}
-
+

Filter @@ -388,7 +390,7 @@ const FilterPage = () => {
{ onKeyDown={handleKeyDown} type="text" id="search" - placeholder="Cari judul..." + placeholder={t("searchTitle")} className="mt-1 w-full border rounded-md py-2 px-3 focus:ring-red-500 focus:border-red-500" />
- + setMonthYearFilter(date)} dateFormat="MM | yyyy" - placeholderText="Pilih Tahun dan Bulan" + placeholderText={t("selectYear")} showMonthYearPicker />
- +
{ setDateRange(update); }} - placeholderText="Pilih Tanggal" + placeholderText={t("selectDate")} onCalendarClose={() => setCalenderState(!calenderState)} />
{handleClose ? : ""}
@@ -433,7 +435,7 @@ const FilterPage = () => {
-

Kategori

+

{t("categories")}

    {categories.map((category: any) => (
  • @@ -449,7 +451,7 @@ const FilterPage = () => {
    {/* Garis */}
    -

    Format Teks

    +

    Format