This commit is contained in:
Sabda Yagra 2025-07-22 14:12:16 +07:00
parent e0bb77e7af
commit 6650eb4a95
17 changed files with 1965 additions and 124 deletions

View File

@ -0,0 +1,743 @@
"use client";
import React, { useEffect, useState } from "react";
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 {
getPublicCategoryData,
getUserLevelListByParent,
listCategory,
listData,
listDataAll,
listDataRegional,
} from "@/service/landing/landing";
import {
ColumnDef,
ColumnFiltersState,
PaginationState,
SortingState,
VisibilityState,
} from "@tanstack/react-table";
import { Link, useRouter } from "@/i18n/routing";
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 FilterImageComponent from "@/components/landing-page/filter-all/image-filter-card";
import FilterVideoComponent from "@/components/landing-page/filter-all/video-filter-card";
import FilterDocumentComponent from "@/components/landing-page/filter-all/document-filter-card";
import FilterAudioComponent from "@/components/landing-page/filter-all/audio-filter-card";
import { useTranslations } from "next-intl";
export default function FilterPage() {
const router = useRouter();
const asPath = usePathname();
const params = useParams();
const searchParams = useSearchParams();
const locale = params?.locale;
const [imageData, setImageData] = useState<any>();
const [totalData, setTotalData] = React.useState<number>(1);
const [totalPage, setTotalPage] = React.useState<number>(1);
const [sorting, setSorting] = React.useState<SortingState>([]);
const [columnFilters, setColumnFilters] = React.useState<ColumnFiltersState>(
[]
);
const [columnVisibility, setColumnVisibility] =
React.useState<VisibilityState>({});
const [rowSelection, setRowSelection] = React.useState({});
const [pagination, setPagination] = React.useState<PaginationState>({
pageIndex: 0,
pageSize: 10,
});
const [page, setPage] = useState(1);
const [totalContent, setTotalContent] = useState();
const [change, setChange] = useState(false);
const sortBy = searchParams?.get("sortBy");
const title = searchParams?.get("title");
const categorie = searchParams?.get("category");
const group = searchParams?.get("group");
const tag: any = searchParams?.get("tag");
const [contentImage, setContentImage] = useState([]);
const [, setGetTotalPage] = useState();
let typingTimer: any;
const doneTypingInterval = 1500;
const [search, setSearch] = useState();
const [categoryFilter, setCategoryFilter] = useState<any>([]);
const [monthYearFilter, setMonthYearFilter] = useState<any>();
const [searchTitle, setSearchTitle] = useState<string>("");
const [sortByOpt, setSortByOpt] = useState<any>(
sortBy === "popular" ? "clickCount" : "createdAt"
);
const isRegional = asPath?.includes("regional");
const isSatker = asPath?.includes("satker");
const [formatFilter, setFormatFilter] = useState<any>([]);
const pages = page ? page - 1 : 0;
const [startDateString, setStartDateString] = useState<any>();
const [endDateString, setEndDateString] = useState<any>();
const [dateRange, setDateRange] = useState<any>([null, null]);
const [calenderState, setCalenderState] = useState(false);
const [handleClose, setHandleClose] = useState(false);
const [categories, setCategories] = useState([]);
const [userLevels, setUserLevels] = useState([]);
const [contentAll, setContentAll] = useState([]);
const t = useTranslations("FilterPage");
const [isFilterOpen, setIsFilterOpen] = useState(true);
const [categoryPage, setCategoryPage] = useState(1);
const [categoryTotalPages, setCategoryTotalPages] = useState(1);
const poldaName = params?.polda_name;
const satkerName = params?.satker_name;
useEffect(() => {
const title = searchParams?.get("title") || "";
const category = searchParams?.get("category") || "";
const sortBy = searchParams?.get("sortBy") || "latest";
setSearchTitle(title);
setCategoryFilter(category ? category.split("&") : []);
setSortByOpt(sortBy === "popular" ? "clickCount" : "createdAt");
}, [searchParams]);
useEffect(() => {
fetchCategories(categoryPage);
}, [categoryPage]);
const fetchCategories = async (pageNumber: number) => {
const groupParam =
poldaName && poldaName.length > 1
? poldaName
: satkerName && satkerName.length > 1
? "satker-" + satkerName
: "";
const isInt = locale === "en";
const response = await getPublicCategoryData(
groupParam,
"",
isInt,
pageNumber
);
const content = response?.data?.data?.content || [];
const total = response?.data?.data?.totalPages || 1;
setCategories(content);
setCategoryTotalPages(total);
};
React.useEffect(() => {
const pageFromUrl = searchParams?.get("page");
if (pageFromUrl) {
setPage(Number(pageFromUrl));
}
}, [searchParams]);
useEffect(() => {
async function initState() {
getCategories();
// getSelectedCategory();
if (isSatker) {
getUserLevels();
}
}
initState();
}, []);
useEffect(() => {
if (categorie) {
setCategoryFilter(
categorie?.split("&")?.length > 1 ? categorie?.split("&") : [categorie]
);
console.log(
"Kategori",
categorie,
categorie?.split("&")?.length > 1 ? categorie?.split("&") : [categorie]
);
}
}, [categorie]);
// useEffect(() => {
// fetchData();
// }, [page, sortBy, sortByOpt, title]);
useEffect(() => {
async function initState() {
if (isRegional) {
getDataRegional();
} else {
getData();
}
}
console.log(monthYearFilter, "monthFilter");
initState();
}, [
change,
monthYearFilter,
sortBy,
sortByOpt,
title,
startDateString,
endDateString,
categorie,
formatFilter,
]);
async function getCategories() {
const category = await listCategory("1");
const resCategory = category?.data?.data?.content;
setCategories(resCategory);
}
useEffect(() => {
function initState() {
if (dateRange[0] != null && dateRange[1] != null) {
setStartDateString(getOnlyDate(dateRange[0]));
setEndDateString(getOnlyDate(dateRange[1]));
setHandleClose(true);
console.log("date range", dateRange, getOnlyDate(dateRange[0]));
}
}
initState();
}, [calenderState]);
async function getData() {
if (asPath?.includes("/polda/") == true) {
if (asPath?.split("/")[2] !== "[polda_name]") {
const filter =
categoryFilter?.length > 0
? categoryFilter?.sort().join(",")
: categorie || "";
const name = title == undefined ? "" : title;
const format = formatFilter == undefined ? "" : formatFilter?.join(",");
const filterGroup = group == undefined ? asPath.split("/")[2] : group;
loading();
const response = await listDataAll(
"",
name,
filter,
"",
tag,
filterGroup,
startDateString,
endDateString,
monthYearFilter
? getOnlyMonthAndYear(monthYearFilter)
?.split("/")[0]
?.replace("0", "")
: "",
monthYearFilter
? getOnlyMonthAndYear(monthYearFilter)?.split("/")[1]
: ""
);
close();
// setGetTotalPage(response?.data?.data?.totalPages);
// setContentImage(response?.data?.data?.content);
// setTotalContent(response?.data?.data?.totalElements);
const data = response?.data?.data;
const contentData = data?.content;
setImageData(contentData);
setTotalData(data?.totalElements);
setContentAll(response?.data?.data?.content);
setTotalPage(response?.data?.data?.totalPages);
setTotalContent(response?.data?.data?.totalElements);
}
} else {
const filter =
categoryFilter?.length > 0
? categoryFilter?.sort().join(",")
: categorie || "";
const name = title == undefined ? "" : title;
const format = formatFilter == undefined ? "" : formatFilter?.join(",");
loading();
const response = await listDataAll(
"",
name,
filter,
"",
"",
tag,
startDateString,
endDateString,
monthYearFilter
? getOnlyMonthAndYear(monthYearFilter)
?.split("/")[0]
?.replace("0", "")
: "",
monthYearFilter
? getOnlyMonthAndYear(monthYearFilter)?.split("/")[1]
: ""
);
close();
// setGetTotalPage(response?.data?.data?.totalPages);
// setContentImage(response?.data?.data?.content);
// setTotalContent(response?.data?.data?.totalElements);
const data = response?.data?.data;
const contentData = data?.content;
setImageData(contentData);
setTotalData(data?.totalElements);
setContentAll(response?.data?.data?.content);
setTotalPage(response?.data?.data?.totalPages);
setTotalContent(response?.data?.data?.totalElements);
}
}
const handleCategoryFilter = (e: boolean, id: string) => {
let filter = [...categoryFilter];
if (e) {
filter = [...categoryFilter, String(id)];
} else {
filter.splice(categoryFilter.indexOf(id), 1);
}
console.log("checkbox filter", filter);
setCategoryFilter(filter);
router.push(`?category=${filter.join("&")}`);
};
const handleFormatFilter = (e: boolean, id: string) => {
let filter = [...formatFilter];
if (e) {
filter = [...formatFilter, id];
} else {
filter.splice(formatFilter.indexOf(id), 1);
}
console.log("Format filter", filter);
setFormatFilter(filter);
};
const cleanCheckbox = () => {
setCategoryFilter([]);
setFormatFilter([]);
router.push(`?category=&title=`);
setDateRange([null, null]);
setMonthYearFilter(null);
setChange(!change);
};
async function getDataRegional() {
const filter =
categoryFilter?.length > 0
? categoryFilter?.sort().join(",")
: categorie || "";
const name = title == undefined ? "" : title;
const format = formatFilter == undefined ? "" : formatFilter?.join(",");
loading();
const response = await listDataRegional(
"",
name,
filter,
format,
"",
startDateString,
endDateString,
monthYearFilter
? getOnlyMonthAndYear(monthYearFilter)?.split("/")[0]?.replace("", "")
: "",
monthYearFilter
? getOnlyMonthAndYear(monthYearFilter)?.split("/")[1]
: "",
12,
pages,
sortByOpt
);
close();
setGetTotalPage(response?.data?.data?.totalPages);
setContentImage(response?.data?.data?.content);
setTotalContent(response?.data?.data?.totalElements);
}
function getSelectedCategory() {
const filter = [];
if (categorie) {
const categoryArr = categorie.split(",");
for (const element of categoryArr) {
filter.push(Number(element));
}
setCategoryFilter(filter);
}
}
const handleDeleteDate = () => {
setDateRange([null, null]);
setStartDateString("");
setEndDateString("");
setHandleClose(false);
};
const handleSorting = (e: any) => {
console.log(e.target.value);
if (e.target.value == "terbaru") {
setSortByOpt("createdAt");
} else {
setSortByOpt("clickCount");
}
setChange(!change);
};
async function getUserLevels() {
const res = await getUserLevelListByParent(761);
const userLevelList = res?.data?.data;
if (userLevelList !== null) {
let optionArr: any = [];
userLevelList?.map((option: any) => {
let optionData = {
id: option.id,
label: option.name,
value: option.id,
};
optionArr.push(optionData);
});
setUserLevels(optionArr);
}
}
const handleKeyUp = () => {
clearTimeout(typingTimer);
typingTimer = setTimeout(doneTyping, doneTypingInterval);
};
async function doneTyping() {
if (searchTitle == "" || searchTitle == undefined) {
router.push("?title=");
} else {
router.push(`?title=${searchTitle}`);
}
}
const handleKeyDown = () => {
clearTimeout(typingTimer);
};
return (
<div className="flex flex-col w-full max-w-screen overflow-x-hidden">
<div className="flex flex-row md:flex-row items-start gap-3 py-10 px-4 lg:px-20 bg-[#f7f7f7] dark:bg-black">
<p> {t("content", { defaultValue: "Content" })}</p>
{">"}
<p>
<span className="font-bold">
{t("allContent", { defaultValue: "All Content" })}
</span>
</p>
<p className="font-bold">|</p>
<p>{`${t("thereIs", { defaultValue: "There Is" })} ${totalContent} ${t(
"downloadableContent",
{ defaultValue: "Downloadable ContentS" }
)}`}</p>
</div>
{/* Left */}
<div className="flex flex-col lg:flex-row gap-6 pl-4 lg:pl-20 py-4">
<div className="lg:hidden flex justify-end mb-2">
<button
onClick={() => setIsFilterOpen(!isFilterOpen)}
className="text-sm text-white bg-[#bb3523] px-4 py-1 rounded-md shadow"
>
{isFilterOpen ? "Hide Filter" : "Show Filter"}
</button>
</div>
{isFilterOpen && (
<div className="h-fit min-w-full lg:min-w-[280px] max-w-full lg:max-w-[300px] bg-[#f7f7f7] dark:bg-black p-4 rounded-lg shadow-md">
<h2 className="text-lg font-semibold mb-4 flex items-center gap-1">
<Icon icon="stash:filter-light" fontSize={30} />
Filter
</h2>
<div className="border-t border-black my-4 dark:border-white"></div>
<div className="space-y-6">
<div>
<label
htmlFor="search"
className="block text-sm font-medium text-gray-700 dark:text-white"
>
{t("search", { defaultValue: "Search" })}
</label>
<Input
value={searchTitle}
onChange={(e) => setSearchTitle(e.target.value)}
onKeyUp={handleKeyUp}
onKeyDown={handleKeyDown}
type="text"
id="search"
placeholder={t("searchTitle", {
defaultValue: "Search Title",
})}
className="mt-1 w-full border rounded-md py-2 px-3 focus:ring-red-500 focus:border-red-500"
/>
</div>
<div>
<label className="block text-sm font-medium text-gray-700 dark:text-white">
{t("monthYear", { defaultValue: "Month Year" })}
</label>
<ReactDatePicker
selected={monthYearFilter}
className="mt-1 w-full text-xs border rounded-md py-2 px-3 focus:ring-red-500 focus:border-red-500"
onChange={(date) => setMonthYearFilter(date)}
dateFormat="MM | yyyy"
placeholderText={t("selectYear", {
defaultValue: "Select Year",
})}
showMonthYearPicker
/>
</div>
<div>
<label className="block text-sm font-medium text-gray-700 dark:text-white">
{t("date", { defaultValue: "Date" })}
</label>
<div className="flex flex-row justify justify-between gap-2">
<ReactDatePicker
selectsRange
className="mt-1 w-full border text-sm rounded-md py-2 px-3 focus:ring-red-500 focus:border-red-500"
startDate={dateRange[0]}
endDate={dateRange[1]}
onChange={(update) => {
setDateRange(update);
}}
placeholderText={t("selectDate", {
defaultValue: "Select Date",
})}
onCalendarClose={() => setCalenderState(!calenderState)}
/>
<div className="flex items-center">
{handleClose ? (
<Icon
icon="carbon:close-filled"
onClick={handleDeleteDate}
width="20"
inline
color="#216ba5"
/>
) : (
""
)}
</div>
</div>
</div>
<div>
<h3 className="text-sm font-medium text-gray-700 dark:text-white">
{t("categories", { defaultValue: "Categories" })}
</h3>
<ul className="mt-2 space-y-2">
{categories.map((category: any) => (
<li key={category?.id}>
<label
className="inline-flex items-center"
htmlFor={`${category.id}`}
>
<Checkbox
id={`${category.id}`}
value={category.id}
checked={categoryFilter.includes(String(category.id))}
onCheckedChange={(e) =>
handleCategoryFilter(Boolean(e), category.id)
}
/>
<span className="ml-2 text-gray-700 dark:text-white">
{category?.name}
</span>
</label>
</li>
))}
<div className="mt-4 flex gap-2 justify-center items-center">
<button
onClick={() =>
setCategoryPage((prev) => Math.max(prev - 1, 1))
}
disabled={categoryPage === 1}
className="px-3 py-1 border rounded disabled:opacity-50"
>
<svg
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
viewBox="0 0 24 24"
>
<path
fill="currentColor"
d="m13.15 16.15l-3.625-3.625q-.125-.125-.175-.25T9.3 12t.05-.275t.175-.25L13.15 7.85q.075-.075.163-.112T13.5 7.7q.2 0 .35.138T14 8.2v7.6q0 .225-.15.363t-.35.137q-.05 0-.35-.15"
/>
</svg>
</button>
{Array.from({ length: categoryTotalPages }, (_, i) => (
<button
key={i}
onClick={() => setCategoryPage(i + 1)}
className={`px-3 py-1 border rounded ${
categoryPage === i + 1
? "bg-[#bb3523] text-white"
: ""
}`}
>
{i + 1}
</button>
))}
<button
onClick={() =>
setCategoryPage((prev) =>
Math.min(prev + 1, categoryTotalPages)
)
}
disabled={categoryPage === categoryTotalPages}
className="px-3 py-1 border rounded disabled:opacity-50"
>
<svg
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
viewBox="0 0 24 24"
>
<path
fill="currentColor"
d="M10.5 16.3q-.2 0-.35-.137T10 15.8V8.2q0-.225.15-.362t.35-.138q.05 0 .35.15l3.625 3.625q.125.125.175.25t.05.275t-.05.275t-.175.25L10.85 16.15q-.075.075-.162.113t-.188.037"
/>
</svg>
</button>
</div>
</ul>
</div>
{/* Garis */}
<div className="border-t border-black my-4 dark:border-white"></div>
{/* Garis */}
<div>
<h3 className="text-sm font-medium text-gray-700 dark:text-white">
Format
</h3>
<ul className="mt-2 space-y-2">
<li>
<label className="inline-flex items-center">
<Checkbox
id="png"
value="png"
checked={formatFilter.includes("png")}
onCheckedChange={(e) =>
handleFormatFilter(Boolean(e), "png")
}
/>
<span className="ml-2 text-gray-700 dark:text-white">
PNG
</span>
</label>
</li>
<li>
<label className="inline-flex items-center">
<Checkbox
id="jpeg"
value="jpeg"
checked={formatFilter.includes("jpeg")}
onCheckedChange={(e) =>
handleFormatFilter(Boolean(e), "jpeg")
}
/>
<span className="ml-2 text-gray-700 dark:text-white">
JPEG
</span>
</label>
</li>
<li>
<label className="inline-flex items-center">
<Checkbox
id="jpg"
value="jpg"
checked={formatFilter.includes("jpg")}
onCheckedChange={(e) =>
handleFormatFilter(Boolean(e), "jpg")
}
/>
<span className="ml-2 text-gray-700 dark:text-white">
JPG
</span>
</label>
</li>
</ul>
</div>
<div className="border-t border-black dark:border-white my-4"></div>
<div className="text-center">
<a
onClick={cleanCheckbox}
className="text-[#bb3523] cursor-pointer"
>
<b>Reset Filter</b>
</a>
</div>
</div>
</div>
)}
{/* Konten Kanan */}
<div className="w-full pl-4 pr-4 lg:pr-16 pb-4 overflow-x-hidden">
<div className="w-full">
<div className="flex flex-col items-end mb-4">
<h2 className="text-lg font-semibold">
{t("sortBy", { defaultValue: "Sort By" })}
</h2>
<select
defaultValue={sortBy == "popular" ? "terpopuler" : "terbaru"}
onChange={(e) => handleSorting(e)}
className="border rounded-md py-2 px-3 focus:ring-red-500 focus:border-red-500"
>
<option value="latest">
{t("latest", { defaultValue: "Latest" })}
</option>
<option value="popular">
{t("mostPopular", { defaultValue: "Most Popular" })}
</option>
</select>
</div>
<div className="flex flex-col gap-4 w-full">
<FilterImageComponent
categoryFilter={categoryFilter}
sortByOpt={sortByOpt}
startDateString={startDateString}
endDateString={endDateString}
monthYearFilter={monthYearFilter}
/>
<FilterVideoComponent
categoryFilter={categoryFilter}
sortByOpt={sortByOpt}
startDateString={startDateString}
endDateString={endDateString}
monthYearFilter={monthYearFilter}
/>
<FilterDocumentComponent
categoryFilter={categoryFilter}
sortByOpt={sortByOpt}
startDateString={startDateString}
endDateString={endDateString}
monthYearFilter={monthYearFilter}
/>
<FilterAudioComponent
categoryFilter={categoryFilter}
sortByOpt={sortByOpt}
startDateString={startDateString}
endDateString={endDateString}
monthYearFilter={monthYearFilter}
/>
</div>
</div>
</div>
</div>
</div>
);
}

