diff --git a/app/[locale]/(protected)/dashboard/routine-task/components/columns.tsx b/app/[locale]/(protected)/dashboard/routine-task/components/columns.tsx index 4ccafa03..1089a6ba 100644 --- a/app/[locale]/(protected)/dashboard/routine-task/components/columns.tsx +++ b/app/[locale]/(protected)/dashboard/routine-task/components/columns.tsx @@ -168,39 +168,61 @@ const columns: ColumnDef[] = [ ); }, }, - { - id: "actions", - accessorKey: "action", - header: "Actions", - enableHiding: false, - cell: ({ row }) => { - return ( - - - - - - - - - View - - - - - Delete + { + id: "actions", + accessorKey: "action", + header: "Actions", + enableHiding: false, + cell: ({ row }) => { + // Menentukan segmen path berdasarkan fileTypeId + let fileTypeSegment; + switch (row.original.fileTypeId) { + case 1: + fileTypeSegment = "image"; + break; + case 2: + fileTypeSegment = "video"; + break; + case 3: + fileTypeSegment = "teks"; // Asumsi 'teks' untuk fileTypeId 3 + break; + case 4: + fileTypeSegment = "audio"; // Asumsi 'audio' untuk fileTypeId 4 + break; + default: + fileTypeSegment = row.original.fileTypeId; // Fallback jika tidak ada yang cocok + } + + return ( + + + + + + {/* Link "View" yang diperbarui dengan logika kondisional untuk fileTypeSegment */} + + + + Lihat - - - ); - }, + + + + Hapus + + + + ); }, +}, ]; export default columns; diff --git a/app/[locale]/(public)/(polda)/polda/[polda_name]/audio/filter/page.tsx b/app/[locale]/(public)/(polda)/polda/[polda_name]/audio/filter/page.tsx index 54f2f868..5b3f5fb1 100644 --- a/app/[locale]/(public)/(polda)/polda/[polda_name]/audio/filter/page.tsx +++ b/app/[locale]/(public)/(polda)/polda/[polda_name]/audio/filter/page.tsx @@ -11,6 +11,7 @@ import { } from "@/utils/globals"; import { useParams, usePathname, useSearchParams } from "next/navigation"; import { + getPublicCategoryData, getUserLevelListByParent, listCategory, listData, @@ -53,7 +54,7 @@ const columns: ColumnDef[] = [ }, ]; -const FilterPage = () => { +const FilterPage = (props: { group?: string; type: string }) => { const router = useRouter(); const asPath = usePathname(); const params = useParams(); @@ -105,6 +106,7 @@ const FilterPage = () => { const poldaName = params?.polda_name; let prefixPath = poldaName ? `/polda/${poldaName}` : "/"; const t = useTranslations("FilterPage"); + const satkerName = params?.satker_name; const [isLoading, setIsLoading] = useState(true); @@ -126,7 +128,7 @@ const FilterPage = () => { useEffect(() => { async function initState() { - getCategories(); + // getCategories(); // getSelectedCategory(); if (isSatker) { getUserLevels(); @@ -177,11 +179,32 @@ const FilterPage = () => { formatFilter, ]); - async function getCategories() { - const category = await listCategory("4"); - const resCategory = category?.data?.data?.content; - setCategories(resCategory); - } + // async function getCategories() { + // const category = await listCategory("4"); + // const resCategory = category?.data?.data?.content; + // setCategories(resCategory); + // } + + useEffect(() => { + initFetch(); + }, []); + const initFetch = async () => { + const response = await getPublicCategoryData( + props.group == "mabes" + ? "" + : props.group == "polda" && poldaName && String(poldaName)?.length > 1 + ? poldaName + : props.group == "satker" && + satkerName && + String(satkerName)?.length > 1 + ? "satker-" + satkerName + : "", + "", + locale == "en" ? true : false + ); + console.log("category", response); + setCategories(response?.data?.data?.content); + }; useEffect(() => { function initState() { diff --git a/app/[locale]/(public)/(polda)/polda/[polda_name]/document/filter/page.tsx b/app/[locale]/(public)/(polda)/polda/[polda_name]/document/filter/page.tsx index 20c37b97..46b6b609 100644 --- a/app/[locale]/(public)/(polda)/polda/[polda_name]/document/filter/page.tsx +++ b/app/[locale]/(public)/(polda)/polda/[polda_name]/document/filter/page.tsx @@ -11,6 +11,7 @@ import { import { useParams, usePathname, useSearchParams } from "next/navigation"; import { getListContent, + getPublicCategoryData, getUserLevelListByParent, listCategory, listData, @@ -46,7 +47,7 @@ const columns: ColumnDef[] = [ }, ]; -const FilterPage = () => { +const FilterPage = (props: { group?: string; type: string }) => { const router = useRouter(); const asPath = usePathname(); const params = useParams(); @@ -98,6 +99,7 @@ const FilterPage = () => { const poldaName = params?.polda_name; let prefixPath = poldaName ? `/polda/${poldaName}` : "/"; const [isLoading, setIsLoading] = useState(true); + const satkerName = params?.satker_name; // const [startDate, endDate] = dateRange; @@ -117,7 +119,7 @@ const FilterPage = () => { useEffect(() => { async function initState() { - getCategories(); + // getCategories(); // getSelectedCategory(); if (isSatker) { getUserLevels(); @@ -168,11 +170,32 @@ const FilterPage = () => { formatFilter, ]); - async function getCategories() { - const category = await listCategory("3"); - const resCategory = category?.data?.data?.content; - setCategories(resCategory); - } + // async function getCategories() { + // const category = await listCategory("3"); + // const resCategory = category?.data?.data?.content; + // setCategories(resCategory); + // } + + useEffect(() => { + initFetch(); + }, []); + const initFetch = async () => { + const response = await getPublicCategoryData( + props.group == "mabes" + ? "" + : props.group == "polda" && poldaName && String(poldaName)?.length > 1 + ? poldaName + : props.group == "satker" && + satkerName && + String(satkerName)?.length > 1 + ? "satker-" + satkerName + : "", + "", + locale == "en" ? true : false + ); + console.log("category", response); + setCategories(response?.data?.data?.content); + }; useEffect(() => { function initState() { @@ -357,9 +380,9 @@ const FilterPage = () => { }); useEffect(() => { - initFetch(); + fetchContent(); }, [page]); - const initFetch = async () => { + const fetchContent = async () => { const response = await getListContent({ page: page - 1, size: 6, diff --git a/app/[locale]/(public)/(polda)/polda/[polda_name]/image/filter/page.tsx b/app/[locale]/(public)/(polda)/polda/[polda_name]/image/filter/page.tsx index f702a5e1..0e373d3b 100644 --- a/app/[locale]/(public)/(polda)/polda/[polda_name]/image/filter/page.tsx +++ b/app/[locale]/(public)/(polda)/polda/[polda_name]/image/filter/page.tsx @@ -10,6 +10,7 @@ import { } from "@/utils/globals"; import { useParams, usePathname, useSearchParams } from "next/navigation"; import { + getPublicCategoryData, getUserLevelListByParent, listCategory, listData, @@ -47,7 +48,7 @@ const columns: ColumnDef[] = [ }, ]; -const FilterPage = () => { +const FilterPage = (props: { group?: string; type: string }) => { const router = useRouter(); const asPath = usePathname(); const params = useParams(); @@ -99,6 +100,7 @@ const FilterPage = () => { const [categories, setCategories] = useState([]); const [userLevels, setUserLevels] = useState([]); const poldaName = params?.polda_name; + const satkerName = params?.satker_name; let prefixPath = poldaName ? `/polda/${poldaName}` : "/"; const [isLoading, setIsLoading] = useState(true); @@ -123,7 +125,7 @@ const FilterPage = () => { useEffect(() => { async function initState() { - getCategories(); + // getCategories(); // getSelectedCategory(); if (isSatker) { getUserLevels(); @@ -174,11 +176,32 @@ const FilterPage = () => { formatFilter, ]); - async function getCategories() { - const category = await listCategory("1"); - const resCategory = category?.data?.data?.content; - setCategories(resCategory); - } + // async function getCategories() { + // const category = await listCategory("1"); + // const resCategory = category?.data?.data?.content; + // setCategories(resCategory); + // } + + useEffect(() => { + initFetch(); + }, []); + const initFetch = async () => { + const response = await getPublicCategoryData( + props.group == "mabes" + ? "" + : props.group == "polda" && poldaName && String(poldaName)?.length > 1 + ? poldaName + : props.group == "satker" && + satkerName && + String(satkerName)?.length > 1 + ? "satker-" + satkerName + : "", + "", + locale == "en" ? true : false + ); + console.log("category", response); + setCategories(response?.data?.data?.content); + }; useEffect(() => { function initState() { diff --git a/app/[locale]/(public)/(polda)/polda/[polda_name]/video/filter/page.tsx b/app/[locale]/(public)/(polda)/polda/[polda_name]/video/filter/page.tsx index 38871b81..1a6f1c8f 100644 --- a/app/[locale]/(public)/(polda)/polda/[polda_name]/video/filter/page.tsx +++ b/app/[locale]/(public)/(polda)/polda/[polda_name]/video/filter/page.tsx @@ -11,6 +11,7 @@ import { import { useParams, usePathname, useSearchParams } from "next/navigation"; import { getListContent, + getPublicCategoryData, getUserLevelListByParent, listCategory, listData, @@ -48,7 +49,7 @@ const columns: ColumnDef[] = [ }, ]; -const FilterPage = () => { +const FilterPage = (props: { group?: string; type: string }) => { const router = useRouter(); const asPath = usePathname(); const params = useParams(); @@ -98,6 +99,7 @@ const FilterPage = () => { let prefixPath = poldaName ? `/polda/${poldaName}` : "/"; const t = useTranslations("FilterPage"); const [isLoading, setIsLoading] = useState(true); + const satkerName = params?.satker_name; // const [startDate, endDate] = dateRange; @@ -117,7 +119,7 @@ const FilterPage = () => { useEffect(() => { async function initState() { - getCategories(); + // getCategories(); // getSelectedCategory(); if (isSatker) { getUserLevels(); @@ -168,11 +170,32 @@ const FilterPage = () => { formatFilter, ]); - async function getCategories() { - const category = await listCategory("2"); - const resCategory = category?.data?.data?.content; - setCategories(resCategory); - } + // async function getCategories() { + // const category = await listCategory("2"); + // const resCategory = category?.data?.data?.content; + // setCategories(resCategory); + // } + + useEffect(() => { + initFetch(); + }, []); + const initFetch = async () => { + const response = await getPublicCategoryData( + props.group == "mabes" + ? "" + : props.group == "polda" && poldaName && String(poldaName)?.length > 1 + ? poldaName + : props.group == "satker" && + satkerName && + String(satkerName)?.length > 1 + ? "satker-" + satkerName + : "", + "", + locale == "en" ? true : false + ); + console.log("category", response); + setCategories(response?.data?.data?.content); + }; useEffect(() => { function initState() { @@ -351,9 +374,9 @@ const FilterPage = () => { }); useEffect(() => { - initFetch(); + fetchContent(); }, [page]); - const initFetch = async () => { + const fetchContent = async () => { const response = await getListContent({ page: page - 1, size: 6, @@ -693,9 +716,13 @@ const FilterPage = () => { >
router.push(prefixPath + `/video/detail/${video?.slug}`)} - > + // href={`/video/detail/${video?.slug}`} + onClick={() => + router.push( + prefixPath + `/video/detail/${video?.slug}` + ) + } + > {/* */}
[] = [ @@ -25,7 +52,7 @@ const columns: ColumnDef[] = [ }, ]; -const FilterPage = () => { +const FilterPage = (props: { group?: string; type: string }) => { const router = useRouter(); const asPath = usePathname(); const params = useParams(); @@ -35,8 +62,11 @@ const 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, @@ -57,7 +87,9 @@ const 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([]); @@ -69,6 +101,7 @@ const FilterPage = () => { const [handleClose, setHandleClose] = useState(false); const [categories, setCategories] = useState([]); const [userLevels, setUserLevels] = useState([]); + const poldaName = params?.polda_name; const satkerName = params?.satker_name; let prefixPath = satkerName ? `/satker/${satkerName}` : "/"; const t = useTranslations("FilterPage"); @@ -84,7 +117,7 @@ const FilterPage = () => { useEffect(() => { async function initState() { - getCategories(); + // getCategories(); // getSelectedCategory(); if (isSatker) { getUserLevels(); @@ -96,8 +129,14 @@ const 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]); @@ -115,13 +154,46 @@ const FilterPage = () => { } console.log(monthYearFilter, "monthFilter"); initState(); - }, [change, asPath, monthYearFilter, page, sortBy, sortByOpt, title, startDateString, endDateString, categorie, formatFilter]); + }, [ + change, + asPath, + monthYearFilter, + page, + sortBy, + sortByOpt, + title, + startDateString, + endDateString, + categorie, + formatFilter, + ]); - async function getCategories() { - const category = await listCategory("4"); - const resCategory = category?.data?.data?.content; - setCategories(resCategory); - } + // async function getCategories() { + // const category = await listCategory("4"); + // const resCategory = category?.data?.data?.content; + // setCategories(resCategory); + // } + + useEffect(() => { + initFetch(); + }, []); + const initFetch = async () => { + const response = await getPublicCategoryData( + props.group == "mabes" + ? "" + : props.group == "polda" && poldaName && String(poldaName)?.length > 1 + ? poldaName + : props.group == "satker" && + satkerName && + String(satkerName)?.length > 1 + ? "satker-" + satkerName + : "", + "", + locale == "en" ? true : false + ); + console.log("category", response); + setCategories(response?.data?.data?.content); + }; useEffect(() => { function initState() { @@ -137,7 +209,10 @@ const FilterPage = () => { async function getDataAll() { if (satkerName && String(satkerName)?.length > 1) { - 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(","); @@ -155,8 +230,12 @@ const FilterPage = () => { filterGroup, startDateString, endDateString, - monthYearFilter ? getOnlyMonthAndYear(monthYearFilter)?.split("/")[0]?.replace("", "") : "", - monthYearFilter ? getOnlyMonthAndYear(monthYearFilter)?.split("/")[1] : "" + monthYearFilter + ? getOnlyMonthAndYear(monthYearFilter)?.split("/")[0]?.replace("", "") + : "", + monthYearFilter + ? getOnlyMonthAndYear(monthYearFilter)?.split("/")[1] + : "" ); close(); const data = response?.data?.data; @@ -166,7 +245,10 @@ const FilterPage = () => { setTotalPage(data?.totalPages); 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(","); @@ -183,8 +265,12 @@ const 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] + : "" ); close(); const data = response?.data?.data; @@ -231,7 +317,10 @@ const 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(","); @@ -244,8 +333,12 @@ const 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 @@ -371,7 +464,10 @@ const FilterPage = () => {
-
- + {
- +
{ placeholderText={t("searchDate")} onCalendarClose={() => setCalenderState(!calenderState)} /> -
{handleClose ? : ""}
+
+ {handleClose ? ( + + ) : ( + "" + )} +
-

{t("categories")}

+

+ {t("categories")} +

    {categories.map((category: any) => (
  • -
  • ))} @@ -433,25 +559,48 @@ const FilterPage = () => {
    {/* Garis */}
    -

    Format

    +

    + Format +

    @@ -463,7 +612,11 @@ const FilterPage = () => {

    {t("sortBy")}

    - handleSorting(e)} + className="border rounded-md py-2 px-3 focus:ring-red-500 focus:border-red-500" + > @@ -475,11 +628,23 @@ const FilterPage = () => { {audioData?.map((audio: any) => ( - +
    - +
    - + {
    - {formatDateToIndonesian(new Date(audio?.createdAt))} {audio?.timezone ? audio?.timezone : "WIB"} | {audio?.clickCount}{" "} + {formatDateToIndonesian( + new Date(audio?.createdAt) + )}{" "} + {audio?.timezone ? audio?.timezone : "WIB"} |{" "} + {" "} + {audio?.clickCount}{" "} +
    +
    + {audio?.title}
    -
    {audio?.title}
    @@ -505,11 +681,19 @@ const FilterPage = () => {
    ) : (

    - empty + empty

    )} - +
    diff --git a/app/[locale]/(public)/(satker)/satker/[satker_name]/document/filter/page.tsx b/app/[locale]/(public)/(satker)/satker/[satker_name]/document/filter/page.tsx index 0c49f0c1..43c4df04 100644 --- a/app/[locale]/(public)/(satker)/satker/[satker_name]/document/filter/page.tsx +++ b/app/[locale]/(public)/(satker)/satker/[satker_name]/document/filter/page.tsx @@ -3,10 +3,32 @@ import React, { useEffect, useState } from "react"; import { Card, CardContent } from "@/components/ui/card"; import { Checkbox } from "@/components/ui/checkbox"; import { Icon } from "@iconify/react/dist/iconify.js"; -import { formatDateToIndonesian, getOnlyDate, getOnlyMonthAndYear } from "@/utils/globals"; +import { + formatDateToIndonesian, + getOnlyDate, + getOnlyMonthAndYear, +} from "@/utils/globals"; import { useParams, usePathname, useSearchParams } from "next/navigation"; -import { getListContent, getUserLevelListByParent, listCategory, listData, listDataRegional } from "@/service/landing/landing"; -import { ColumnDef, ColumnFiltersState, PaginationState, SortingState, VisibilityState, getCoreRowModel, getFilteredRowModel, getPaginationRowModel, getSortedRowModel, useReactTable } from "@tanstack/react-table"; +import { + getListContent, + getPublicCategoryData, + getUserLevelListByParent, + listCategory, + listData, + listDataRegional, +} from "@/service/landing/landing"; +import { + ColumnDef, + ColumnFiltersState, + PaginationState, + SortingState, + VisibilityState, + getCoreRowModel, + getFilteredRowModel, + getPaginationRowModel, + getSortedRowModel, + useReactTable, +} from "@tanstack/react-table"; import LandingPagination from "@/components/landing-page/pagination"; import { Reveal } from "@/components/landing-page/Reveal"; import { Link, useRouter } from "@/i18n/routing"; @@ -24,7 +46,7 @@ const columns: ColumnDef[] = [ }, ]; -const FilterPage = () => { +const FilterPage = (props: { group?: string; type: string }) => { const router = useRouter(); const asPath = usePathname(); const params = useParams(); @@ -34,8 +56,11 @@ const 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, @@ -56,7 +81,9 @@ const 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([]); @@ -68,6 +95,7 @@ const FilterPage = () => { const [handleClose, setHandleClose] = useState(false); const [categories, setCategories] = useState([]); const [userLevels, setUserLevels] = useState([]); + const poldaName = params?.polda_name; const satkerName = params?.satker_name; let prefixPath = satkerName ? `/satker/${satkerName}` : "/"; @@ -82,7 +110,7 @@ const FilterPage = () => { useEffect(() => { async function initState() { - getCategories(); + // getCategories(); // getSelectedCategory(); if (isSatker) { getUserLevels(); @@ -94,8 +122,14 @@ const 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]); @@ -113,13 +147,46 @@ const FilterPage = () => { } console.log(monthYearFilter, "monthFilter"); initState(); - }, [change, asPath, monthYearFilter, page, sortBy, sortByOpt, title, startDateString, endDateString, categorie, formatFilter]); + }, [ + change, + asPath, + monthYearFilter, + page, + sortBy, + sortByOpt, + title, + startDateString, + endDateString, + categorie, + formatFilter, + ]); - async function getCategories() { - const category = await listCategory("3"); - const resCategory = category?.data?.data?.content; - setCategories(resCategory); - } + // async function getCategories() { + // const category = await listCategory("3"); + // const resCategory = category?.data?.data?.content; + // setCategories(resCategory); + // } + + useEffect(() => { + fetchContent(); + }, []); + const fetchContent = async () => { + const response = await getPublicCategoryData( + props.group == "mabes" + ? "" + : props.group == "polda" && poldaName && String(poldaName)?.length > 1 + ? poldaName + : props.group == "satker" && + satkerName && + String(satkerName)?.length > 1 + ? "satker-" + satkerName + : "", + "", + locale == "en" ? true : false + ); + console.log("category", response); + setCategories(response?.data?.data?.content); + }; useEffect(() => { function initState() { @@ -135,7 +202,10 @@ const FilterPage = () => { async function getDataAll() { if (satkerName && String(satkerName)?.length > 1) { - 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(","); @@ -153,8 +223,12 @@ const FilterPage = () => { filterGroup, startDateString, endDateString, - monthYearFilter ? getOnlyMonthAndYear(monthYearFilter)?.split("/")[0]?.replace("", "") : "", - monthYearFilter ? getOnlyMonthAndYear(monthYearFilter)?.split("/")[1] : "" + monthYearFilter + ? getOnlyMonthAndYear(monthYearFilter)?.split("/")[0]?.replace("", "") + : "", + monthYearFilter + ? getOnlyMonthAndYear(monthYearFilter)?.split("/")[1] + : "" ); close(); // setGetTotalPage(response?.data?.data?.totalPages); @@ -167,7 +241,10 @@ const FilterPage = () => { setTotalPage(data?.totalPages); 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(","); @@ -184,8 +261,12 @@ const 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] + : "" ); close(); // setGetTotalPage(response?.data?.data?.totalPages); @@ -235,7 +316,10 @@ const 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(","); @@ -248,8 +332,12 @@ const 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 @@ -286,7 +374,12 @@ const FilterPage = () => { initFetch(); }, [page]); const initFetch = async () => { - const response = await getListContent({ page: page - 1, size: 6, sortBy: "createdAt", contentTypeId: "3" }); + const response = await getListContent({ + page: page - 1, + size: 6, + sortBy: "createdAt", + contentTypeId: "3", + }); console.log(response); setDocumentData(response?.data?.data?.content); const data = response?.data?.data; @@ -389,7 +482,10 @@ const FilterPage = () => {
    -
    - + {
    - +
    { placeholderText={t("selectDate")} onCalendarClose={() => setCalenderState(!calenderState)} /> -
    {handleClose ? : ""}
    +
    + {handleClose ? ( + + ) : ( + "" + )} +
    -

    {t("categories")}

    +

    + {t("categories")} +

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

      Format

      +

      + Format +

      @@ -499,7 +675,11 @@ const FilterPage = () => {

      {t("sortBy")}

      - handleSorting(e)} + className="border rounded-md py-2 px-3 focus:ring-red-500 focus:border-red-500" + > @@ -508,9 +688,19 @@ const FilterPage = () => { {documentData?.length > 0 ? (
      {documentData?.map((document: any) => ( - +
      - + {
      - {formatDateToIndonesian(new Date(document?.createdAt))} {document?.timezone ? document?.timezone : "WIB"} | 518 + {formatDateToIndonesian(new Date(document?.createdAt))}{" "} + {document?.timezone ? document?.timezone : "WIB"} |{" "} + 518 +
      +
      + {document?.title}
      -
      {document?.title}
      - - + + Download Dokumen
      @@ -534,11 +736,19 @@ const FilterPage = () => {
      ) : (

      - empty + empty

      )} - +
      diff --git a/app/[locale]/(public)/(satker)/satker/[satker_name]/image/filter/page.tsx b/app/[locale]/(public)/(satker)/satker/[satker_name]/image/filter/page.tsx index 454fb32b..b7f0e3a4 100644 --- a/app/[locale]/(public)/(satker)/satker/[satker_name]/image/filter/page.tsx +++ b/app/[locale]/(public)/(satker)/satker/[satker_name]/image/filter/page.tsx @@ -10,6 +10,7 @@ import { } from "@/utils/globals"; import { useParams, usePathname, useSearchParams } from "next/navigation"; import { + getPublicCategoryData, getUserLevelListByParent, listCategory, listData, @@ -44,7 +45,7 @@ const columns: ColumnDef[] = [ }, ]; -const FilterPage = () => { +const FilterPage = (props: { group?: string; type: string }) => { const router = useRouter(); const asPath = usePathname(); const params = useParams(); @@ -95,9 +96,9 @@ const FilterPage = () => { const [handleClose, setHandleClose] = useState(false); const [categories, setCategories] = useState([]); const [userLevels, setUserLevels] = useState([]); + const poldaName = params?.polda_name; const satkerName = params?.satker_name; let prefixPath = satkerName ? `/satker/${satkerName}` : "/"; - const t = useTranslations("FilterPage"); // const [startDate, endDate] = dateRange; @@ -111,7 +112,7 @@ const FilterPage = () => { useEffect(() => { async function initState() { - getCategories(); + // getCategories(); // getSelectedCategory(); if (isSatker) { getUserLevels(); @@ -162,11 +163,32 @@ const FilterPage = () => { formatFilter, ]); - async function getCategories() { - const category = await listCategory("1"); - const resCategory = category?.data?.data?.content; - setCategories(resCategory); - } + // async function getCategories() { + // const category = await listCategory("1"); + // const resCategory = category?.data?.data?.content; + // setCategories(resCategory); + // } + + useEffect(() => { + initFetch(); + }, []); + const initFetch = async () => { + const response = await getPublicCategoryData( + props.group == "mabes" + ? "" + : props.group == "polda" && poldaName && String(poldaName)?.length > 1 + ? poldaName + : props.group == "satker" && + satkerName && + String(satkerName)?.length > 1 + ? "satker-" + satkerName + : "", + "", + locale == "en" ? true : false + ); + console.log("category", response); + setCategories(response?.data?.data?.content); + }; useEffect(() => { function initState() { diff --git a/app/[locale]/(public)/(satker)/satker/[satker_name]/video/filter/page.tsx b/app/[locale]/(public)/(satker)/satker/[satker_name]/video/filter/page.tsx index 30fdbcd9..ce697cda 100644 --- a/app/[locale]/(public)/(satker)/satker/[satker_name]/video/filter/page.tsx +++ b/app/[locale]/(public)/(satker)/satker/[satker_name]/video/filter/page.tsx @@ -3,10 +3,32 @@ import React, { useEffect, useState } from "react"; import { Card, CardContent } from "@/components/ui/card"; import { Checkbox } from "@/components/ui/checkbox"; import { Icon } from "@iconify/react/dist/iconify.js"; -import { formatDateToIndonesian, getOnlyDate, getOnlyMonthAndYear } from "@/utils/globals"; +import { + formatDateToIndonesian, + getOnlyDate, + getOnlyMonthAndYear, +} from "@/utils/globals"; import { useParams, usePathname, useSearchParams } from "next/navigation"; -import { getListContent, getUserLevelListByParent, listCategory, listData, listDataRegional } from "@/service/landing/landing"; -import { ColumnDef, ColumnFiltersState, PaginationState, SortingState, VisibilityState, getCoreRowModel, getFilteredRowModel, getPaginationRowModel, getSortedRowModel, useReactTable } from "@tanstack/react-table"; +import { + getListContent, + getPublicCategoryData, + getUserLevelListByParent, + listCategory, + listData, + listDataRegional, +} from "@/service/landing/landing"; +import { + ColumnDef, + ColumnFiltersState, + PaginationState, + SortingState, + VisibilityState, + getCoreRowModel, + getFilteredRowModel, + getPaginationRowModel, + getSortedRowModel, + useReactTable, +} from "@tanstack/react-table"; import LandingPagination from "@/components/landing-page/pagination"; import { Reveal } from "@/components/landing-page/Reveal"; import { Link, useRouter } from "@/i18n/routing"; @@ -24,7 +46,7 @@ const columns: ColumnDef[] = [ }, ]; -const FilterPage = () => { +const FilterPage = (props: { group?: string; type: string }) => { const router = useRouter(); const asPath = usePathname(); const params = useParams(); @@ -34,8 +56,11 @@ const 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, @@ -53,7 +78,9 @@ const 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([]); @@ -65,6 +92,7 @@ const FilterPage = () => { const [handleClose, setHandleClose] = useState(false); const [categories, setCategories] = useState([]); const [userLevels, setUserLevels] = useState([]); + const poldaName = params?.polda_name; const satkerName = params?.satker_name; let prefixPath = satkerName ? `/satker/${satkerName}` : "/"; const t = useTranslations("FilterPage"); @@ -80,7 +108,7 @@ const FilterPage = () => { useEffect(() => { async function initState() { - getCategories(); + // getCategories(); // getSelectedCategory(); if (isSatker) { getUserLevels(); @@ -92,8 +120,14 @@ const 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]); @@ -111,13 +145,46 @@ const FilterPage = () => { } console.log(monthYearFilter, "monthFilter"); initState(); - }, [change, asPath, monthYearFilter, page, sortBy, sortByOpt, title, startDateString, endDateString, categorie, formatFilter]); + }, [ + change, + asPath, + monthYearFilter, + page, + sortBy, + sortByOpt, + title, + startDateString, + endDateString, + categorie, + formatFilter, + ]); - async function getCategories() { - const category = await listCategory("2"); - const resCategory = category?.data?.data?.content; - setCategories(resCategory); - } + // async function getCategories() { + // const category = await listCategory("2"); + // const resCategory = category?.data?.data?.content; + // setCategories(resCategory); + // } + + useEffect(() => { + fetchContent(); + }, []); + const fetchContent = async () => { + const response = await getPublicCategoryData( + props.group == "mabes" + ? "" + : props.group == "polda" && poldaName && String(poldaName)?.length > 1 + ? poldaName + : props.group == "satker" && + satkerName && + String(satkerName)?.length > 1 + ? "satker-" + satkerName + : "", + "", + locale == "en" ? true : false + ); + console.log("category", response); + setCategories(response?.data?.data?.content); + }; useEffect(() => { function initState() { @@ -133,7 +200,10 @@ const FilterPage = () => { async function getDataAll() { if (satkerName && String(satkerName)?.length > 1) { - 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(","); @@ -151,8 +221,12 @@ const FilterPage = () => { filterGroup, startDateString, endDateString, - monthYearFilter ? getOnlyMonthAndYear(monthYearFilter)?.split("/")[0]?.replace("", "") : "", - monthYearFilter ? getOnlyMonthAndYear(monthYearFilter)?.split("/")[1] : "" + monthYearFilter + ? getOnlyMonthAndYear(monthYearFilter)?.split("/")[0]?.replace("", "") + : "", + monthYearFilter + ? getOnlyMonthAndYear(monthYearFilter)?.split("/")[1] + : "" ); close(); const data = response?.data?.data; @@ -162,7 +236,10 @@ const FilterPage = () => { setTotalPage(data?.totalPages); 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(","); @@ -179,8 +256,12 @@ const 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] + : "" ); close(); const data = response?.data?.data; @@ -227,7 +308,10 @@ const 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(","); @@ -240,8 +324,12 @@ const 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 @@ -389,7 +477,10 @@ const FilterPage = () => {
      -
      - + {
      - +
      { placeholderText={t("selectDate")} onCalendarClose={() => setCalenderState(!calenderState)} /> -
      {handleClose ? : ""}
      +
      + {handleClose ? ( + + ) : ( + "" + )} +
      -

      {t("categories")}

      +

      + {t("categories")} +

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

        Format

        +

        + Format +

        @@ -499,7 +670,11 @@ const FilterPage = () => {

        {t("sortBy")}

        - handleSorting(e)} + className="border rounded-md py-2 px-3 focus:ring-red-500 focus:border-red-500" + > @@ -508,21 +683,36 @@ const FilterPage = () => { {videoData?.length > 0 ? (
        {videoData?.map((video: any) => ( - + - +
        - {formatDateToIndonesian(new Date(video?.createdAt))} {video?.timezone ? video?.timezone : "WIB"}| + {formatDateToIndonesian(new Date(video?.createdAt))}{" "} + {video?.timezone ? video?.timezone : "WIB"}|{" "} + {video?.clickCount}{" "} - + {" "}
        -
        {video?.title}
        +
        + {video?.title} +
        @@ -530,11 +720,19 @@ const FilterPage = () => {
        ) : (

        - empty + empty

        )} - +
        diff --git a/app/[locale]/(public)/audio/filter/page.tsx b/app/[locale]/(public)/audio/filter/page.tsx index 6d637afc..8b1f1388 100644 --- a/app/[locale]/(public)/audio/filter/page.tsx +++ b/app/[locale]/(public)/audio/filter/page.tsx @@ -10,6 +10,7 @@ import { } from "@/utils/globals"; import { useParams, usePathname, useSearchParams } from "next/navigation"; import { + getPublicCategoryData, getUserLevelListByParent, listCategory, listData, @@ -45,7 +46,7 @@ const columns: ColumnDef[] = [ }, ]; -const FilterPage = () => { +const FilterPage = (props: { group?: string; type: string }) => { const router = useRouter(); const asPath = usePathname(); const params = useParams(); @@ -96,6 +97,8 @@ const FilterPage = () => { const [userLevels, setUserLevels] = useState([]); const t = useTranslations("FilterPage"); const [isLoading, setIsLoading] = useState(true); + const poldaName = params?.polda_name; + const satkerName = params?.satker_name; // const [startDate, endDate] = dateRange; @@ -116,7 +119,7 @@ const FilterPage = () => { useEffect(() => { async function initState() { - getCategories(); + // getCategories(); // getSelectedCategory(); if (isSatker) { getUserLevels(); @@ -167,11 +170,32 @@ const FilterPage = () => { formatFilter, ]); - async function getCategories() { - const category = await listCategory("4"); - const resCategory = category?.data?.data?.content; - setCategories(resCategory); - } + // async function getCategories() { + // const category = await listCategory("4"); + // const resCategory = category?.data?.data?.content; + // setCategories(resCategory); + // } + + useEffect(() => { + initFetch(); + }, []); + const initFetch = async () => { + const response = await getPublicCategoryData( + props.group == "mabes" + ? "" + : props.group == "polda" && poldaName && String(poldaName)?.length > 1 + ? poldaName + : props.group == "satker" && + satkerName && + String(satkerName)?.length > 1 + ? "satker-" + satkerName + : "", + "", + locale == "en" ? true : false + ); + console.log("category", response); + setCategories(response?.data?.data?.content); + }; useEffect(() => { function initState() { diff --git a/app/[locale]/(public)/document/filter/page.tsx b/app/[locale]/(public)/document/filter/page.tsx index 50dcc25c..4a0d71e3 100644 --- a/app/[locale]/(public)/document/filter/page.tsx +++ b/app/[locale]/(public)/document/filter/page.tsx @@ -11,6 +11,7 @@ import { import { useParams, usePathname, useSearchParams } from "next/navigation"; import { getListContent, + getPublicCategoryData, getUserLevelListByParent, listCategory, listData, @@ -46,7 +47,7 @@ const columns: ColumnDef[] = [ }, ]; -const FilterPage = () => { +const FilterPage = (props: { group?: string; type: string }) => { const router = useRouter(); const asPath = usePathname(); const params = useParams(); @@ -96,6 +97,8 @@ const FilterPage = () => { const [categories, setCategories] = useState([]); const [userLevels, setUserLevels] = useState([]); const [isLoading, setIsLoading] = useState(true); + const poldaName = params?.polda_name; + const satkerName = params?.satker_name; // const [startDate, endDate] = dateRange; @@ -116,7 +119,7 @@ const FilterPage = () => { useEffect(() => { async function initState() { - getCategories(); + // getCategories(); // getSelectedCategory(); if (isSatker) { getUserLevels(); @@ -167,11 +170,32 @@ const FilterPage = () => { formatFilter, ]); - async function getCategories() { - const category = await listCategory("3"); - const resCategory = category?.data?.data?.content; - setCategories(resCategory); - } + // async function getCategories() { + // const category = await listCategory("3"); + // const resCategory = category?.data?.data?.content; + // setCategories(resCategory); + // } + + useEffect(() => { + initFetch(); + }, []); + const initFetch = async () => { + const response = await getPublicCategoryData( + props.group == "mabes" + ? "" + : props.group == "polda" && poldaName && String(poldaName)?.length > 1 + ? poldaName + : props.group == "satker" && + satkerName && + String(satkerName)?.length > 1 + ? "satker-" + satkerName + : "", + "", + locale == "en" ? true : false + ); + console.log("category", response); + setCategories(response?.data?.data?.content); + }; useEffect(() => { function initState() { diff --git a/app/[locale]/(public)/image/filter/page.tsx b/app/[locale]/(public)/image/filter/page.tsx index 5624c1bb..803e2a31 100644 --- a/app/[locale]/(public)/image/filter/page.tsx +++ b/app/[locale]/(public)/image/filter/page.tsx @@ -10,6 +10,7 @@ import { } from "@/utils/globals"; import { useParams, usePathname, useSearchParams } from "next/navigation"; import { + getPublicCategoryData, getUserLevelListByParent, listCategory, listData, @@ -47,7 +48,7 @@ const columns: ColumnDef[] = [ }, ]; -const FilterPage = () => { +const FilterPage = (props: { group?: string; type: string }) => { const router = useRouter(); const asPath = usePathname(); const params = useParams(); @@ -99,6 +100,8 @@ const FilterPage = () => { const [userLevels, setUserLevels] = useState([]); const t = useTranslations("FilterPage"); const [isFilterOpen, setIsFilterOpen] = useState(true); + const poldaName = params?.polda_name; + const satkerName = params?.satker_name; // const [startDate, endDate] = dateRange; @@ -119,7 +122,7 @@ const FilterPage = () => { useEffect(() => { async function initState() { - getCategories(); + // getCategories(); // getSelectedCategory(); if (isSatker) { getUserLevels(); @@ -170,11 +173,25 @@ const FilterPage = () => { formatFilter, ]); - async function getCategories() { - const category = await listCategory("1"); - const resCategory = category?.data?.data?.content; - setCategories(resCategory); - } + // async function getCategories() { + // const category = await listCategory("1"); + // const resCategory = category?.data?.data?.content; + // setCategories(resCategory); + // } + + useEffect(() => { + initFetch(); + }, []); + const initFetch = async () => { + const response = await getPublicCategoryData( + props.group == "mabes" ? "" : props.group == "polda" && poldaName && String(poldaName)?.length > 1 ? poldaName : props.group == "satker" && satkerName && String(satkerName)?.length > 1 ? "satker-" + satkerName : "", + "", + locale == "en" ? true : false + ); + console.log("category", response); + setCategories(response?.data?.data?.content); + }; + useEffect(() => { function initState() { diff --git a/app/[locale]/(public)/video/filter/page.tsx b/app/[locale]/(public)/video/filter/page.tsx index 752885ca..6197aedd 100644 --- a/app/[locale]/(public)/video/filter/page.tsx +++ b/app/[locale]/(public)/video/filter/page.tsx @@ -11,6 +11,7 @@ import { import { useParams, usePathname, useSearchParams } from "next/navigation"; import { getListContent, + getPublicCategoryData, getUserLevelListByParent, listCategory, listData, @@ -48,7 +49,7 @@ const columns: ColumnDef[] = [ }, ]; -const FilterPage = () => { +const FilterPage = (props: { group?: string; type: string }) => { const router = useRouter(); const asPath = usePathname(); const params = useParams(); @@ -83,6 +84,8 @@ const FilterPage = () => { const [sortByOpt, setSortByOpt] = useState( sortBy === "popular" ? "clickCount" : "createdAt" ); + const poldaName = params?.polda_name; + const satkerName = params?.satker_name; const isRegional = asPath?.includes("regional"); const isSatker = asPath?.includes("satker"); const [formatFilter, setFormatFilter] = useState([]); @@ -116,7 +119,7 @@ const FilterPage = () => { useEffect(() => { async function initState() { - getCategories(); + // getCategories(); // getSelectedCategory(); if (isSatker) { getUserLevels(); @@ -162,11 +165,32 @@ const FilterPage = () => { formatFilter, ]); - async function getCategories() { - const category = await listCategory("2"); - const resCategory = category?.data?.data?.content; - setCategories(resCategory); - } + // async function getCategories() { + // const category = await listCategory("2"); + // const resCategory = category?.data?.data?.content; + // setCategories(resCategory); + // } + + useEffect(() => { + initFetch(); + }, []); + const initFetch = async () => { + const response = await getPublicCategoryData( + props.group == "mabes" + ? "" + : props.group == "polda" && poldaName && String(poldaName)?.length > 1 + ? poldaName + : props.group == "satker" && + satkerName && + String(satkerName)?.length > 1 + ? "satker-" + satkerName + : "", + "", + locale == "en" ? true : false + ); + console.log("category", response); + setCategories(response?.data?.data?.content); + }; useEffect(() => { function initState() { diff --git a/components/form/content/video-update-form.tsx b/components/form/content/video-update-form.tsx index c081082b..959c6aae 100644 --- a/components/form/content/video-update-form.tsx +++ b/components/form/content/video-update-form.tsx @@ -345,8 +345,66 @@ export default function FormVideoUpdate() { } }; + // const save = async (data: VideoSchema) => { + // loading(); + // const finalTags = tags.join(", "); + // const requestData = { + // ...data, + // id: detail?.id, + // title: data.title, + // description: data.description, + // htmlDescription: data.description, + // fileTypeId, + // categoryId: selectedTarget, + // subCategoryId: selectedTarget, + // uploadedBy: "2b7c8d83-d298-4b19-9f74-b07924506b58", + // statusId: "1", + // publishedFor: publishedFor.join(","), + // creatorName: data.creatorName, + // tags: finalTags, + // isYoutube: false, + // isInternationalMedia: false, + // }; + + // const response = await createMedia(requestData); + // console.log("Form Data Submitted:", requestData); + + // const formMedia = new FormData(); + // const thumbnail = files[0]; + // formMedia.append("file", thumbnail); + // const responseThumbnail = await uploadThumbnail(id, formMedia); + // if (responseThumbnail?.error == true) { + // error(responseThumbnail?.message); + // return false; + // } + + // const progressInfoArr = []; + // for (const item of files) { + // progressInfoArr.push({ percentage: 0, fileName: item.name }); + // } + // progressInfo = progressInfoArr; + // setIsStartUpload(true); + // setProgressList(progressInfoArr); + + // close(); + // // showProgress(); + // files.map(async (item: any, index: number) => { + // await uploadResumableFile(index, String(id), item, "0"); + // }); + + // // MySwal.fire({ + // // title: "Sukses", + // // text: "Data berhasil disimpan.", + // // icon: "success", + // // confirmButtonColor: "#3085d6", + // // confirmButtonText: "OK", + // // }).then(() => { + // // router.push("/en/contributor/content/video"); + // // }); + // }; const save = async (data: VideoSchema) => { loading(); + const finalTags = tags.join(", "); const requestData = { ...data, @@ -367,40 +425,43 @@ export default function FormVideoUpdate() { }; const response = await createMedia(requestData); - console.log("Form Data Submitted:", requestData); + console.log("Form Data Submitted (Metadata):", requestData); - const formMedia = new FormData(); - const thumbnail = files[0]; - formMedia.append("file", thumbnail); - const responseThumbnail = await uploadThumbnail(id, formMedia); - if (responseThumbnail?.error == true) { - error(responseThumbnail?.message); + if (response?.error) { + error(response?.message); return false; } - const progressInfoArr = []; - for (const item of files) { - progressInfoArr.push({ percentage: 0, fileName: item.name }); + if (selectedFiles.length > 0) { + const thumbnail = selectedFiles[0]; + const formMedia = new FormData(); + formMedia.append("file", thumbnail); + const responseThumbnail = await uploadThumbnail(id, formMedia); + if (responseThumbnail?.error) { + // Perbaiki pengecekan error + error(responseThumbnail?.message); + return false; + } + console.log("Thumbnail uploaded:", responseThumbnail); } - progressInfo = progressInfoArr; - setIsStartUpload(true); - setProgressList(progressInfoArr); - close(); - // showProgress(); - files.map(async (item: any, index: number) => { - await uploadResumableFile(index, String(id), item, "0"); - }); + const newVideoFilesToUpload = files.filter((file) => file instanceof File); - // MySwal.fire({ - // title: "Sukses", - // text: "Data berhasil disimpan.", - // icon: "success", - // confirmButtonColor: "#3085d6", - // confirmButtonText: "OK", - // }).then(() => { - // router.push("/en/contributor/content/video"); - // }); + if (newVideoFilesToUpload.length > 0) { + const progressInfoArr = newVideoFilesToUpload.map((item) => ({ + percentage: 0, + fileName: item.name, + })); + progressInfo = progressInfoArr; + setIsStartUpload(true); + setProgressList(progressInfoArr); + + newVideoFilesToUpload.map(async (item: File, index: number) => { + await uploadResumableFile(index, String(id), item, "0"); + }); + } else { + successSubmit("/in/contributor/content/video"); + } }; const onSubmit = (data: VideoSchema) => { diff --git a/components/landing-page/hero-new-polda.tsx b/components/landing-page/hero-new-polda.tsx index fbb2f664..55df4024 100644 --- a/components/landing-page/hero-new-polda.tsx +++ b/components/landing-page/hero-new-polda.tsx @@ -2,21 +2,19 @@ import { formatDateToIndonesian, shimmer, toBase64 } from "@/utils/globals"; import React, { useEffect, useRef, useState } from "react"; import "swiper/css/bundle"; import "swiper/css/navigation"; -import { getHeroData, listStaticBanner } from "@/service/landing/landing"; +import { getHeroData, getListContent, listStaticBanner } from "@/service/landing/landing"; import Link from "next/link"; import { useParams, usePathname, useRouter } from "next/navigation"; -import { Carousel, CarouselContent, CarouselItem, CarouselNext, CarouselPrevious } from "@/components/ui/carousel"; +import { + Carousel, + CarouselContent, + CarouselItem, + CarouselNext, + CarouselPrevious, +} from "@/components/ui/carousel"; import { Skeleton } from "../ui/skeleton"; import Image from "next/image"; import Cookies from "js-cookie"; -import { Tabs, TabsContent, TabsList, TabsTrigger } from "../ui/tabs"; -import { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle } from "../ui/card"; -import { Label } from "../ui/label"; -import { Input } from "../ui/input"; -import { Button } from "../ui/button"; -import { Textarea } from "../ui/textarea"; -import { Checkbox } from "../ui/checkbox"; -import { Dialog, DialogClose, DialogContent, DialogDescription, DialogHeader, DialogTitle } from "../ui/dialog"; import { Autoplay, Navigation, Pagination } from "swiper/modules"; import { Swiper, SwiperClass, SwiperSlide } from "swiper/react"; import "swiper/css"; @@ -31,7 +29,12 @@ type HeroModalProps = { satkerName?: string; }; -const HeroModal = ({ onClose, group, poldaName, satkerName }: HeroModalProps) => { +const HeroModal = ({ + onClose, + group, + poldaName, + satkerName, +}: HeroModalProps) => { const [heroData, setHeroData] = useState(); const params = useParams(); const locale = params?.locale; @@ -93,17 +96,32 @@ const HeroModal = ({ onClose, group, poldaName, satkerName }: HeroModalProps) =>
        {heroData?.length > 0 && ( <> - - )} - (swiperRef.current = swiper)} autoplay={{ delay: 3000 }} className="mySwiper w-full"> + (swiperRef.current = swiper)} + autoplay={{ delay: 3000 }} + className="mySwiper w-full" + >
        - @@ -111,19 +129,37 @@ const HeroModal = ({ onClose, group, poldaName, satkerName }: HeroModalProps) => heroData.map((list: any, index: number) => (
        - gambar-utama + gambar-utama
        - {list?.categoryName || "Liputan Kegiatan"} + + {list?.categoryName || "Liputan Kegiatan"} +

        {list?.title}

        - {formatDateToIndonesian(new Date(list?.createdAt))} {list?.timezone || "WIB"} |{" "} - + {formatDateToIndonesian(new Date(list?.createdAt))}{" "} + {list?.timezone || "WIB"} |{" "} + )) ) : (

        - empty + empty
        )}
        @@ -173,6 +215,8 @@ const HeroNewPolda = (props: { group?: string }) => { const [showFormModal, setShowFormModal] = useState(false); const poldaName = params?.polda_name; const satkerName = params?.satker_name; + const [newContent, setNewContent] = useState(); + const [selectedTab, setSelectedTab] = useState("image"); useEffect(() => { const timer = setTimeout(() => { @@ -250,7 +294,12 @@ const HeroNewPolda = (props: { group?: string }) => { let data = response?.data?.data?.content; setHeroData(data); - if (data && props.group === "polda" && poldaName && String(poldaName)?.length > 1) { + if ( + data && + props.group === "polda" && + poldaName && + String(poldaName)?.length > 1 + ) { const resStatic = await listStaticBanner(poldaName, locale == "en"); for (let i = 0; i < resStatic?.data?.data?.length; i++) { @@ -264,6 +313,43 @@ const HeroNewPolda = (props: { group?: string }) => { } }; + useEffect(() => { + fecthNewContent(); + }, [selectedTab]); + const fecthNewContent = async () => { + console.log("Satker Name : ", satkerName); + const request = { + title: "", + page: 0, + size: 5, + sortBy: "createdAt", + contentTypeId: + selectedTab == "image" + ? "1" + : selectedTab == "video" + ? "2" + : selectedTab == "text" + ? "3" + : selectedTab == "audio" + ? "4" + : "", + group: + props.group == "mabes" + ? "" + : props.group == "polda" && poldaName && String(poldaName)?.length > 1 + ? poldaName + : props.group == "satker" && + satkerName && + String(satkerName)?.length > 1 + ? "satker-" + satkerName + : "", + isInt: locale == "en" ? true : false, + }; + const response = await getListContent(request); + console.log("category", response); + setNewContent(response?.data?.data?.content); + }; + const shimmer = (w: number, h: number) => ` @@ -278,11 +364,18 @@ const HeroNewPolda = (props: { group?: string }) => { `; - const toBase64 = (str: string) => (typeof window === "undefined" ? Buffer.from(str).toString("base64") : window.btoa(str)); + const toBase64 = (str: string) => + typeof window === "undefined" + ? Buffer.from(str).toString("base64") + : window.btoa(str); return (
        -
        {showModal && setShowModal(false)} group="polda" />}
        +
        + {showModal && ( + setShowModal(false)} group="polda" /> + )} +
        {isLoading ? (
        @@ -298,7 +391,16 @@ const HeroNewPolda = (props: { group?: string }) => { {content?.map((list: any) => (
        - gambar-utama + gambar-utama
        { } >
        - {list?.categoryName || "Liputan Kegiatan"} -

        {list?.title}

        + + {list?.categoryName || "Liputan Kegiatan"} + +

        + {list?.title} +

        - {formatDateToIndonesian(new Date(list?.createdAt))} {list?.timezone || "WIB"} | 👁 {list?.clickCount} + {formatDateToIndonesian(new Date(list?.createdAt))}{" "} + {list?.timezone || "WIB"} | 👁 {list?.clickCount}

        @@ -327,10 +434,19 @@ const HeroNewPolda = (props: { group?: string }) => {
        - {heroData?.slice(0, 3).map((item: any) => ( + {newContent?.slice(0, 3).map((item: any) => (
      • - {item?.title} + {item?.title}
        { : `${locale}/audio/detail/${item?.slug}` } > - {item?.categoryName} -

        {item?.title}

        + + {item?.categoryName} + +

        + {item?.title} +

        - {formatDateToIndonesian(new Date(item?.createdAt))} {item?.timezone || "WIB"} |{" "} - + {formatDateToIndonesian(new Date(item?.createdAt))}{" "} + {item?.timezone || "WIB"} |{" "} + { const [showFormModal, setShowFormModal] = useState(false); const poldaName = params?.polda_name; const satkerName = params?.satker_name; + const [newContent, setNewContent] = useState(); + const [selectedTab, setSelectedTab] = useState("image"); + + useEffect(() => { + fecthNewContent(); + }, [selectedTab]); + const fecthNewContent = async () => { + console.log("Satker Name : ", satkerName); + const request = { + title: "", + page: 0, + size: 5, + sortBy: "createdAt", + contentTypeId: + selectedTab == "image" + ? "1" + : selectedTab == "video" + ? "2" + : selectedTab == "text" + ? "3" + : selectedTab == "audio" + ? "4" + : "", + group: + props.group == "mabes" + ? "" + : props.group == "polda" && poldaName && String(poldaName)?.length > 1 + ? poldaName + : props.group == "satker" && + satkerName && + String(satkerName)?.length > 1 + ? "satker-" + satkerName + : "", + isInt: locale == "en" ? true : false, + }; + const response = await getListContent(request); + console.log("category", response); + setNewContent(response?.data?.data?.content); + }; + useEffect(() => { const timer = setTimeout(() => { @@ -399,7 +440,7 @@ const HeroNew = (props: { group?: string }) => {

        - {heroData?.slice(0, 3).map((item: any) => ( + {newContent?.slice(0, 3).map((item: any) => (
      • { }; }, [api]); - let prefixPath = poldaName ? `/polda/${poldaName}` : satkerName ? `/satker/${satkerName}` : "/"; + let prefixPath = poldaName + ? `/polda/${poldaName}` + : satkerName + ? `/satker/${satkerName}` + : "/"; useEffect(() => { const timer = setTimeout(() => { @@ -66,8 +77,26 @@ const NewContent = (props: { group: string; type: string }) => { page: 0, size: 5, sortBy: props.type == "popular" ? "clickCount" : "createdAt", - contentTypeId: selectedTab == "image" ? "1" : selectedTab == "video" ? "2" : selectedTab == "text" ? "3" : selectedTab == "audio" ? "4" : "", - group: props.group == "mabes" ? "" : props.group == "polda" && poldaName && String(poldaName)?.length > 1 ? poldaName : props.group == "satker" && satkerName && String(satkerName)?.length > 1 ? "satker-" + satkerName : "", + contentTypeId: + selectedTab == "image" + ? "1" + : selectedTab == "video" + ? "2" + : selectedTab == "text" + ? "3" + : selectedTab == "audio" + ? "4" + : "", + group: + props.group == "mabes" + ? "" + : props.group == "polda" && poldaName && String(poldaName)?.length > 1 + ? poldaName + : props.group == "satker" && + satkerName && + String(satkerName)?.length > 1 + ? "satker-" + satkerName + : "", isInt: locale == "en" ? true : false, }; const response = await getListContent(request); @@ -89,7 +118,10 @@ const NewContent = (props: { group: string; type: string }) => { `; - const toBase64 = (str: string) => (typeof window === "undefined" ? Buffer.from(str).toString("base64") : window.btoa(str)); + const toBase64 = (str: string) => + typeof window === "undefined" + ? Buffer.from(str).toString("base64") + : window.btoa(str); return (
        @@ -99,11 +131,21 @@ const NewContent = (props: { group: string; type: string }) => { {pathname?.split("/")[1] == "in" ? ( <> {t("content")}  - {props.type == "popular" ? "Terpopuler" : props.type == "latest" ? t("new") : "Serupa"} + {props.type == "popular" + ? "Terpopuler" + : props.type == "latest" + ? t("new") + : "Serupa"} ) : ( <> - {props.type == "popular" ? "Popular" : props.type == "latest" ? t("new") : "Serupa"} + + {props.type == "popular" + ? "Popular" + : props.type == "latest" + ? t("new") + : "Serupa"} +   {t("content")} @@ -149,11 +191,34 @@ const NewContent = (props: { group: string; type: string }) => { {newContent?.map((image: any) => ( - -
        router.push(prefixPath + `/image/detail/${image?.slug}`)} className="cursor-pointer relative group overflow-hidden bg-white rounded-xl shadow-md hover:shadow-lg transition-shadow duration-300"> + +
        + router.push( + prefixPath + `/image/detail/${image?.slug}` + ) + } + className="cursor-pointer relative group overflow-hidden bg-white rounded-xl shadow-md hover:shadow-lg transition-shadow duration-300" + > {/* Image with motion effect */} - - image + + image {/* Badge category */} @@ -161,7 +226,12 @@ const NewContent = (props: { group: string; type: string }) => { {/* Red icon overlay */}
        - + { {/* Caption section */}
        -

        {image?.categoryName?.toUpperCase() ?? "Giat Pimpinan"}

        +

        + {image?.categoryName?.toUpperCase() ?? + "Giat Pimpinan"} +

        -

        {image?.title}

        +

        + {image?.title} +

        {/*

        {formatDateToIndonesian(new Date(image?.createdAt))} {image?.timezone ?? "WIB"} | @@ -190,7 +265,14 @@ const NewContent = (props: { group: string; type: string }) => {

        {Array.from({ length: count }).map((_, index) => ( -
        @@ -199,7 +281,13 @@ const NewContent = (props: { group: string; type: string }) => { ) : (

        - empty + empty

        ) ) : selectedTab == "audio" ? ( @@ -207,11 +295,26 @@ const NewContent = (props: { group: string; type: string }) => { {newContent?.map((audio: any) => ( - -
        router.push(prefixPath + `/audio/detail/${audio?.slug}`)} className="cursor-pointer bg-white rounded-xl shadow-md hover:shadow-lg transition-shadow duration-300 overflow-hidden"> + +
        + router.push( + prefixPath + `/audio/detail/${audio?.slug}` + ) + } + className="cursor-pointer bg-white rounded-xl shadow-md hover:shadow-lg transition-shadow duration-300 overflow-hidden" + > {/* Icon Background */}
        - + { {/* Caption */}
        -

        {audio?.categoryName?.toUpperCase() ?? "GIAT PIMPINAN"}

        +

        + {audio?.categoryName?.toUpperCase() ?? + "GIAT PIMPINAN"} +

        -

        {audio?.title}

        +

        + {audio?.title} +

        {/*

        {formatDateToIndonesian(new Date(audio?.createdAt))} {audio?.timezone ?? "WIB"} | @@ -237,7 +345,14 @@ const NewContent = (props: { group: string; type: string }) => {

        {Array.from({ length: count }).map((_, index) => ( -
        @@ -246,7 +361,13 @@ const NewContent = (props: { group: string; type: string }) => { ) : (

        - empty + empty

        ) ) : selectedTab == "video" ? ( @@ -254,11 +375,34 @@ const NewContent = (props: { group: string; type: string }) => { {newContent?.map((video: any) => ( - -
        router.push(prefixPath + `/video/detail/${video?.slug}`)} className="cursor-pointer relative group overflow-hidden bg-white rounded-xl shadow-md hover:shadow-lg transition-shadow duration-300"> + +
        + router.push( + prefixPath + `/video/detail/${video?.slug}` + ) + } + className="cursor-pointer relative group overflow-hidden bg-white rounded-xl shadow-md hover:shadow-lg transition-shadow duration-300" + > {/* Image with motion effect */} - - video + + video {/* Badge category */} @@ -266,7 +410,12 @@ const NewContent = (props: { group: string; type: string }) => { {/* Red icon overlay */}
        - + { {/* Caption section */}
        -

        {video?.categoryName?.toUpperCase() ?? "Video"}

        +

        + {video?.categoryName?.toUpperCase() ?? "Video"} +

        -

        {video?.title}

        +

        + {video?.title} +

        {/*

        {formatDateToIndonesian(new Date(video?.createdAt))} {video?.timezone ?? "WIB"} | @@ -296,7 +449,14 @@ const NewContent = (props: { group: string; type: string }) => { {/* Pagination Dots */}

        {Array.from({ length: count }).map((_, index) => ( -
        @@ -305,18 +465,39 @@ const NewContent = (props: { group: string; type: string }) => { ) : (

        - empty + empty

        ) ) : newContent.length > 0 ? ( {newContent?.map((text: any) => ( - -
        router.push(prefixPath + `/document/detail/${text?.slug}`)} className="cursor-pointer rounded-lg shadow-md overflow-hidden bg-white"> + +
        + router.push( + prefixPath + `/document/detail/${text?.slug}` + ) + } + className="cursor-pointer rounded-lg shadow-md overflow-hidden bg-white" + > {/* Ikon di tengah dengan latar kuning */}
        - + { {/* Konten bawah */}
        {/* Kategori merah */} -
        {text?.categoryName?.toUpperCase() ?? "Text"}
        +
        + {text?.categoryName?.toUpperCase() ?? "Text"} +
        {/* Judul */} -
        {text?.title}
        +
        + {text?.title} +
        {/* Meta info */} {/*
        @@ -360,7 +545,14 @@ const NewContent = (props: { group: string; type: string }) => { {/* Pagination Dots */}
        {Array.from({ length: count }).map((_, index) => ( -
        @@ -369,7 +561,13 @@ const NewContent = (props: { group: string; type: string }) => { ) : (

        - empty + empty

        )}