From e0bb77e7afb4dafced3be0c400a87e59776d42f9 Mon Sep 17 00:00:00 2001 From: Sabda Yagra Date: Mon, 21 Jul 2025 22:23:30 +0700 Subject: [PATCH] fix: fixing filter and add thumbnail in admin update --- .../[polda_name]/video/detail/[slug]/page.tsx | 2 +- app/[locale]/(public)/all/filter/page.tsx | 501 ++++++++++-------- app/[locale]/(public)/audio/filter/page.tsx | 37 +- .../(public)/document/filter/page.tsx | 7 +- app/[locale]/(public)/image/filter/page.tsx | 44 +- app/[locale]/(public)/video/filter/page.tsx | 7 +- components/form/content/video-update-form.tsx | 99 +++- .../filter-all/audio-filter-card.tsx | 12 +- .../filter-all/document-filter-card.tsx | 4 +- .../filter-all/image-filter-card.tsx | 4 +- .../filter-all/video-filter-card.tsx | 4 +- .../landing-page/search-section-new.tsx | 2 - components/main/audio-detail.tsx | 2 +- messages/en.json | 11 +- messages/in.json | 3 + 15 files changed, 435 insertions(+), 304 deletions(-) diff --git a/app/[locale]/(public)/(polda)/polda/[polda_name]/video/detail/[slug]/page.tsx b/app/[locale]/(public)/(polda)/polda/[polda_name]/video/detail/[slug]/page.tsx index dc418284..3be24ad4 100644 --- a/app/[locale]/(public)/(polda)/polda/[polda_name]/video/detail/[slug]/page.tsx +++ b/app/[locale]/(public)/(polda)/polda/[polda_name]/video/detail/[slug]/page.tsx @@ -134,7 +134,7 @@ const DetailVideo = () => { const handleDownload = () => { if (downloadProgress === 0) { if (!userId) { - router.push("/auth/login"); + router.push("/auth"); } else { sendActivityLog(2); sendActivityLog(3); diff --git a/app/[locale]/(public)/all/filter/page.tsx b/app/[locale]/(public)/all/filter/page.tsx index 4554bb66..63861bdf 100644 --- a/app/[locale]/(public)/all/filter/page.tsx +++ b/app/[locale]/(public)/all/filter/page.tsx @@ -34,6 +34,7 @@ import FilterImageComponent from "@/components/landing-page/filter-all/image-fil 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(); @@ -86,6 +87,8 @@ export default function FilterPage() { const [categories, setCategories] = useState([]); const [userLevels, setUserLevels] = useState([]); const [contentAll, setContentAll] = useState([]); + const t = useTranslations("FilterPage"); + const [isFilterOpen, setIsFilterOpen] = useState(true); // const [startDate, endDate] = dateRange; @@ -387,244 +390,314 @@ export default function FilterPage() { }; return ( -
- {/* Header */} - -
+
+
+

{t("content", { defaultValue: "Content" })}

+ {">"}

- {" "} - Konten {">"} Semua Konten + + {t("allContent", { defaultValue: "All Content" })} +

|

-

{`Hasil Pencarian ${title} `}

- {`Terdapat ${contentAll?.length} konten yang dapat diunduh`} +

{`${t("thereIs", { defaultValue: "There Is" })} ${totalContent} ${t( + "downloadableContent", + { defaultValue: "Downloadable ContentS" } + )}`}

{/* Left */} -
-
-

- - Filter -

-
-
-
- - setSearchTitle(e.target.value)} - onKeyUp={handleKeyUp} - onKeyDown={handleKeyDown} - type="text" - id="search" - placeholder="Cari judul..." - className="mt-1 w-full border rounded-md py-2 px-3 focus:ring-red-500 focus:border-red-500" - /> -
+
+
+ +
-
- - setMonthYearFilter(date)} - dateFormat="MM | yyyy" - placeholderText="Pilih Tahun dan Bulan" - showMonthYearPicker - /> -
- -
- -
- +

+ + Filter +

+
+
+
+ + 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" - startDate={dateRange[0]} - endDate={dateRange[1]} - onChange={(update) => { - setDateRange(update); - }} - placeholderText="Pilih Tanggal" - onCalendarClose={() => setCalenderState(!calenderState)} /> -
- {handleClose ? ( - - ) : ( - "" - )} +
+ +
+ + setMonthYearFilter(date)} + dateFormat="MM | yyyy" + placeholderText={t("selectYear", { + defaultValue: "Select Year", + })} + showMonthYearPicker + /> +
+ +
+ +
+ { + setDateRange(update); + }} + placeholderText={t("selectDate", { + defaultValue: "Select Date", + })} + onCalendarClose={() => setCalenderState(!calenderState)} + /> +
+ {handleClose ? ( + + ) : ( + "" + )} +
-
-
-