View File

@ -0,0 +1,14 @@
import Footer from "@/components/landing-page/footer";
import Navbar from "@/components/landing-page/navbar";
const layout = async ({ children }: { children: React.ReactNode }) => {
return (
<>
<Navbar />
{children}
<Footer />
</>
);
};
export default layout;

View File

@ -6,6 +6,7 @@ import { Icon } from "@iconify/react/dist/iconify.js";
import { getOnlyDate, getOnlyMonthAndYear } from "@/utils/globals";
import { useParams, usePathname, useSearchParams } from "next/navigation";
import {
getPublicCategoryData,
getUserLevelListByParent,
listCategory,
listData,
@ -18,13 +19,7 @@ import {
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";
import ReactDatePicker from "react-datepicker";
@ -90,7 +85,49 @@ export default function FilterPage() {
const t = useTranslations("FilterPage");
const [isFilterOpen, setIsFilterOpen] = useState(true);
// const [startDate, endDate] = dateRange;
const [categoryPage, setCategoryPage] = useState(1);
const [categoryTotalPages, setCategoryTotalPages] = useState(1);
const poldaName = params?.polda_name;
const satkerName = params?.satker_name;
useEffect(() => {
const title = searchParams?.get("title") || "";
const category = searchParams?.get("category") || "";
const sortBy = searchParams?.get("sortBy") || "latest";
setSearchTitle(title);
setCategoryFilter(category ? category.split("&") : []);
setSortByOpt(sortBy === "popular" ? "clickCount" : "createdAt");
}, [searchParams]);
useEffect(() => {
fetchCategories(categoryPage);
}, [categoryPage]);
const fetchCategories = async (pageNumber: number) => {
const groupParam =
poldaName && poldaName.length > 1
? poldaName
: satkerName && satkerName.length > 1
? "satker-" + satkerName
: "";
const isInt = locale === "en";
const response = await getPublicCategoryData(
groupParam,
"",
isInt,
pageNumber
);
const content = response?.data?.data?.content || [];
const total = response?.data?.data?.totalPages || 1;
setCategories(content);
setCategoryTotalPages(total);
};
React.useEffect(() => {
const pageFromUrl = searchParams?.get("page");
@ -521,63 +558,63 @@ export default function FilterPage() {
</label>
</li>
))}
{/* <div className="mt-4 flex gap-2 justify-center items-center">
<button
onClick={() =>
setCategoryPage((prev) => Math.max(prev - 1, 1))
}
disabled={categoryPage === 1}
className="px-3 py-1 border rounded disabled:opacity-50"
>
<svg
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
viewBox="0 0 24 24"
>
<path
fill="currentColor"
d="m13.15 16.15l-3.625-3.625q-.125-.125-.175-.25T9.3 12t.05-.275t.175-.25L13.15 7.85q.075-.075.163-.112T13.5 7.7q.2 0 .35.138T14 8.2v7.6q0 .225-.15.363t-.35.137q-.05 0-.35-.15"
/>
</svg>
</button>
{Array.from({ length: categoryTotalPages }, (_, i) => (
<button
key={i}
onClick={() => setCategoryPage(i + 1)}
className={`px-3 py-1 border rounded ${
categoryPage === i + 1
? "bg-[#bb3523] text-white"
: ""
}`}
>
{i + 1}
</button>
))}
<button
onClick={() =>
setCategoryPage((prev) =>
Math.min(prev + 1, categoryTotalPages)
)
}
disabled={categoryPage === categoryTotalPages}
className="px-3 py-1 border rounded disabled:opacity-50"
>
<svg
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
viewBox="0 0 24 24"
>
<path
fill="currentColor"
d="M10.5 16.3q-.2 0-.35-.137T10 15.8V8.2q0-.225.15-.362t.35-.138q.05 0 .35.15l3.625 3.625q.125.125.175.25t.05.275t-.05.275t-.175.25L10.85 16.15q-.075.075-.162.113t-.188.037"
/>
</svg>
</button>
</div> */}
<div className="mt-4 flex gap-2 justify-center items-center">
<button
onClick={() =>
setCategoryPage((prev) => Math.max(prev - 1, 1))
}
disabled={categoryPage === 1}
className="px-3 py-1 border rounded disabled:opacity-50"
>
<svg
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
viewBox="0 0 24 24"
>
<path
fill="currentColor"
d="m13.15 16.15l-3.625-3.625q-.125-.125-.175-.25T9.3 12t.05-.275t.175-.25L13.15 7.85q.075-.075.163-.112T13.5 7.7q.2 0 .35.138T14 8.2v7.6q0 .225-.15.363t-.35.137q-.05 0-.35-.15"
/>
</svg>
</button>
{Array.from({ length: categoryTotalPages }, (_, i) => (
<button
key={i}
onClick={() => setCategoryPage(i + 1)}
className={`px-3 py-1 border rounded ${
categoryPage === i + 1
? "bg-[#bb3523] text-white"
: ""
}`}
>
{i + 1}
</button>
))}
<button
onClick={() =>
setCategoryPage((prev) =>
Math.min(prev + 1, categoryTotalPages)
)
}
disabled={categoryPage === categoryTotalPages}
className="px-3 py-1 border rounded disabled:opacity-50"
>
<svg
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
viewBox="0 0 24 24"
>
<path
fill="currentColor"
d="M10.5 16.3q-.2 0-.35-.137T10 15.8V8.2q0-.225.15-.362t.35-.138q.05 0 .35.15l3.625 3.625q.125.125.175.25t.05.275t-.05.275t-.175.25L10.85 16.15q-.075.075-.162.113t-.188.037"
/>
</svg>
</button>
</div>
</ul>
</div>
{/* Garis */}

View File

@ -603,7 +603,7 @@ const FilterPage = () => {
</label>
</li>
))}
{/* <div className="mt-4 flex gap-2 justify-center items-center">
<div className="mt-4 flex gap-2 justify-center items-center">
<button
onClick={() =>
setCategoryPage((prev) => Math.max(prev - 1, 1))
@ -657,7 +657,7 @@ const FilterPage = () => {
/>
</svg>
</button>
</div> */}
</div>
</ul>
</div>
{/* Garis */}

View File

@ -504,10 +504,16 @@ const FilterPage = () => {
<div className="flex flex-col md:flex-row items-start gap-5 py-10 px-4 lg:px-20 bg-[#f7f7f7] dark:bg-black">
<p>
{" "}
{t("text", { defaultValue: "Text" })} {">"} <span className="font-bold">{t("allText", { defaultValue: "All Text" })}</span>
{t("text", { defaultValue: "Text" })} {">"}{" "}
<span className="font-bold">
{t("allText", { defaultValue: "All Text" })}
</span>
</p>
<p className="font-bold">|</p>
<p>{`${t("thereIs", { defaultValue: "There Is" })} ${totalContent} ${t("downloadableText", { defaultValue: "Downloadable Text" })}`}</p>
<p>{`${t("thereIs", { defaultValue: "There Is" })} ${totalContent} ${t(
"downloadableText",
{ defaultValue: "Downloadable Text" }
)}`}</p>
</div>
{/* Left */}
@ -547,7 +553,9 @@ const FilterPage = () => {
className="mt-1 w-full text-xs border rounded-md py-2 px-3 focus:ring-red-500 focus:border-red-500"
onChange={(date) => setMonthYearFilter(date)}
dateFormat="MM | yyyy"
placeholderText={t("selectYear", { defaultValue: "Select Year" })}
placeholderText={t("selectYear", {
defaultValue: "Select Year",
})}
showMonthYearPicker
/>
</div>
@ -565,7 +573,9 @@ const FilterPage = () => {
onChange={(update) => {
setDateRange(update);
}}
placeholderText={t("selectDate", { defaultValue: "Select Date" })}
placeholderText={t("selectDate", {
defaultValue: "Select Date",
})}
onCalendarClose={() => setCalenderState(!calenderState)}
/>
<div className="flex items-center">
@ -609,7 +619,7 @@ const FilterPage = () => {
</label>
</li>
))}
{/* <div className="mt-4 flex gap-2 justify-center items-center">
<div className="mt-4 flex gap-2 justify-center items-center">
<button
onClick={() =>
setCategoryPage((prev) => Math.max(prev - 1, 1))
@ -663,7 +673,7 @@ const FilterPage = () => {
/>
</svg>
</button>
</div> */}
</div>
</ul>
</div>
{/* Garis */}
@ -768,14 +778,20 @@ const FilterPage = () => {
<Reveal>
<div className="flex-1">
<div className="flex flex-col items-end mb-4">
<h2 className="text-lg font-semibold">{t("sortBy", { defaultValue: "Sort By" })}</h2>
<h2 className="text-lg font-semibold">
{t("sortBy", { defaultValue: "Sort By" })}
</h2>
<select
defaultValue={sortBy == "popular" ? "terpopuler" : "terbaru"}
onChange={(e) => handleSorting(e)}
className="border rounded-md py-2 px-3 focus:ring-red-500 focus:border-red-500"
>
<option value="latest">{t("latest", { defaultValue: "Latest" })}</option>
<option value="popular">{t("mostPopular", { defaultValue: "Most Popular" })}</option>
<option value="latest">
{t("latest", { defaultValue: "Latest" })}
</option>
<option value="popular">
{t("mostPopular", { defaultValue: "Most Popular" })}
</option>
</select>
</div>

View File

@ -511,13 +511,17 @@ const FilterPage = () => {
<p> {t("image", { defaultValue: "Image" })}</p>
{">"}
<p>
<span className="font-bold">{t("allImage", { defaultValue: "All Image" })}</span>
<span className="font-bold">
{t("allImage", { defaultValue: "All Image" })}
</span>
</p>
<p className="font-bold">|</p>
<p>{`${t("thereIs", { defaultValue: "There Is" })} ${totalContent} ${t("downloadableImage", { defaultValue: "Downloadable Image" })}`}</p>
<p>{`${t("thereIs", { defaultValue: "There Is" })} ${totalContent} ${t(
"downloadableImage",
{ defaultValue: "Downloadable Image" }
)}`}</p>
</div>
<div className="flex flex-col lg:flex-row gap-6 pl-4 lg:pl-20 py-4">
{/* Left */}
<div className="lg:hidden flex justify-end mb-2">
@ -551,7 +555,9 @@ const FilterPage = () => {
onKeyDown={handleKeyDown}
type="text"
id="search"
placeholder={t("searchTitle", { defaultValue: "Search Title" })}
placeholder={t("searchTitle", {
defaultValue: "Search Title",
})}
className="mt-1 w-full border rounded-md py-2 px-3 focus:ring-red-500 focus:border-red-500"
/>
</div>
@ -565,7 +571,9 @@ const FilterPage = () => {
className="mt-1 w-full text-xs border rounded-md py-2 px-3 focus:ring-red-500 focus:border-red-500"
onChange={(date) => setMonthYearFilter(date)}
dateFormat="MM | yyyy"
placeholderText={t("selectYear", { defaultValue: "Select Year" })}
placeholderText={t("selectYear", {
defaultValue: "Select Year",
})}
showMonthYearPicker
/>
</div>
@ -583,7 +591,9 @@ const FilterPage = () => {
onChange={(update) => {
setDateRange(update);
}}
placeholderText={t("selectDate", { defaultValue: "Select Date" })}
placeholderText={t("selectDate", {
defaultValue: "Select Date",
})}
onCalendarClose={() => setCalenderState(!calenderState)}
/>
<div className="flex items-center">
@ -627,7 +637,7 @@ const FilterPage = () => {
</label>
</li>
))}
{/* <div className="mt-4 flex gap-2 justify-center items-center">
<div className="mt-4 flex gap-2 justify-center items-center">
<button
onClick={() =>
setCategoryPage((prev) => Math.max(prev - 1, 1))
@ -683,7 +693,7 @@ const FilterPage = () => {
/>
</svg>
</button>
</div> */}
</div>
</ul>
</div>
{/* Garis */}
@ -759,14 +769,20 @@ const FilterPage = () => {
<Reveal>
<div className="w-full">
<div className="flex flex-col items-end mb-4">
<h2 className="text-lg font-semibold">{t("sortBy", { defaultValue: "Sort By" })}</h2>
<h2 className="text-lg font-semibold">
{t("sortBy", { defaultValue: "Sort By" })}
</h2>
<select
defaultValue={sortBy == "popular" ? "terpopuler" : "terbaru"}
onChange={(e) => handleSorting(e)}
className="border rounded-md py-2 px-3 focus:ring-red-500 focus:border-red-500"
>
<option value="latest">{t("latest", { defaultValue: "Latest" })}</option>
<option value="popular">{t("mostPopular", { defaultValue: "Most Popular" })}</option>
<option value="latest">
{t("latest", { defaultValue: "Latest" })}
</option>
<option value="popular">
{t("mostPopular", { defaultValue: "Most Popular" })}
</option>
</select>
</div>

View File

@ -0,0 +1,731 @@
"use client";
import React, { useEffect, useState } from "react";
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 {
getPublicCategoryData,
getUserLevelListByParent,
listCategory,
listData,
listDataAll,
listDataRegional,
} from "@/service/landing/landing";
import {
ColumnDef,
ColumnFiltersState,
PaginationState,
SortingState,
VisibilityState,
} from "@tanstack/react-table";
import { Link, useRouter } from "@/i18n/routing";
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 FilterImageComponent from "@/components/landing-page/filter-all/image-filter-card";
import FilterVideoComponent from "@/components/landing-page/filter-all/video-filter-card";
import FilterDocumentComponent from "@/components/landing-page/filter-all/document-filter-card";
import FilterAudioComponent from "@/components/landing-page/filter-all/audio-filter-card";
import { useTranslations } from "next-intl";
export default function FilterPage() {
const router = useRouter();
const asPath = usePathname();
const params = useParams();
const searchParams = useSearchParams();
const locale = params?.locale;
const [imageData, setImageData] = useState<any>();
const [totalData, setTotalData] = React.useState<number>(1);
const [totalPage, setTotalPage] = React.useState<number>(1);
const [sorting, setSorting] = React.useState<SortingState>([]);
const [columnFilters, setColumnFilters] = React.useState<ColumnFiltersState>(
[]
);
const [columnVisibility, setColumnVisibility] =
React.useState<VisibilityState>({});
const [rowSelection, setRowSelection] = React.useState({});
const [pagination, setPagination] = React.useState<PaginationState>({
pageIndex: 0,
pageSize: 10,
});
const [page, setPage] = useState(1);
const [totalContent, setTotalContent] = useState();
const [change, setChange] = useState(false);
const sortBy = searchParams?.get("sortBy");
const title = searchParams?.get("title");
const categorie = searchParams?.get("category");
const group = searchParams?.get("group");
const tag: any = searchParams?.get("tag");
const [contentImage, setContentImage] = useState([]);
const [, setGetTotalPage] = useState();
let typingTimer: any;
const doneTypingInterval = 1500;
const [search, setSearch] = useState();
const [categoryFilter, setCategoryFilter] = useState<any>([]);
const [monthYearFilter, setMonthYearFilter] = useState<any>();
const [searchTitle, setSearchTitle] = useState<string>("");
const [sortByOpt, setSortByOpt] = useState<any>(
sortBy === "popular" ? "clickCount" : "createdAt"
);
const isRegional = asPath?.includes("regional");
const isSatker = asPath?.includes("satker");
const [formatFilter, setFormatFilter] = useState<any>([]);
const pages = page ? page - 1 : 0;
const [startDateString, setStartDateString] = useState<any>();
const [endDateString, setEndDateString] = useState<any>();
const [dateRange, setDateRange] = useState<any>([null, null]);
const [calenderState, setCalenderState] = useState(false);
const [handleClose, setHandleClose] = useState(false);
const [categories, setCategories] = useState([]);
const [userLevels, setUserLevels] = useState([]);
const [contentAll, setContentAll] = useState([]);
const t = useTranslations("FilterPage");
const [isFilterOpen, setIsFilterOpen] = useState(true);
const [categoryPage, setCategoryPage] = useState(1);
const [categoryTotalPages, setCategoryTotalPages] = useState(1);
const poldaName = params?.polda_name;
const satkerName = params?.satker_name;
useEffect(() => {
fetchCategories(categoryPage);
}, [categoryPage]);
const fetchCategories = async (pageNumber: number) => {
const groupParam =
poldaName && poldaName.length > 1
? poldaName
: satkerName && satkerName.length > 1
? "satker-" + satkerName
: "";
const isInt = locale === "en";
const response = await getPublicCategoryData(
groupParam,
"",
isInt,
pageNumber
); // halaman 1-based
const content = response?.data?.data?.content || [];
const total = response?.data?.data?.totalPages || 1;
setCategories(content);
setCategoryTotalPages(total);
};
React.useEffect(() => {
const pageFromUrl = searchParams?.get("page");
if (pageFromUrl) {
setPage(Number(pageFromUrl));
}
}, [searchParams]);
useEffect(() => {
async function initState() {
getCategories();
// getSelectedCategory();
if (isSatker) {
getUserLevels();
}
}
initState();
}, []);
useEffect(() => {
if (categorie) {
setCategoryFilter(
categorie?.split("&")?.length > 1 ? categorie?.split("&") : [categorie]
);
console.log(
"Kategori",
categorie,
categorie?.split("&")?.length > 1 ? categorie?.split("&") : [categorie]
);
}
}, [categorie]);
// useEffect(() => {
// fetchData();
// }, [page, sortBy, sortByOpt, title]);
useEffect(() => {
async function initState() {
if (isRegional) {
getDataRegional();
} else {
getData();
}
}
console.log(monthYearFilter, "monthFilter");
initState();
}, [
change,
monthYearFilter,
sortBy,
sortByOpt,
title,
startDateString,
endDateString,
categorie,
formatFilter,
]);
async function getCategories() {
const category = await listCategory("1");
const resCategory = category?.data?.data?.content;
setCategories(resCategory);
}
useEffect(() => {
function initState() {
if (dateRange[0] != null && dateRange[1] != null) {
setStartDateString(getOnlyDate(dateRange[0]));
setEndDateString(getOnlyDate(dateRange[1]));
setHandleClose(true);
console.log("date range", dateRange, getOnlyDate(dateRange[0]));
}
}
initState();
}, [calenderState]);
async function getData() {
if (asPath?.includes("/polda/") == true) {
if (asPath?.split("/")[2] !== "[polda_name]") {
const filter =
categoryFilter?.length > 0
? categoryFilter?.sort().join(",")
: categorie || "";
const name = title == undefined ? "" : title;
const format = formatFilter == undefined ? "" : formatFilter?.join(",");
const filterGroup = group == undefined ? asPath.split("/")[2] : group;
loading();
const response = await listDataAll(
"",
name,
filter,
"",
tag,
filterGroup,
startDateString,
endDateString,
monthYearFilter
? getOnlyMonthAndYear(monthYearFilter)
?.split("/")[0]
?.replace("0", "")
: "",
monthYearFilter
? getOnlyMonthAndYear(monthYearFilter)?.split("/")[1]
: ""
);
close();
// setGetTotalPage(response?.data?.data?.totalPages);
// setContentImage(response?.data?.data?.content);
// setTotalContent(response?.data?.data?.totalElements);
const data = response?.data?.data;
const contentData = data?.content;
setImageData(contentData);
setTotalData(data?.totalElements);
setContentAll(response?.data?.data?.content);
setTotalPage(response?.data?.data?.totalPages);
setTotalContent(response?.data?.data?.totalElements);
}
} else {
const filter =
categoryFilter?.length > 0
? categoryFilter?.sort().join(",")
: categorie || "";
const name = title == undefined ? "" : title;
const format = formatFilter == undefined ? "" : formatFilter?.join(",");
loading();
const response = await listDataAll(
"",
name,
filter,
"",
"",
tag,
startDateString,
endDateString,
monthYearFilter
? getOnlyMonthAndYear(monthYearFilter)
?.split("/")[0]
?.replace("0", "")
: "",
monthYearFilter
? getOnlyMonthAndYear(monthYearFilter)?.split("/")[1]
: ""
);
close();
// setGetTotalPage(response?.data?.data?.totalPages);
// setContentImage(response?.data?.data?.content);
// setTotalContent(response?.data?.data?.totalElements);
const data = response?.data?.data;
const contentData = data?.content;
setImageData(contentData);
setTotalData(data?.totalElements);
setContentAll(response?.data?.data?.content);
setTotalPage(response?.data?.data?.totalPages);
setTotalContent(response?.data?.data?.totalElements);
}
}
const handleCategoryFilter = (e: boolean, id: string) => {
let filter = [...categoryFilter];
if (e) {
filter = [...categoryFilter, String(id)];
} else {
filter.splice(categoryFilter.indexOf(id), 1);
}
console.log("checkbox filter", filter);
setCategoryFilter(filter);
router.push(`?category=${filter.join("&")}`);
};
const handleFormatFilter = (e: boolean, id: string) => {
let filter = [...formatFilter];
if (e) {
filter = [...formatFilter, id];
} else {
filter.splice(formatFilter.indexOf(id), 1);
}
console.log("Format filter", filter);
setFormatFilter(filter);
};
const cleanCheckbox = () => {
setCategoryFilter([]);
setFormatFilter([]);
router.push(`?category=&title=`);
setDateRange([null, null]);
setMonthYearFilter(null);
setChange(!change);
};
async function getDataRegional() {
const filter =
categoryFilter?.length > 0
? categoryFilter?.sort().join(",")
: categorie || "";
const name = title == undefined ? "" : title;
const format = formatFilter == undefined ? "" : formatFilter?.join(",");
loading();
const response = await listDataRegional(
"",
name,
filter,
format,
"",
startDateString,
endDateString,
monthYearFilter
? getOnlyMonthAndYear(monthYearFilter)?.split("/")[0]?.replace("", "")
: "",
monthYearFilter
? getOnlyMonthAndYear(monthYearFilter)?.split("/")[1]
: "",
12,
pages,
sortByOpt
);
close();
setGetTotalPage(response?.data?.data?.totalPages);
setContentImage(response?.data?.data?.content);
setTotalContent(response?.data?.data?.totalElements);
}
function getSelectedCategory() {
const filter = [];
if (categorie) {
const categoryArr = categorie.split(",");
for (const element of categoryArr) {
filter.push(Number(element));
}
setCategoryFilter(filter);
}
}
const handleDeleteDate = () => {
setDateRange([null, null]);
setStartDateString("");
setEndDateString("");
setHandleClose(false);
};
const handleSorting = (e: any) => {
console.log(e.target.value);
if (e.target.value == "terbaru") {
setSortByOpt("createdAt");
} else {
setSortByOpt("clickCount");
}
setChange(!change);
};
async function getUserLevels() {
const res = await getUserLevelListByParent(761);
const userLevelList = res?.data?.data;
if (userLevelList !== null) {
let optionArr: any = [];
userLevelList?.map((option: any) => {
let optionData = {
id: option.id,
label: option.name,
value: option.id,
};
optionArr.push(optionData);
});
setUserLevels(optionArr);
}
}
const handleKeyUp = () => {
clearTimeout(typingTimer);
typingTimer = setTimeout(doneTyping, doneTypingInterval);
};
async function doneTyping() {
if (searchTitle == "" || searchTitle == undefined) {
router.push("?title=");
} else {
router.push(`?title=${searchTitle}`);
}
}
const handleKeyDown = () => {
clearTimeout(typingTimer);
};
return (
<div className="flex flex-col w-full max-w-screen overflow-x-hidden">
<div className="flex flex-row md:flex-row items-start gap-3 py-10 px-4 lg:px-20 bg-[#f7f7f7] dark:bg-black">
<p> {t("content", { defaultValue: "Content" })}</p>
{">"}
<p>
<span className="font-bold">
{t("allContent", { defaultValue: "All Content" })}
</span>
</p>
<p className="font-bold">|</p>
<p>{`${t("thereIs", { defaultValue: "There Is" })} ${totalContent} ${t(
"downloadableContent",
{ defaultValue: "Downloadable ContentS" }
)}`}</p>
</div>
{/* Left */}
<div className="flex flex-col lg:flex-row gap-6 pl-4 lg:pl-20 py-4">
<div className="lg:hidden flex justify-end mb-2">
<button
onClick={() => setIsFilterOpen(!isFilterOpen)}
className="text-sm text-white bg-[#bb3523] px-4 py-1 rounded-md shadow"
>
{isFilterOpen ? "Hide Filter" : "Show Filter"}
</button>
</div>
{isFilterOpen && (
<div className="h-fit min-w-full lg:min-w-[280px] max-w-full lg:max-w-[300px] bg-[#f7f7f7] dark:bg-black p-4 rounded-lg shadow-md">
<h2 className="text-lg font-semibold mb-4 flex items-center gap-1">
<Icon icon="stash:filter-light" fontSize={30} />
Filter
</h2>
<div className="border-t border-black my-4 dark:border-white"></div>
<div className="space-y-6">
<div>
<label
htmlFor="search"
className="block text-sm font-medium text-gray-700 dark:text-white"
>
{t("search", { defaultValue: "Search" })}
</label>
<Input
value={searchTitle}
onChange={(e) => setSearchTitle(e.target.value)}
onKeyUp={handleKeyUp}
onKeyDown={handleKeyDown}
type="text"
id="search"
placeholder={t("searchTitle", {
defaultValue: "Search Title",
})}
className="mt-1 w-full border rounded-md py-2 px-3 focus:ring-red-500 focus:border-red-500"
/>
</div>
<div>
<label className="block text-sm font-medium text-gray-700 dark:text-white">
{t("monthYear", { defaultValue: "Month Year" })}
</label>
<ReactDatePicker
selected={monthYearFilter}
className="mt-1 w-full text-xs border rounded-md py-2 px-3 focus:ring-red-500 focus:border-red-500"
onChange={(date) => setMonthYearFilter(date)}
dateFormat="MM | yyyy"
placeholderText={t("selectYear", {
defaultValue: "Select Year",
})}
showMonthYearPicker
/>
</div>
<div>
<label className="block text-sm font-medium text-gray-700 dark:text-white">
{t("date", { defaultValue: "Date" })}
</label>
<div className="flex flex-row justify justify-between gap-2">
<ReactDatePicker
selectsRange
className="mt-1 w-full border text-sm rounded-md py-2 px-3 focus:ring-red-500 focus:border-red-500"
startDate={dateRange[0]}
endDate={dateRange[1]}
onChange={(update) => {
setDateRange(update);
}}
placeholderText={t("selectDate", {
defaultValue: "Select Date",
})}
onCalendarClose={() => setCalenderState(!calenderState)}
/>
<div className="flex items-center">
{handleClose ? (
<Icon
icon="carbon:close-filled"
onClick={handleDeleteDate}
width="20"
inline
color="#216ba5"
/>
) : (
""
)}
</div>
</div>
</div>
<div>
<h3 className="text-sm font-medium text-gray-700 dark:text-white">
{t("categories", { defaultValue: "Categories" })}
</h3>
<ul className="mt-2 space-y-2">
{categories.map((category: any) => (
<li key={category?.id}>
<label
className="inline-flex items-center"
htmlFor={`${category.id}`}
>
<Checkbox
id={`${category.id}`}
value={category.id}
checked={categoryFilter.includes(String(category.id))}
onCheckedChange={(e) =>
handleCategoryFilter(Boolean(e), category.id)
}
/>
<span className="ml-2 text-gray-700 dark:text-white">
{category?.name}
</span>
</label>
</li>
))}
<div className="mt-4 flex gap-2 justify-center items-center">
<button
onClick={() =>
setCategoryPage((prev) => Math.max(prev - 1, 1))
}
disabled={categoryPage === 1}
className="px-3 py-1 border rounded disabled:opacity-50"
>
<svg
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
viewBox="0 0 24 24"
>
<path
fill="currentColor"
d="m13.15 16.15l-3.625-3.625q-.125-.125-.175-.25T9.3 12t.05-.275t.175-.25L13.15 7.85q.075-.075.163-.112T13.5 7.7q.2 0 .35.138T14 8.2v7.6q0 .225-.15.363t-.35.137q-.05 0-.35-.15"
/>
</svg>
</button>
{Array.from({ length: categoryTotalPages }, (_, i) => (
<button
key={i}
onClick={() => setCategoryPage(i + 1)}
className={`px-3 py-1 border rounded ${
categoryPage === i + 1
? "bg-[#bb3523] text-white"
: ""
}`}
>
{i + 1}
</button>
))}
<button
onClick={() =>
setCategoryPage((prev) =>
Math.min(prev + 1, categoryTotalPages)
)
}
disabled={categoryPage === categoryTotalPages}
className="px-3 py-1 border rounded disabled:opacity-50"
>
<svg
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
viewBox="0 0 24 24"
>
<path
fill="currentColor"
d="M10.5 16.3q-.2 0-.35-.137T10 15.8V8.2q0-.225.15-.362t.35-.138q.05 0 .35.15l3.625 3.625q.125.125.175.25t.05.275t-.05.275t-.175.25L10.85 16.15q-.075.075-.162.113t-.188.037"
/>
</svg>
</button>
</div>
</ul>
</div>
{/* Garis */}
<div className="border-t border-black my-4 dark:border-white"></div>
{/* Garis */}
<div>
<h3 className="text-sm font-medium text-gray-700 dark:text-white">
Format
</h3>
<ul className="mt-2 space-y-2">
<li>
<label className="inline-flex items-center">
<Checkbox
id="png"
value="png"
checked={formatFilter.includes("png")}
onCheckedChange={(e) =>
handleFormatFilter(Boolean(e), "png")
}
/>
<span className="ml-2 text-gray-700 dark:text-white">
PNG
</span>
</label>
</li>
<li>
<label className="inline-flex items-center">
<Checkbox
id="jpeg"
value="jpeg"
checked={formatFilter.includes("jpeg")}
onCheckedChange={(e) =>
handleFormatFilter(Boolean(e), "jpeg")
}
/>
<span className="ml-2 text-gray-700 dark:text-white">
JPEG
</span>
</label>
</li>
<li>
<label className="inline-flex items-center">
<Checkbox
id="jpg"
value="jpg"
checked={formatFilter.includes("jpg")}
onCheckedChange={(e) =>
handleFormatFilter(Boolean(e), "jpg")
}
/>
<span className="ml-2 text-gray-700 dark:text-white">
JPG
</span>
</label>
</li>
</ul>
</div>
<div className="border-t border-black dark:border-white my-4"></div>
<div className="text-center">
<a
onClick={cleanCheckbox}
className="text-[#bb3523] cursor-pointer"
>
<b>Reset Filter</b>
</a>
</div>
</div>
</div>
)}
{/* Konten Kanan */}
<div className="w-full pl-4 pr-4 lg:pr-16 pb-4 overflow-x-hidden">
<div className="w-full">
<div className="flex flex-col items-end mb-4">
<h2 className="text-lg font-semibold">
{t("sortBy", { defaultValue: "Sort By" })}
</h2>
<select
defaultValue={sortBy == "popular" ? "terpopuler" : "terbaru"}
onChange={(e) => handleSorting(e)}
className="border rounded-md py-2 px-3 focus:ring-red-500 focus:border-red-500"
>
<option value="latest">
{t("latest", { defaultValue: "Latest" })}
</option>
<option value="popular">
{t("mostPopular", { defaultValue: "Most Popular" })}
</option>
</select>
</div>
<div className="flex flex-col gap-4 w-full">
<FilterImageComponent
categoryFilter={categoryFilter}
sortByOpt={sortByOpt}
startDateString={startDateString}
endDateString={endDateString}
monthYearFilter={monthYearFilter}
/>
<FilterVideoComponent
categoryFilter={categoryFilter}
sortByOpt={sortByOpt}
startDateString={startDateString}
endDateString={endDateString}
monthYearFilter={monthYearFilter}
/>
<FilterDocumentComponent
categoryFilter={categoryFilter}
sortByOpt={sortByOpt}
startDateString={startDateString}
endDateString={endDateString}
monthYearFilter={monthYearFilter}
/>
<FilterAudioComponent
categoryFilter={categoryFilter}
sortByOpt={sortByOpt}
startDateString={startDateString}
endDateString={endDateString}
monthYearFilter={monthYearFilter}
/>
</div>
</div>
</div>
</div>
</div>
);
}

View File

@ -0,0 +1,14 @@
import Footer from "@/components/landing-page/footer";
import Navbar from "@/components/landing-page/navbar";
const layout = async ({ children }: { children: React.ReactNode }) => {
return (
<>
<Navbar />
{children}
<Footer />
</>
);
};
export default layout;

View File

@ -295,7 +295,6 @@ const Schedule = (props: any) => {
};
temp.push(now);
}
console.log("QQQQQ", temp);
setCity(temp);
}
fetchPoldaPolres();
@ -341,7 +340,6 @@ const Schedule = (props: any) => {
curr.setDate(curr.getDate() + 1);
}
console.log("Change Date :", dateListTemp);
setDateList(dateListTemp);
setDateAWeek(dateListTemp);
}
@ -431,7 +429,6 @@ const Schedule = (props: any) => {
const response = await detailSchedule(itemFound?.id);
setDetail(response?.data?.data);
setContent(response?.data?.data?.files);
console.log("item Found", itemFound);
close();
setOpenDialog(true);
};
@ -483,7 +480,6 @@ const Schedule = (props: any) => {
};
const deleteFilterhandler = (filterId: any) => {
console.log("hapus", filterId);
const deletedReg = regionName.filter((list: any) => list.id !== filterId);
const filtered = regionFilter.filter((list: any) => list !== filterId);

View File

@ -328,7 +328,7 @@ const FilterPage = () => {
setCategoryFilter(filter);
router.push(`?category=${filter.join("&")}`);
};
const handleFormatFilter = (e: boolean, id: string) => {
let filter = [...formatFilter];
@ -505,10 +505,16 @@ const FilterPage = () => {
<p>
{" "}
{t("video", { defaultValue: "Video" })}&nbsp;
{">"} <span className="font-bold">{t("allVideo", { defaultValue: "All Video" })}</span>
{">"}{" "}
<span className="font-bold">
{t("allVideo", { defaultValue: "All Video" })}
</span>
</p>
<p className="font-bold">|</p>
<p>{`${t("thereIs", { defaultValue: "There Is" })} ${totalContent} ${t("downloadableVideo", { defaultValue: "Downloadable Video" })}`}</p>
<p>{`${t("thereIs", { defaultValue: "There Is" })} ${totalContent} ${t(
"downloadableVideo",
{ defaultValue: "Downloadable Video" }
)}`}</p>
</div>
{/* Left */}
@ -548,7 +554,9 @@ const FilterPage = () => {
className="mt-1 w-full text-xs border rounded-md py-2 px-3 focus:ring-red-500 focus:border-red-500"
onChange={(date) => setMonthYearFilter(date)}
dateFormat="MM | yyyy"
placeholderText={t("selectYear", { defaultValue: "Select Year" })}
placeholderText={t("selectYear", {
defaultValue: "Select Year",
})}
showMonthYearPicker
/>
</div>
@ -566,7 +574,9 @@ const FilterPage = () => {
onChange={(update) => {
setDateRange(update);
}}
placeholderText={t("selectDate", { defaultValue: "Select Date" })}
placeholderText={t("selectDate", {
defaultValue: "Select Date",
})}
onCalendarClose={() => setCalenderState(!calenderState)}
/>
<div className="flex items-center">
@ -610,7 +620,7 @@ const FilterPage = () => {
</label>
</li>
))}
{/* <div className="mt-4 flex gap-2 justify-center items-center">
<div className="mt-4 flex gap-2 justify-center items-center">
<button
onClick={() =>
setCategoryPage((prev) => Math.max(prev - 1, 1))
@ -664,7 +674,7 @@ const FilterPage = () => {
/>
</svg>
</button>
</div> */}
</div>
</ul>
</div>
{/* Garis */}
@ -769,14 +779,20 @@ const FilterPage = () => {
<Reveal>
<div className="w-full">
<div className="flex flex-col items-end mb-4">
<h2 className="text-lg font-semibold">{t("sortBy", { defaultValue: "Sort By" })}</h2>
<h2 className="text-lg font-semibold">
{t("sortBy", { defaultValue: "Sort By" })}
</h2>
<select
defaultValue={sortBy == "popular" ? "terpopuler" : "terbaru"}
onChange={(e) => handleSorting(e)}
className="border rounded-md py-2 px-3 focus:ring-red-500 focus:border-red-500"
>
<option value="latest">{t("latest", { defaultValue: "Latest" })}</option>
<option value="popular">{t("mostPopular", { defaultValue: "Most Popular" })}</option>
<option value="latest">
{t("latest", { defaultValue: "Latest" })}
</option>
<option value="popular">
{t("mostPopular", { defaultValue: "Most Popular" })}
</option>
</select>
</div>

View File

@ -15,6 +15,8 @@ import Coverage from "./coverage";
import Division from "./division";
import { useTranslations } from "next-intl";
import { useParams } from "next/navigation";
import { useRouter } from "@/i18n/routing";
import { Icon } from "../ui/icon";
const AreaCoverageWorkUnits = () => {
const [openPolda, setOpenPolda] = useState(false);
@ -22,6 +24,16 @@ const AreaCoverageWorkUnits = () => {
const t = useTranslations("LandingPage");
const params = useParams();
const locale = params?.locale;
const [search, setSearch] = useState("");
const router = useRouter();
const poldaName = params?.polda_name;
const satkerName = params?.satker_name;
let prefixPath = poldaName
? `/polda/${poldaName}`
: satkerName
? `/satker/${satkerName}`
: "";
useEffect(() => {
if (openPolda || openSatker) {
@ -42,9 +54,28 @@ const AreaCoverageWorkUnits = () => {
<h2 className="text-start text-lg md:text-xl font-bold text-[#bb3523] border-b-2 border-[#bb3523] mb-4 uppercase">
{t("areaCoverage", { defaultValue: "Area Coverage" })}
</h2>
{/* search */}
<div className="flex flex-row gap-2 mb-2">
<input
type="text"
placeholder={t("searchCoverageHere", {
defaultValue: "Search Coverage Here",
})}
className="w-full py-4 px-2 text-sm text-gray-700 dark:text-gray-100 focus:outline-none rounded-md"
onChange={(e) => setSearch(e.target.value)}
/>
<button
onClick={() =>
router.push(prefixPath + `/regional/filter?title=${search}`)
}
className="flex justify-center items-center px-6 w-full lg:w-[20%] py-4 bg-[#bb3523] gap-2 text-white rounded-lg hover:bg-red-700 text-[14px]"
>
{t("searchCoverage", { defaultValue: "Search Coverage" })}
<Icon icon="ri:arrow-right-s-line" fontSize={20} />
</button>
</div>
<div className="flex flex-col justify-center lg:flex-row gap-8 ">
{/* POLDA */}
<Dialog open={openPolda} onOpenChange={setOpenPolda}>
<DialogTrigger asChild>
<button
@ -59,7 +90,9 @@ const AreaCoverageWorkUnits = () => {
src="/assets/indo.png"
className="h-32 w-32 group-hover:scale-110 group-hover:border-[#bb3523] "
/>
<p className="text-base font-bold">{t("regionalPolice", { defaultValue: "Regional Police" })}</p>
<p className="text-base font-bold">
{t("regionalPolice", { defaultValue: "Regional Police" })}
</p>
</button>
</DialogTrigger>
<DialogContent
@ -69,7 +102,9 @@ const AreaCoverageWorkUnits = () => {
>
<DialogHeader className="flex flex-col justify-center">
<DialogTitle>
<p className="text-center">{t("regionalPolice", { defaultValue: "Regional Police" })}</p>
<p className="text-center">
{t("regionalPolice", { defaultValue: "Regional Police" })}
</p>
</DialogTitle>
<DialogTitle>
<div className="h-1 w-[150px] bg-[#bb3523] mx-auto mb-6 rounded"></div>
@ -89,7 +124,6 @@ const AreaCoverageWorkUnits = () => {
</Dialog>
{/* SATKER */}
<Dialog open={openSatker} onOpenChange={setOpenSatker}>
<DialogTrigger asChild>
<button className="flex flex-col gap-2 justify-center items-center shadow-lg group rounded-xl py-5 w-full border-2 border-transparent hover:border-[#bb3523] transition-all duration-300">
@ -101,13 +135,17 @@ const AreaCoverageWorkUnits = () => {
src="/assets/logo-polri.png"
className="h-32 w-32 group-hover:scale-110 group-hover:border-[#bb3523] transition-transform duration-300"
/>
<p className="text-base font-bold">{t("policeDivision", { defaultValue: "Police Division" })}</p>
<p className="text-base font-bold">
{t("policeDivision", { defaultValue: "Police Division" })}
</p>
</button>
</DialogTrigger>
<DialogContent size="md" data-lenis-prevent>
<DialogHeader className="flex flex-col justify-center">
<DialogTitle>
<p className="text-center">{t("policeDivision", { defaultValue: "Police Division" })}</p>
<p className="text-center">
{t("policeDivision", { defaultValue: "Police Division" })}
</p>
</DialogTitle>
<DialogTitle>
<div className="h-1 w-[150px] bg-[#bb3523] mx-auto mb-6 rounded"></div>

View File

@ -8,7 +8,7 @@ import {
} from "@/components/ui/carousel";
import { close, loading } from "@/config/swal";
import { Link, usePathname } from "@/i18n/routing";
import { listData } from "@/service/landing/landing";
import { listData, listDataRegional } from "@/service/landing/landing";
import { formatDateToIndonesian, getOnlyMonthAndYear } from "@/utils/globals";
import { Icon } from "@iconify/react/dist/iconify.js";
import { pages } from "next/dist/build/templates/app-page";
@ -42,6 +42,50 @@ export default function FilterAudioComponent(props: {
const categorie = searchParams?.get("category");
const group = searchParams?.get("group");
const [totalContent, setTotalContent] = useState();
const isRegional = group || asPath.includes("/polda/");
const searchType = isRegional ? "regional" : "filter";
useEffect(() => {
if (searchType === "regional") {
getDataRegional();
} else {
getDataAll();
}
}, [
title,
categoryFilter,
categorie,
group,
startDateString,
endDateString,
monthYearFilter,
sortByOpt,
]);
async function getDataRegional() {
let startDateFilter = startDateString ? startDateString : "";
let endDateFilter = endDateString ? endDateString : "";
let monthFilter = monthYearFilter ? monthYearFilter : "";
const response = await listDataRegional(
"4",
"",
"",
"",
"",
startDateFilter,
endDateFilter,
monthFilter
? getOnlyMonthAndYear(monthFilter)?.split("/")[0]?.replace("0", "")
: "",
monthFilter ? getOnlyMonthAndYear(monthFilter)?.split("/")[1] : ""
);
const data = response?.data?.data;
const contentData = data?.content;
setNewContent(contentData);
setTotalData(data?.totalElements);
// setLoading(false);
}
useEffect(() => {
getDataAll();
@ -137,7 +181,7 @@ export default function FilterAudioComponent(props: {
return newContent?.length > 0 ? (
<div className="flex flex-col gap-3">
<p>{`Audio(${totalContent})`}</p>
<p>{`Audio (${totalContent})`}</p>
<Carousel className="w-full max-w-7xl mx-auto">
<CarouselContent>
{newContent?.map((audio: any) => (
@ -163,7 +207,7 @@ export default function FilterAudioComponent(props: {
</div>
<div className="flex flex-col flex-1">
<div className="text-gray-500 dark:text-gray-400 flex flex-row text-sm">
<div className="text-gray-500 dark:text-gray-400 flex flex-row text-sm items-center">
{formatDateToIndonesian(new Date(audio?.createdAt))}{" "}
{audio?.timezone ? audio?.timezone : "WIB"} | &nbsp;
<Icon icon="formkit:eye" width="15" height="15" />
@ -181,6 +225,24 @@ export default function FilterAudioComponent(props: {
<CarouselPrevious className="-ml-0" />
<CarouselNext className="-mr-0" />
</Carousel>
<div className="flex justify-center mt-1 mb-6">
<Link
href={
`${
asPath.includes("/polda/")
? `/${asPath.split("/")[1]}/${asPath.split("/")[2]}`
: ""
}/audio/` +
`${group ? "regional?" : "filter?"}` +
`sortBy=${sortBy === "popular" ? "popular" : "latest"}` +
`${title ? `&title=${title.toLowerCase()}` : ""}` +
`${categorie ? `&category=${categorie}` : ""}`
}
className="border border-red-500 text-red-500 hover:bg-red-500 hover:text-white transition-colors duration-200 px-4 py-2 rounded-md text-sm"
>
Lihat Semua
</Link>
</div>
</div>
) : (
""

View File

@ -8,7 +8,7 @@ import {
} from "@/components/ui/carousel";
import { close, loading } from "@/config/swal";
import { Link, usePathname } from "@/i18n/routing";
import { listData } from "@/service/landing/landing";
import { listData, listDataRegional } from "@/service/landing/landing";
import { formatDateToIndonesian, getOnlyMonthAndYear } from "@/utils/globals";
import { Icon } from "@iconify/react/dist/iconify.js";
import { pages } from "next/dist/build/templates/app-page";
@ -43,8 +43,15 @@ export default function FilterDocumentComponent(props: {
const group = searchParams?.get("group");
const [totalContent, setTotalContent] = useState();
const isRegional = group || asPath.includes("/polda/");
const searchType = isRegional ? "regional" : "filter";
useEffect(() => {
getDataAll();
if (searchType === "regional") {
getDataRegional();
} else {
getDataAll();
}
}, [
title,
categoryFilter,
@ -56,6 +63,31 @@ export default function FilterDocumentComponent(props: {
sortByOpt,
]);
async function getDataRegional() {
let startDateFilter = startDateString ? startDateString : "";
let endDateFilter = endDateString ? endDateString : "";
let monthFilter = monthYearFilter ? monthYearFilter : "";
const response = await listDataRegional(
"3",
"",
"",
"",
"",
startDateFilter,
endDateFilter,
monthFilter
? getOnlyMonthAndYear(monthFilter)?.split("/")[0]?.replace("0", "")
: "",
monthFilter ? getOnlyMonthAndYear(monthFilter)?.split("/")[1] : ""
);
const data = response?.data?.data;
const contentData = data?.content;
setNewContent(contentData);
setTotalData(data?.totalElements);
// setLoading(false);
}
async function getDataAll() {
if (asPath?.includes("/polda/") == true) {
if (asPath?.split("/")[2] !== "[polda_name]") {
@ -137,7 +169,7 @@ export default function FilterDocumentComponent(props: {
return newContent?.length > 0 ? (
<div className="flex flex-col gap-3">
<p>{`Document(${totalContent})`}</p>
<p>{`Document (${totalContent})`}</p>
<Carousel className="w-full max-w-7xl mx-auto">
<CarouselContent>
{newContent?.map((text: any) => (
@ -164,12 +196,12 @@ export default function FilterDocumentComponent(props: {
<div className="flex w-full pr-10 flex-col flex-1">
<div className="text-gray-500 dark:text-gray-400 flex flex-row items-center text-xs gap-0 lg:gap-1 mt-1 lg:text-sm">
{formatDateToIndonesian(new Date(text?.createdAt))}
{text?.timezone ? text?.timezone : "WIB"}|
{formatDateToIndonesian(new Date(text?.createdAt))}&nbsp;
{text?.timezone ? text?.timezone : "WIB"}&nbsp;|
<Icon icon="formkit:eye" width="15" height="15" />
{text?.clickCount}
</div>
<div className="font-semibold text-gray-900 dark:text-white mt-1 text-sm h-5 hover:h-auto truncate hover:whitespace-normal hover:overflow-visible ">
<div className="font-semibold tet-gray-900 dark:text-white mt-1 text-sm h-5 hover:h-auto truncate hover:whitespace-normal hover:overflow-visible ">
{text?.title}
</div>
<div className="flex gap-2 items-center text-sm text-red-500 dark:text-red-500">
@ -195,6 +227,22 @@ export default function FilterDocumentComponent(props: {
<CarouselPrevious className="-ml-0" />
<CarouselNext className="-mr-0" />
</Carousel>
<div className="flex justify-center mt-1 mb-6">
<Link
href={`${
asPath.includes("/polda/")
? `/${asPath.split("/")[1]}/${asPath.split("/")[2]}`
: ""
}/document/${group ? "filter" : "regional"}?sortBy=${
sortBy || "latest"
}${title ? `&title=${title.toLowerCase()}` : ""}${
categorie ? `&category=${categorie}` : ""
}${group ? `&group=${group}` : ""}`}
className="border border-red-500 text-red-500 hover:bg-red-500 hover:text-white transition-colors duration-200 px-4 py-2 rounded-md text-sm"
>
Lihat Semua
</Link>
</div>
</div>
) : (
""

View File

@ -8,7 +8,7 @@ import {
} from "@/components/ui/carousel";
import { close, loading } from "@/config/swal";
import { Link, usePathname } from "@/i18n/routing";
import { listData } from "@/service/landing/landing";
import { listData, listDataRegional } from "@/service/landing/landing";
import { formatDateToIndonesian, getOnlyMonthAndYear } from "@/utils/globals";
import { Icon } from "@iconify/react/dist/iconify.js";
import { pages } from "next/dist/build/templates/app-page";
@ -42,8 +42,15 @@ export default function FilterImageComponent(props: {
const group = searchParams?.get("group");
const [totalContent, setTotalContent] = useState();
const isRegional = group || asPath.includes("/polda/");
const searchType = isRegional ? "regional" : "filter";
useEffect(() => {
getDataAll();
if (searchType === "regional") {
getDataRegional();
} else {
getDataAll();
}
}, [
title,
categoryFilter,
@ -134,10 +141,48 @@ export default function FilterImageComponent(props: {
}
}
async function getDataRegional() {
let startDateFilter = startDateString ? startDateString : "";
let endDateFilter = endDateString ? endDateString : "";
let monthFilter = monthYearFilter ? monthYearFilter : "";
const response = await listDataRegional(
"1",
"",
"",
"",
"",
startDateFilter,
endDateFilter,
monthFilter
? getOnlyMonthAndYear(monthFilter)?.split("/")[0]?.replace("0", "")
: "",
monthFilter ? getOnlyMonthAndYear(monthFilter)?.split("/")[1] : ""
);
const data = response?.data?.data;
const contentData = data?.content;
setNewContent(contentData);
setTotalData(data?.totalElements);
// setLoading(false);
}
const basePath = asPath.includes("/polda/")
? `/${asPath.split("/")[1]}/${asPath.split("/")[2]}`
: "";
const type = group || asPath.includes("/polda/") ? "regional?" : "filter?";
const sort = sortByOpt === "popular" ? "sortBy=popular" : "sortBy=latest";
const titleParam = title ? `&title=${title?.toLowerCase()}` : "";
const categoryParam = categorie ? `&category=${categorie}` : "";
const fullQuery = `${type}${sort}${titleParam}${categoryParam}${
startDateString ? `&startDate=${startDateString}` : ""
}${endDateString ? `&endDate=${endDateString}` : ""}`;
const href = `${basePath}/image/${fullQuery}`;
return newContent?.length > 0 ? (
<div className="flex flex-col gap-3 w-full">
<p>{`Foto(${totalContent})`}</p>
<Carousel className="w-full max-w-7xl mx-auto">
<p>{`Foto (${totalContent})`}</p>
<Carousel className="w-full max-w-7xl mx-auto mt-3">
<CarouselContent>
{newContent?.map((image: any) => (
<CarouselItem key={image?.id} className="md:basis-1/2 lg:basis-1/3">
@ -167,6 +212,14 @@ export default function FilterImageComponent(props: {
<CarouselPrevious className="-ml-0" />
<CarouselNext className="-mr-0" />
</Carousel>
<div className="flex justify-center mt-1 mb-6">
<Link
href={href}
className="border border-red-500 text-red-500 hover:bg-red-500 text-sm hover:text-white px-4 py-2 rounded transition duration-200"
>
Lihat Semua
</Link>
</div>
</div>
) : (
""

View File

@ -8,7 +8,7 @@ import {
} from "@/components/ui/carousel";
import { close, loading } from "@/config/swal";
import { Link, usePathname } from "@/i18n/routing";
import { listData } from "@/service/landing/landing";
import { listData, listDataRegional } from "@/service/landing/landing";
import { formatDateToIndonesian, getOnlyMonthAndYear } from "@/utils/globals";
import { Icon } from "@iconify/react/dist/iconify.js";
import { pages } from "next/dist/build/templates/app-page";
@ -43,8 +43,15 @@ export default function FilterVideoComponent(props: {
const group = searchParams?.get("group");
const [totalContent, setTotalContent] = useState();
const isRegional = group || asPath.includes("/polda/");
const searchType = isRegional ? "regional" : "filter";
useEffect(() => {
getDataAll();
if (searchType === "regional") {
getDataRegional();
} else {
getDataAll();
}
}, [
title,
categoryFilter,
@ -56,6 +63,31 @@ export default function FilterVideoComponent(props: {
sortByOpt,
]);
async function getDataRegional() {
let startDateFilter = startDateString ? startDateString : "";
let endDateFilter = endDateString ? endDateString : "";
let monthFilter = monthYearFilter ? monthYearFilter : "";
const response = await listDataRegional(
"2",
"",
"",
"",
"",
startDateFilter,
endDateFilter,
monthFilter
? getOnlyMonthAndYear(monthFilter)?.split("/")[0]?.replace("0", "")
: "",
monthFilter ? getOnlyMonthAndYear(monthFilter)?.split("/")[1] : ""
);
const data = response?.data?.data;
const contentData = data?.content;
setNewContent(contentData);
setTotalData(data?.totalElements);
// setLoading(false);
}
async function getDataAll() {
if (asPath?.includes("/polda/") == true) {
if (asPath?.split("/")[2] !== "[polda_name]") {
@ -137,7 +169,7 @@ export default function FilterVideoComponent(props: {
return newContent?.length > 0 ? (
<div className="flex flex-col gap-3">
<p>{`Audio Visual(${totalContent})`}</p>
<p>{`Audio Visual (${totalContent})`}</p>
<Carousel className="w-full max-w-7xl mx-auto">
<CarouselContent>
{newContent?.map((video: any) => (
@ -168,6 +200,32 @@ export default function FilterVideoComponent(props: {
<CarouselPrevious className="-ml-0" />
<CarouselNext className="-mr-0" />
</Carousel>
<div className="flex justify-center mt-1 mb-6">
<Link
href={`${
asPath.includes("/polda/")
? `/${asPath.split("/")[1]}/${asPath.split("/")[2]}`
: ""
}/video/${
group || asPath.includes("/polda/") ? "regional?" : "filter?"
}${sortByOpt === "popular" ? "sortBy=popular" : "sortBy=latest"}${
title ? `&title=${title.toLowerCase()}` : ""
}${categorie ? `&category=${categorie}` : ""}${
startDateString ? `&startDate=${startDateString}` : ""
}${endDateString ? `&endDate=${endDateString}` : ""}${
monthYearFilter
? `&month=${getOnlyMonthAndYear(monthYearFilter)?.split("/")[0]}`
: ""
}${
monthYearFilter
? `&year=${getOnlyMonthAndYear(monthYearFilter)?.split("/")[1]}`
: ""
}`}
className="border border-red-500 text-red-500 hover:bg-red-500 hover:text-white px-4 py-2 text-sm rounded transition duration-200"
>
Lihat Semua
</Link>
</div>
</div>
) : (
""

View File

@ -86,7 +86,7 @@ const ScrollableContent = () => {
<span className="text-[#c03724] dark:text-white">
&nbsp;{t("download", { defaultValue: "Download" })}&nbsp;
{t("coverage", { defaultValue: "Coverage" })}
</span>{" "}
</span>
</h1>
<div className="w-[10%] h-1 bg-[#bb3523] mt-2"></div>
<div className="w-full h-1 bg-[#bb3523] mx-auto"></div>

View File

@ -27,7 +27,6 @@ const SearchSection = () => {
const t = useTranslations("LandingPage");
const { theme } = useTheme();
// Determine background image based on theme
const getBackgroundImage = () => {
if (theme === "dark") {
return "url('/assets/background-dark.jpg')";