- Kategori -

-
    - {categories.map((category: any) => ( -
  • -
  • + +
  • +
  • + +
  • +
+
+
+
-
+ )} {/* Konten Kanan */} -
-
-

Urutkan berdasarkan

- -
-
- - - - +
+
+
+

+ {t("sortBy", { defaultValue: "Sort By" })} +

+ +
+
+ + + + +
diff --git a/app/[locale]/(public)/audio/filter/page.tsx b/app/[locale]/(public)/audio/filter/page.tsx index 7cff776e..84154821 100644 --- a/app/[locale]/(public)/audio/filter/page.tsx +++ b/app/[locale]/(public)/audio/filter/page.tsx @@ -488,10 +488,16 @@ const FilterPage = () => {

{" "} - Audio {">"} {t("allAudio", { defaultValue: "All Audio" })} + Audio {">"}{" "} + + {t("allAudio", { defaultValue: "All Audio" })} +

|

-

{`${t("thereIs", { defaultValue: "There Is" })} ${totalContent} ${t("downloadableAudio", { defaultValue: "Downloadable Audio" })}`}

+

{`${t("thereIs", { defaultValue: "There Is" })} ${totalContent} ${t( + "downloadableAudio", + { defaultValue: "Downloadable Audio" } + )}`}

{/* Left */} @@ -531,7 +537,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 />
@@ -549,7 +557,9 @@ const FilterPage = () => { onChange={(update) => { setDateRange(update); }} - placeholderText={t("searchDate", { defaultValue: "Search Date" })} + placeholderText={t("searchDate", { + defaultValue: "Search Date", + })} onCalendarClose={() => setCalenderState(!calenderState)} />
@@ -593,8 +603,7 @@ const FilterPage = () => { ))} -
- {/* Tombol Prev */} + {/*
- {/* Nomor Halaman */} {Array.from({ length: categoryTotalPages }, (_, i) => ( ))} - {/* Tombol Next */} -
+
*/}
{/* Garis */} @@ -709,14 +716,20 @@ const FilterPage = () => {
-

{t("sortBy", { defaultValue: "Sort By" })}

+

+ {t("sortBy", { defaultValue: "Sort By" })}{" "} +

diff --git a/app/[locale]/(public)/document/filter/page.tsx b/app/[locale]/(public)/document/filter/page.tsx index 9812149a..5f46875f 100644 --- a/app/[locale]/(public)/document/filter/page.tsx +++ b/app/[locale]/(public)/document/filter/page.tsx @@ -609,8 +609,7 @@ const FilterPage = () => { ))} -
- {/* Tombol Prev */} + {/*
- {/* Nomor Halaman */} {Array.from({ length: categoryTotalPages }, (_, i) => ( ))} - {/* Tombol Next */} -
+
*/}
{/* Garis */} diff --git a/app/[locale]/(public)/image/filter/page.tsx b/app/[locale]/(public)/image/filter/page.tsx index eacd0392..d08f2f67 100644 --- a/app/[locale]/(public)/image/filter/page.tsx +++ b/app/[locale]/(public)/image/filter/page.tsx @@ -485,24 +485,24 @@ const FilterPage = () => { clearTimeout(typingTimer); }; - const shimmer = (w: number, h: number) => ` - - - - - - - - - - - - `; + // const shimmer = (w: number, h: number) => ` + // + // + // + // + // + // + // + // + // + // + // + // `; - 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 (
@@ -517,8 +517,9 @@ const FilterPage = () => {

{`${t("thereIs", { defaultValue: "There Is" })} ${totalContent} ${t("downloadableImage", { defaultValue: "Downloadable Image" })}`}

- {/* Left */} +
+ {/* Left */}
- {/* Nomor Halaman */} {Array.from({ length: categoryTotalPages }, (_, i) => ( ))} - {/* Tombol Next */} -
+
*/}
{/* Garis */} diff --git a/app/[locale]/(public)/video/filter/page.tsx b/app/[locale]/(public)/video/filter/page.tsx index a0958c6e..fb4e5ea0 100644 --- a/app/[locale]/(public)/video/filter/page.tsx +++ b/app/[locale]/(public)/video/filter/page.tsx @@ -610,8 +610,7 @@ const FilterPage = () => { ))} -
- {/* Tombol Prev */} + {/*
- {/* Nomor Halaman */} {Array.from({ length: categoryTotalPages }, (_, i) => ( ))} - {/* Tombol Next */} -
+
*/}
{/* Garis */} diff --git a/components/form/content/video-update-form.tsx b/components/form/content/video-update-form.tsx index 0cea11d7..394876ad 100644 --- a/components/form/content/video-update-form.tsx +++ b/components/form/content/video-update-form.tsx @@ -106,25 +106,21 @@ const CustomEditor = dynamic( export default function FormVideoUpdate() { const MySwal = withReactContent(Swal); const router = useRouter(); - const { id } = useParams() as { id: string }; console.log(id); const editor = useRef(null); type VideoSchema = z.infer; - let progressInfo: any = []; let counterUpdateProgress = 0; const [progressList, setProgressList] = useState([]); let uploadPersen = 0; const [isStartUpload, setIsStartUpload] = useState(false); const [counterProgress, setCounterProgress] = useState(0); - const t = useTranslations("Form"); const [selectedFiles, setSelectedFiles] = useState([]); const taskId = Cookies.get("taskId"); const scheduleId = Cookies.get("scheduleId"); const scheduleType = Cookies.get("scheduleType"); - const [categories, setCategories] = useState([]); const [selectedCategory, setSelectedCategory] = useState(); const [tags, setTags] = useState([]); @@ -133,7 +129,6 @@ export default function FormVideoUpdate() { const [selectedPublishers, setSelectedPublishers] = useState([]); const [detailVideo, setDetailVideo] = useState([]); const [thumbsSwiper, setThumbsSwiper] = useState(null); - const [files, setFiles] = useState([]); const [selectedTarget, setSelectedTarget] = useState(""); const [unitSelection, setUnitSelection] = useState({ @@ -263,7 +258,7 @@ export default function FormVideoUpdate() { setDetail(details); setSelectedTarget(String(details.category.id)); - + // Set form values immediately and then again after a delay to ensure editor is ready setValue("title", details.title); setValue("description", details.htmlDescription); @@ -609,7 +604,7 @@ export default function FormVideoUpdate() { const fileList = files.map((file: any) => (
@@ -728,7 +723,9 @@ export default function FormVideoUpdate() {
-

{t("form-video", { defaultValue: "Form Video" })}

+

+ {t("form-video", { defaultValue: "Form Video" })} +

{/* Input Title */}
@@ -767,14 +764,18 @@ export default function FormVideoUpdate() { {/* Show the category from details if it doesn't exist in categories list */} - {detail && !categories.find(cat => String(cat.id) === String(detail.category.id)) && ( - - {detail.category.name} - - )} + {detail && + !categories.find( + (cat) => + String(cat.id) === String(detail.category.id) + ) && ( + + {detail.category.name} + + )} {categories.map((category) => (
- +
- + {/*
- {t("upload-file-video-max", { defaultValue: "Upload File Video Max" })} + {t("upload-file-video-max", { + defaultValue: "Upload File Video Max", + })}
@@ -829,7 +836,9 @@ export default function FormVideoUpdate() {
{fileList}
- +
@@ -869,7 +878,9 @@ export default function FormVideoUpdate() { rel="noopener noreferrer" className="text-blue-500 text-sm" > - {t("view-file", { defaultValue: "View File" })} + {t("view-file", { + defaultValue: "View File", + })}
@@ -887,7 +898,9 @@ export default function FormVideoUpdate() { } className="form-checkbox" /> - {t("all", { defaultValue: "All" })} + + {t("all", { defaultValue: "All" })} +
@@ -980,7 +993,7 @@ export default function FormVideoUpdate() { )}
-
+ {/*
+
*/} +
+ + { + const file = e.target.files?.[0]; + if (file) { + setSelectedFiles([file]); + } + }} + className="dark:border dark:border-gray-500 dark:rounded-lg" + /> + {selectedFiles.length > 0 ? ( + + Thumbnail Baru + + ) : ( + + Thumbnail Lama + + )}
+
@@ -1027,7 +1072,9 @@ export default function FormVideoUpdate() {
- + {options.map((option: Option) => (
-

{t("suggestion-box", { defaultValue: "Suggestion Box" })} (0)

+

+ {t("suggestion-box", { defaultValue: "Suggestion Box" })} (0) +

{t("information", { defaultValue: "Information" })}:

diff --git a/components/landing-page/filter-all/audio-filter-card.tsx b/components/landing-page/filter-all/audio-filter-card.tsx index 4361c252..4ba73c4b 100644 --- a/components/landing-page/filter-all/audio-filter-card.tsx +++ b/components/landing-page/filter-all/audio-filter-card.tsx @@ -145,7 +145,7 @@ export default function FilterAudioComponent(props: {
{formatDateToIndonesian(new Date(audio?.createdAt))}{" "} - {audio?.timezone ? audio?.timezone : "WIB"} |{" "} - {" "} - {audio?.clickCount}{" "} + {audio?.timezone ? audio?.timezone : "WIB"} |   + +  {audio?.clickCount}{" "}
{audio?.title} @@ -178,8 +178,8 @@ export default function FilterAudioComponent(props: { ))} - - + +
) : ( diff --git a/components/landing-page/filter-all/document-filter-card.tsx b/components/landing-page/filter-all/document-filter-card.tsx index 07b59bdb..2794f11d 100644 --- a/components/landing-page/filter-all/document-filter-card.tsx +++ b/components/landing-page/filter-all/document-filter-card.tsx @@ -192,8 +192,8 @@ export default function FilterDocumentComponent(props: { ))} - - + +
) : ( diff --git a/components/landing-page/filter-all/image-filter-card.tsx b/components/landing-page/filter-all/image-filter-card.tsx index c8c7672d..8346bfc3 100644 --- a/components/landing-page/filter-all/image-filter-card.tsx +++ b/components/landing-page/filter-all/image-filter-card.tsx @@ -164,8 +164,8 @@ export default function FilterImageComponent(props: { ))} - - + +
) : ( diff --git a/components/landing-page/filter-all/video-filter-card.tsx b/components/landing-page/filter-all/video-filter-card.tsx index ddf9c6fb..4b87dcf0 100644 --- a/components/landing-page/filter-all/video-filter-card.tsx +++ b/components/landing-page/filter-all/video-filter-card.tsx @@ -165,8 +165,8 @@ export default function FilterVideoComponent(props: { ))} - - + +
) : ( diff --git a/components/landing-page/search-section-new.tsx b/components/landing-page/search-section-new.tsx index 28ee2d5d..8e0540f7 100644 --- a/components/landing-page/search-section-new.tsx +++ b/components/landing-page/search-section-new.tsx @@ -1,6 +1,5 @@ import { useTranslations } from "next-intl"; import { useParams } from "next/navigation"; -import router from "next/router"; import React, { useEffect, useState } from "react"; import { Icon } from "@iconify/react/dist/iconify.js"; import { @@ -13,7 +12,6 @@ import { } from "../ui/select"; import Image from "next/image"; import { getHeroData } from "@/service/landing/landing"; -import { title } from "process"; import { htmlToString } from "@/utils/globals"; import { Link, useRouter } from "@/i18n/routing"; import { Button } from "../ui/button"; diff --git a/components/main/audio-detail.tsx b/components/main/audio-detail.tsx index 461c594d..437bfd29 100644 --- a/components/main/audio-detail.tsx +++ b/components/main/audio-detail.tsx @@ -298,7 +298,7 @@ const DetailAudio = () => { async function shareToEmail() { if (Number(userRoleId) < 1 || userRoleId == undefined) { - router.push("/auth/login"); + router.push("/auth"); } else { const data = { mediaUploadId: id?.split("-")?.[0], diff --git a/messages/en.json b/messages/en.json index 12d8c4f0..62c08573 100644 --- a/messages/en.json +++ b/messages/en.json @@ -641,6 +641,9 @@ "timeTable1": "TIMETABLE /" }, "FilterPage": { + "downloadableContent": "Downloadable Content", + "content": "Content", + "allContent":"All Content", "image": "Image", "video": "Video", "text": "Text", @@ -653,10 +656,10 @@ "searchTitle": "Find Title...", "monthYear": "Month and Year", "thereIs": "There is", - "downloadableImage": "downloadable image", - "downloadableVideo": "downloadable video", - "downloadableText": "downloadable text", - "downloadableAudio": "downloadable audio", + "downloadableImage": "Downloadable image", + "downloadableVideo": "Downloadable video", + "downloadableText": "Downloadable text", + "downloadableAudio": "Downloadable audio", "date": "Date", "selectYear": "Select Month and Year", "selectDate": "Select Date", diff --git a/messages/in.json b/messages/in.json index 2dc92af4..3f5031a1 100644 --- a/messages/in.json +++ b/messages/in.json @@ -642,6 +642,9 @@ "timeTable1": "JADWAL /" }, "FilterPage": { + "content": "Konten", + "downloadableContent": "artikel berisi konten yang dapat di unduh", + "allContent": "Semua Konten", "image": "Foto", "video": "Audio Visual", "text": "Teks",