diff --git a/app/[locale]/(protected)/contributor/agenda-setting/calender-view.tsx b/app/[locale]/(protected)/contributor/agenda-setting/calender-view.tsx index 2ce35a53..851d9a9b 100644 --- a/app/[locale]/(protected)/contributor/agenda-setting/calender-view.tsx +++ b/app/[locale]/(protected)/contributor/agenda-setting/calender-view.tsx @@ -32,15 +32,15 @@ const INITIAL_MONTH = dayjs().format("M"); export interface AgendaSettingsAPIResponse { id: number; title: string; + createdByName: string; description: string; agendaType: string; - startDate: string; // API mengembalikan tanggal dalam bentuk string + startDate: string; endDate: string; isActive: boolean; createdAt: string; updatedAt: string; createdById: number | null; - createdByName: string | null; } interface APIResponse { @@ -89,12 +89,15 @@ const CalendarView = ({ categories }: CalendarViewProps) => { const events = res?.data?.data.map((event: any) => ({ id: event.id.toString(), title: event.title, + createBy: "Mabes Polri - Approver", + createdByName: event.createdByName, start: new Date(event.startDate), end: new Date(event.endDate), - allDay: true, // Assuming all events are all-day by default + allDay: true, extendedProps: { - calendar: event.agendaType, // Map agendaType to the calendar category + calendar: event.agendaType, description: event.description, + createdByName: event.createdByName, }, })); @@ -130,25 +133,25 @@ const CalendarView = ({ categories }: CalendarViewProps) => { const month = (selectedMonth.getMonth() + 1).toString(); const typeFilter = ""; // Replace with your type filter logic if needed - const response = await getAgendaSettingsList( - year, - month, - typeFilter - ); + const response = await getAgendaSettingsList(year, month, typeFilter); if (response?.data && Array.isArray(response?.data)) { // Transform API data to match CalendarEvent type - const eventsFromAPI: CalendarEvent[] = response?.data?.map((item) => ({ - id: item.id.toString(), - title: item.title, - start: new Date(item.startDate), - end: new Date(item.endDate), - allDay: true, // Sesuaikan jika memang ada event sepanjang hari - extendedProps: { - calendar: item.agendaType, - description: item.description, - }, - })); + const eventsFromAPI: CalendarEvent[] = response?.data?.map( + (item) => ({ + id: item.id.toString(), + title: item.title, + createBy: "Mabes Polri - Approver", + createdByName: item.createdByName, + start: new Date(item.startDate), + end: new Date(item.endDate), + allDay: true, // Sesuaikan jika memang ada event sepanjang hari + extendedProps: { + calendar: item.agendaType, + description: item.description, + }, + }) + ); setApiEvents(eventsFromAPI); } else { @@ -235,6 +238,18 @@ const CalendarView = ({ categories }: CalendarViewProps) => { } }; + const renderEventContent = (eventInfo: any) => { + const { title } = eventInfo.event; + const { createdByName } = eventInfo.event.extendedProps; // Akses dari extendedProps + + return ( + <> +
{title}
Create By: {createdByName}
Simpan
Hapus
poldajabar
pilkadamai2024
{" "} - Audio {">"} Semua Audio + Audio {">"} {t("allAudio")}
|
{`Terdapat ${totalContent} artikel berisi Audio yang dapat diunduh`}
{`${t("thereIs")} ${totalContent} ${t("downloadableAudio")}`}
- +
{" "} - Teks {">"} Semua Teks + {t("text")} {">"} {t("allText")}
{`Terdapat ${totalContent} artikel berisi Teks yang dapat diunduh`}
{`${t("thereIs")} ${totalContent} ${t("downloadableText")}`}
{tag}
{" "} - Foto {">"} Semua Foto + {t("image")} {">"} {t("allImage")}
{`Terdapat ${totalContent} artikel berisi Foto yang dapat diunduh`}
{`${t("thereIs")} ${totalContent} ${t("downloadableImage")}`}
{indeksBottom?.date}
oleh - - {detailDataVideo?.uploadedBy?.userLevel?.name} - - | Diupdate pada {detailDataVideo?.updatedAt}{" "} - WIB | + {detailDataVideo?.uploadedBy?.userLevel?.name} + | Diupdate pada {detailDataVideo?.updatedAt} WIB | {detailDataVideo?.clickCount} @@ -252,9 +243,7 @@ const DetailVideo = () => { {/* Keterangan */}
Berikan Komentar
{" "} - Audio Visual {">"}{" "} - Semua Audio Visual + {t("video")} + {">"} {t("allVideo")}
{`Terdapat ${totalContent} artikel berisi Audio Visual yang dapat diunduh`}
{`${t("thereIs")} ${totalContent} ${t("downloadableVideo")}`}
Form Konten Foto
+ {errors.title.message} +
+ {errors.description.message} +
+ {errors.creatorName.message} +
Kotak Saran (0)
Keterangan:
{detail?.statusName}
handleArticleIdClick(id)} > {id} -
Loading Proses Data...
@@ -977,28 +1053,24 @@ export default function FormAudio() {
{detail?.status}
diff --git a/components/form/content/image-update-form.tsx b/components/form/content/image-update-form.tsx index 86c07442..98b75969 100644 --- a/components/form/content/image-update-form.tsx +++ b/components/form/content/image-update-form.tsx @@ -31,6 +31,7 @@ import { import { detailMedia } from "@/service/curated-content/curated-content"; import { Badge } from "@/components/ui/badge"; import { MailIcon } from "lucide-react"; +import dynamic from "next/dynamic"; const imageSchema = z.object({ title: z.string().min(1, { message: "Judul diperlukan" }), @@ -61,6 +62,13 @@ type Detail = { tags: string; }; +const CustomEditor = dynamic( + () => { + return import("@/components/editor/custom-editor"); + }, + { ssr: false } +); + export default function FormImageUpdate() { const MySwal = withReactContent(Swal); const router = useRouter(); @@ -81,6 +89,7 @@ export default function FormImageUpdate() { const [detail, setDetail] = useState(); const [refresh, setRefresh] = useState(false); const [selectedPublishers, setSelectedPublishers] = useState([]); + const [articleBody, setArticleBody] = useState(""); const [selectedTarget, setSelectedTarget] = useState(""); const [unitSelection, setUnitSelection] = useState({ @@ -305,11 +314,9 @@ export default function FormImageUpdate() { control={control} name="description" render={({ field: { onChange, value } }) => ( - )} /> diff --git a/components/form/content/spit-convert-form.tsx b/components/form/content/spit-convert-form.tsx index 324eeaf6..53800599 100644 --- a/components/form/content/spit-convert-form.tsx +++ b/components/form/content/spit-convert-form.tsx @@ -46,6 +46,7 @@ import { FreeMode, Navigation, Pagination, Thumbs } from "swiper/modules"; import { request } from "http"; import { generateDataArticle, getDetailArticle } from "@/service/content/ai"; import { getCookiesDecrypt } from "@/lib/utils"; +import dynamic from "next/dynamic"; const imageSchema = z.object({ contentTitle: z.string().min(1, { message: "Judul diperlukan" }), @@ -79,6 +80,18 @@ type Detail = { contentTag: string; }; +type Option = { + id: string; + label: string; +}; + +const CustomEditor = dynamic( + () => { + return import("@/components/editor/custom-editor"); + }, + { ssr: false } +); + export default function FormConvertSPIT() { const MySwal = withReactContent(Swal); const router = useRouter(); @@ -114,6 +127,7 @@ export default function FormConvertSPIT() { ); const [detailData, setDetailData] = useState(null); const [selectedFileType, setSelectedFileType] = useState("original"); + const [isLoadingData, setIsLoadingData] = useState(false); const [selectedTarget, setSelectedTarget] = useState(""); const [unitSelection, setUnitSelection] = useState({ @@ -122,6 +136,15 @@ export default function FormConvertSPIT() { polda: false, polres: false, }); + const [publishedFor, setPublishedFor] = useState([]); + + const options: Option[] = [ + { id: "all", label: "SEMUA" }, + { id: "5", label: "UMUM" }, + { id: "6", label: "JOURNALIS" }, + { id: "7", label: "POLRI" }, + { id: "8", label: "KSP" }, + ]; let fileTypeId = "1"; @@ -150,11 +173,11 @@ export default function FormConvertSPIT() { setSelectedFiles((prevImages) => prevImages.filter((_, i) => i !== index)); }; - const handleCheckboxChange = (id: number) => { - setSelectedPublishers((prev) => - prev.includes(id) ? prev.filter((item) => item !== id) : [...prev, id] - ); - }; + // const handleCheckboxChange = (id: number) => { + // setSelectedPublishers((prev) => + // prev.includes(id) ? prev.filter((item) => item !== id) : [...prev, id] + // ); + // }; useEffect(() => { async function initState() { @@ -246,6 +269,33 @@ export default function FormConvertSPIT() { })); }; + const handleCheckboxChange = (id: string): void => { + if (id === "all") { + if (publishedFor.includes("all")) { + // Uncheck all checkboxes + setPublishedFor([]); + } else { + // Select all checkboxes + setPublishedFor( + options + .filter((opt: any) => opt.id !== "all") + .map((opt: any) => opt.id) + ); + } + } else { + const updatedPublishedFor = publishedFor.includes(id) + ? publishedFor.filter((item) => item !== id) + : [...publishedFor, id]; + + // Remove "all" if any checkbox is unchecked + if (publishedFor.includes("all") && id !== "all") { + setPublishedFor(updatedPublishedFor.filter((item) => item !== "all")); + } else { + setPublishedFor(updatedPublishedFor); + } + } + }; + const save = async (data: any) => { const description = selectedFileType === "original" @@ -258,7 +308,7 @@ export default function FormConvertSPIT() { htmlDescription: description, tags: "siap", categoryId: selectedCategoryId, - publishedFor: "6", + publishedFor: publishedFor.join(","), creator: data.contentCreator, files: getPlacement(), }; @@ -330,11 +380,11 @@ export default function FormConvertSPIT() { setIsGeneratedArticle(true); setArticleIds((prevIds: string[]) => { - if (prevIds.length < 5) { + if (prevIds.length < 3) { return [...prevIds, newArticleId]; } else { const updatedIds = [...prevIds]; - updatedIds[4] = newArticleId; + updatedIds[2] = newArticleId; return updatedIds; } }); @@ -344,19 +394,41 @@ export default function FormConvertSPIT() { }; const handleArticleIdClick = async (id: string) => { - const res = await getDetailArticle(id); - const articleData = res?.data?.data; + setIsLoadingData(true); + let retryCount = 0; + const maxRetries = 20; - const cleanArticleBody = articleData?.articleBody?.replace( - /]*>/g, - "" - ); - const articleImagesData = articleData?.imagesUrl?.split(","); + try { + const waitForStatusUpdate = async () => { + while (retryCount < maxRetries) { + const res = await getDetailArticle(id); + const articleData = res?.data?.data; - setArticleBody(cleanArticleBody || ""); - setDetailData(articleData); - setSelectedArticleId(id); - // setArticleImages(articleImagesData || []); + if (articleData?.status === 2) { + return articleData; + } + + retryCount++; + await new Promise((resolve) => setTimeout(resolve, 5000)); + } + + throw new Error("Timeout: Artikel belum selesai diproses."); + }; + const articleData = await waitForStatusUpdate(); + const cleanArticleBody = articleData?.articleBody?.replace( + /]*>/g, + "" + ); + const articleImagesData = articleData?.imagesUrl?.split(","); + setArticleBody(cleanArticleBody || ""); + setDetailData(articleData); + setSelectedArticleId(id); + // setArticleImages(articleImagesData || []); + } catch (error) { + console.error("Error fetching article details:", error); + } finally { + setIsLoadingData(false); + } }; return ( @@ -434,11 +506,15 @@ export default function FormConvertSPIT() { control={control} name="contentDescription" render={({ field: { onChange, value } }) => ( - + )} /> @@ -462,30 +538,17 @@ export default function FormConvertSPIT() { {isGeneratedArticle && ( {articleIds.map((id: string, index: number) => ( - // handleArticleIdClick(id)} - // variant={"outline"} - // color="success" - // > - // {id} - // - handleArticleIdClick(id)} > {id} - + ))} )} @@ -500,14 +563,20 @@ export default function FormConvertSPIT() { ( - - )} + render={({ field: { onChange, value } }) => + isLoadingData ? ( + + + Loading Proses Data... + + + ) : ( + + ) + } /> {errors.contentRewriteDescription?.message && ( @@ -654,40 +723,24 @@ export default function FormConvertSPIT() {
+ Loading Proses Data... +
@@ -654,40 +723,24 @@ export default function FormConvertSPIT() {
+ Form detail Konten Teks +
@@ -977,28 +1052,24 @@ export default function FormTeks() {
+ Form Update Konten Teks +
+ Form Detail Konten Video +
@@ -1003,28 +1065,24 @@ export default function FormVideo() {
+ Form Update Konten Video +
Form Contest
+ {errors.scoringFormula.message} +
Recording... {timer} seconds remaining
Polda Tidak Ditemukan
{t("notFound")}
{`Foto(${totalContent})`}
- {formatDateToIndonesian(new Date(list?.createdAt))}{" "} - {list?.timezone ? list?.timezone : "WIB"}|{" "} - + {formatDateToIndonesian(new Date(list?.createdAt))} {list?.timezone ? list?.timezone : "WIB"}|{" "} + { {heroData?.map((item: any) => ( - + - - {item?.categoryName} - + {item?.categoryName} - - {textEllipsis(item?.title, 30)} - + {textEllipsis(item?.title, 30)} - {formatDateToIndonesian(new Date(item?.createdAt))}{" "} - {item?.timezone ? item?.timezone : "WIB"} |{" "} - + {formatDateToIndonesian(new Date(item?.createdAt))} {item?.timezone ? item?.timezone : "WIB"} |{" "} + { const [menuOpen, setMenuOpen] = useState(false); const router = useRouter(); - const pathname = usePathname(); const params = useParams(); const locale = params?.locale; const [language, setLanguage] = useState<"id" | "en">("id"); @@ -40,7 +41,10 @@ const Navbar = () => { const levelName = getCookiesDecrypt("ulnae"); const roleId = getCookiesDecrypt("urie"); const [detail, setDetail] = useState(); - const t = useTranslations("Menu"); + const t = useTranslations("LandingPage"); + const [search, setSearch] = useState(""); + const [onSearch, setOnSearch] = useState(""); + const pathname = usePathname(); const onLogout = () => { Object.keys(Cookies.get()).forEach((cookieName) => { @@ -64,7 +68,7 @@ const Navbar = () => { const response = await getInfoProfile(); if (!response?.error) { const details = response?.data?.data; - + setDetail(details); console.log("data", details); } @@ -73,6 +77,16 @@ const Navbar = () => { initState(); }, []); + const handleChange = (e: any) => { + setSearch(e.target.value); + }; + + // const handleKeypress = (e: any) => { + // if (e.which == 13) { + // handleSearch(); + // } + // }; + return ( @@ -100,7 +114,7 @@ const Navbar = () => { - + { {t("content")} - - router.push(generateLocalizedPath("/video/filter", String(locale)))} className="flex items-start gap-1.5 p-2 "> - - - Video - - - router.push(generateLocalizedPath("/audio/filter", String(locale)))} className="flex place-items-start gap-1.5 p-2 "> - - - Audio - - - router.push(generateLocalizedPath("/image/filter", String(locale)))} className="flex place-items-start gap-1.5 p-2"> + + router.push("/image/filter")} className="flex place-items-start gap-1.5 p-2"> - Foto + {t("image")} - router.push(generateLocalizedPath("/document/filter", String(locale)))} className="flex place-items-start gap-1.5 p-2"> + router.push("/video/filter")} className="flex items-start gap-1.5 p-2 "> + {pathname?.split("/")[1] == "in" ? ( + <> + + + {t("video")} + + > + ) : ( + <> + + + {t("video")} + + > + )} + {/* + + {t("video")} + */} + + router.push("/document/filter")} className="flex place-items-start gap-1.5 p-2"> - Teks + {t("text")} + + + router.push("/audio/filter")} className="flex place-items-start gap-1.5 p-2 "> + + + {t("audio")}{" "} @@ -149,7 +178,7 @@ const Navbar = () => { /> - Jadwal + {t("schedule")} @@ -166,7 +195,7 @@ const Navbar = () => { /> - Indeks + {t("index")} @@ -175,7 +204,7 @@ const Navbar = () => { - Live + {t("live")} @@ -183,39 +212,23 @@ const Navbar = () => { + {/* Languange */} - {/* Tombol Utama */} - setIsOpen(!isOpen)} className="flex items-center space-x-2 p-2 text-gray-700 bg-slate-200 rounded-lg"> - - {language === "id" ? "Ind" : "Eng"} - - - - - - - - {/* Dropdown Menu */} - {isOpen && ( - - handleLanguageChange("id")} className={`flex items-center space-x-2 w-full px-4 py-2 ${language === "id" ? "font-medium" : ""}`}> - - Ind - - handleLanguageChange("en")} className={`flex items-center space-x-2 w-full px-4 py-2 ${language === "en" ? "font-medium" : ""}`}> - - Eng - - - )} + + + {/* Dark Mode */} + - + setOnSearch(e.target.value)} + onKeyPress={() => router.push(`/all/filter?title=${onSearch}`)} + type="text" + placeholder={t("search")} + className="pl-8 pr-4 py-1 w-28 text-[13px] border rounded-full focus:outline-none dark:text-white" + /> { + {/* {fullName ? ( <> @@ -318,7 +332,7 @@ const Navbar = () => { - Log out + {t("logOut")} @@ -372,7 +386,7 @@ const Navbar = () => { - Log out + {t("logOut")} @@ -382,11 +396,11 @@ const Navbar = () => { ) : ( // Masuk and Daftar buttons for roleId === null - - Masuk + + {t("logIn")} - Daftar + {t("register")} )} @@ -407,32 +421,32 @@ const Navbar = () => { fill="currentColor" /> - Konten + {t("content")} router.push(generateLocalizedPath("/video/filter", String(locale)))} className="flex items-start gap-1.5 p-2 hover:bg-white"> - Video + {t("video")} router.push(generateLocalizedPath("/audio/filter", String(locale)))} className="flex place-items-start gap-1.5 p-2 hover:bg-white"> - Audio + {t("audio")} router.push(generateLocalizedPath("/image/filter", String(locale)))} className="flex place-items-start gap-1.5 p-2 hover:bg-white"> - Foto + {t("image")} router.push(generateLocalizedPath("/document/filter", String(locale)))} className="flex place-items-start gap-1.5 p-2 hover:bg-white"> - Teks + {t("text")} @@ -448,7 +462,7 @@ const Navbar = () => { /> - Jadwal + {t("schedule")} @@ -465,7 +479,7 @@ const Navbar = () => { /> - Indeks + {t("index")} @@ -481,8 +495,11 @@ const Navbar = () => { + - {/* Tombol Utama Bahasa */} + + + {/* Tombol Utama Bahasa setIsOpen(!isOpen)} className="flex items-center space-x-2 p-2 text-gray-700 bg-slate-200 rounded-lg"> { - + */} - {/* Dropdown Menu */} + {/* Dropdown Menu {isOpen && ( handleLanguageChange("id")} className={`flex items-center space-x-2 w-full px-4 py-2 ${language === "id" ? "font-medium" : ""}`}> @@ -509,7 +526,7 @@ const Navbar = () => { Eng - )} + )} */} @@ -531,20 +548,20 @@ const Navbar = () => { - Profile + {t("profile")} - Kelola Konten + {t("contentManagement")} - Log Out + {t("logOut")} @@ -554,10 +571,10 @@ const Navbar = () => { ) : ( <> - Masuk + {t("logIn")} - Daftar + {t("register")} {" "} > )} diff --git a/components/landing-page/new-content.tsx b/components/landing-page/new-content.tsx index b70a96e3..bdc42672 100644 --- a/components/landing-page/new-content.tsx +++ b/components/landing-page/new-content.tsx @@ -2,27 +2,23 @@ import React, { useEffect, useState } from "react"; import { Tabs, TabsList, TabsTrigger } from "@/components/ui/tabs"; -import { - Carousel, - CarouselContent, - CarouselItem, - CarouselNext, - CarouselPrevious, -} from "@/components/ui/carousel"; +import { Carousel, CarouselContent, CarouselItem, CarouselNext, CarouselPrevious } from "@/components/ui/carousel"; import { useParams, usePathname, useRouter } from "next/navigation"; import { Icon } from "@iconify/react/dist/iconify.js"; import { formatDateToIndonesian } from "@/utils/globals"; import { getListContent } from "@/service/landing/landing"; import { Link } from "@/i18n/routing"; import { Reveal } from "./Reveal"; +import { useTranslations } from "next-intl"; const NewContent = (props: { type: string }) => { const [newContent, setNewContent] = useState(); - const [selectedTab, setSelectedTab] = useState("video"); + const [selectedTab, setSelectedTab] = useState("image"); const router = useRouter(); const pathname = usePathname(); const params = useParams(); const locale = params?.locale; + const t = useTranslations("LandingPage"); useEffect(() => { initFetch(); @@ -32,16 +28,7 @@ const NewContent = (props: { 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" - : "", + contentTypeId: selectedTab == "image" ? "1" : selectedTab == "video" ? "2" : selectedTab == "text" ? "3" : selectedTab == "audio" ? "4" : "", }; const response = await getListContent(request); console.log("category", response); @@ -54,47 +41,46 @@ const NewContent = (props: { type: string }) => { - Konten - {props.type == "popular" - ? "Populer" - : props.type == "latest" - ? "Terbaru" - : "Serupa"} + {pathname?.split("/")[1] == "in" ? ( + <> + {t("content")} + {props.type == "popular" ? "Terpopuler" : props.type == "latest" ? t("new") : "Serupa"} + > + ) : ( + <> + {props.type == "popular" ? "Popular" : props.type == "latest" ? t("new") : "Serupa"} + {t("content")} + > + )} - - Audio Visual - - - | - - - Audio - - - | - - Foto + {t("image")} - - | - + | + + {t("video")} + + | - Teks + {t("text")} + + | + + {t("audio")} @@ -105,29 +91,13 @@ const NewContent = (props: { type: string }) => { {newContent?.map((video: any) => ( - - - + + + - - {video?.title} - + {video?.title} - {formatDateToIndonesian( - new Date(video?.createdAt) - )}{" "} - {video?.timezone ? video?.timezone : "WIB"} |{" "} - {" "} - {video.clickCount}{" "} + {formatDateToIndonesian(new Date(video?.createdAt))} {video?.timezone ? video?.timezone : "WIB"} | {video.clickCount}{" "} @@ -139,11 +109,7 @@ const NewContent = (props: { type: string }) => { ) : ( - + ) ) : selectedTab == "audio" ? ( @@ -151,23 +117,11 @@ const NewContent = (props: { type: string }) => { {newContent?.map((audio: any) => ( - + - + - + { - {formatDateToIndonesian( - new Date(audio?.createdAt) - )}{" "} - {audio?.timezone ? audio?.timezone : "WIB"} |{" "} - {" "} - {audio?.clickCount}{" "} - - - {audio?.title} + {formatDateToIndonesian(new Date(audio?.createdAt))} {audio?.timezone ? audio?.timezone : "WIB"} | {audio?.clickCount}{" "} + {audio?.title} @@ -202,11 +145,7 @@ const NewContent = (props: { type: string }) => { ) : ( - + ) ) : selectedTab == "image" ? ( @@ -214,29 +153,13 @@ const NewContent = (props: { type: string }) => { {newContent?.map((image: any) => ( - - - + + + - - {image?.title} - + {image?.title} - {formatDateToIndonesian( - new Date(image?.createdAt) - )}{" "} - {image?.timezone ? image?.timezone : "WIB"}|{" "} - {" "} - {image?.clickCount}{" "} + {formatDateToIndonesian(new Date(image?.createdAt))} {image?.timezone ? image?.timezone : "WIB"}| {image?.clickCount}{" "} @@ -248,34 +171,18 @@ const NewContent = (props: { type: string }) => { ) : ( - + ) ) : newContent.length > 0 ? ( {newContent?.map((text: any) => ( - + - + - + { - {formatDateToIndonesian( - new Date(text?.createdAt) - )} + {formatDateToIndonesian(new Date(text?.createdAt))} {text?.timezone ? text?.timezone : "WIB"}| {text?.clickCount} - - {text?.title} - + {text?.title} - - + + - Download Dokumen + Download {t("document")} @@ -320,21 +215,14 @@ const NewContent = (props: { type: string }) => { ) : ( - + )} - - LIHAT SEMUA + + {t("seeAll")} diff --git a/components/landing-page/search-section.tsx b/components/landing-page/search-section.tsx index 38fd87cd..0bf06c2e 100644 --- a/components/landing-page/search-section.tsx +++ b/components/landing-page/search-section.tsx @@ -1,42 +1,26 @@ import React, { useState } from "react"; -import { - DropdownMenu, - DropdownMenuContent, - DropdownMenuItem, - DropdownMenuTrigger, -} from "../ui/dropdown-menu"; +import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger } from "../ui/dropdown-menu"; import { FiFile, FiImage, FiMusic, FiYoutube } from "react-icons/fi"; import { Icon } from "@iconify/react/dist/iconify.js"; -import { - Select, - SelectContent, - SelectGroup, - SelectItem, - SelectLabel, - SelectTrigger, - SelectValue, -} from "@/components/ui/select"; +import { Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectTrigger, SelectValue } from "@/components/ui/select"; import { useRouter } from "@/i18n/routing"; +import { useTranslations } from "next-intl"; const SearchSection = () => { const [contentType, setContentType] = useState("all"); const [search, setSearch] = useState(""); const router = useRouter(); + const t = useTranslations("LandingPage"); return ( {/* Heading */} - Eksplorasi dan{" "} - Download{" "} - Liputan Resmi Kami + {t("exploration")} {t("and")} {t("download")} {t("coverage")}{" "} - - Liputan resmi yang bersumber dari kegiatan Polri di Mabes dan Polda - seluruh Indonesia - + {t("officialCoverage")} {/* Search Form */} @@ -48,45 +32,31 @@ const SearchSection = () => { - Semua Konten - Foto - Audio Visual - Teks - Audio + {t("allContent")} + {t("image")} + {t("video")} + {t("text")} + {t("audio")} - + - setSearch(e.target.value)} - /> + setSearch(e.target.value)} /> {/* Search Input */} - - router.push(`/${contentType}/filter?title=${search}`) - } - className="flex justify-center items-center px-6 w-full lg:w-[20%] py-2 bg-[#bb3523] gap-2 text-white rounded-lg hover:bg-red-700" - > - Cari Liputan + router.push(`/${contentType}/filter?title=${search}`)} className="flex justify-center items-center px-6 w-full lg:w-[20%] py-2 bg-[#bb3523] gap-2 text-white rounded-lg hover:bg-red-700"> + {t("searchCoverage")} + diff --git a/messages/en.json b/messages/en.json index d217003c..bd982b40 100644 --- a/messages/en.json +++ b/messages/en.json @@ -306,5 +306,68 @@ "version": "Version's", "changelog": "CHANGELOG", "versionHistory": "VERSION HISTORY" + }, + "LandingPage": { + "content": "Content", + "new": "Latest", + "schedule": "Schedule", + "index": "Index", + "search": "Search", + "exploration": "Exploration", + "and": "and", + "download": "Download", + "coverage": "Our Official Coverage", + "officialCoverage": "Official coverage sourced from Polri activities at the National Police Headquarters and Regional Police throughout Indonesia", + "allContent": "All Content", + "searchCoverage": "Search Coverage", + "newContent": "Latest Content", + "video": "Video", + "audio": "Audio", + "image": "Image", + "text": "Text", + "document": "Document", + "seeAll": "See All", + "category": "Category", + "contentCategory": "Content Category", + "seeMore": "See More", + "area": "Area", + "coverageOnly": "Coverage", + "searchRegional": "Search for Regional Police", + "divisionCoverage": "Division Coverage", + "searchDivision": "Search Division", + "division": "Division", + "seeLess": "See Less", + "logIn": "Log In", + "logOut": "Log Out", + "register": "Register", + "profile": "Profile", + "contentManagement": "Content Management", + "live": "Live", + "notFound": "Not Found" + }, + "FilterPage": { + "image": "Image", + "video": "Video", + "text": "Text", + "audio": "Audio", + "allImage": "All Image", + "allVideo": "All Video", + "allText": "All Text", + "allAudio": "All Audio", + "search": "Search", + "searchTitle": "Find Title...", + "monthYear": "Month and Year", + "thereIs": "There is", + "downloadableImage": "downloadable image", + "downloadableVideo": "downloadable video", + "downloadableText": "downloadable text", + "downloadableAudio": "downloadable audio", + "date": "Date", + "selectYear": "Select Month and Year", + "selectDate": "Select Date", + "categories": "Categories", + "sortBy": "Sort by", + "latest": "Latest", + "mostPopular": "Most Popular" } } diff --git a/messages/in.json b/messages/in.json index 273f8511..719b4f88 100644 --- a/messages/in.json +++ b/messages/in.json @@ -306,5 +306,68 @@ "version": "Version's", "changelog": "CHANGELOG", "versionHistory": "VERSION HISTORY" + }, + "LandingPage": { + "content": "Konten", + "new": "Terbaru", + "schedule": "Jadwal", + "index": "Indeks", + "search": "Pencarian", + "exploration": "Eksplorasi", + "and": "dan", + "download": "Download", + "coverage": "Liputan Resmi Kami", + "officialCoverage": "Liputan resmi yang bersumber dari kegiatan Polri di Mabes dan Polda seluruh Indonesia", + "allContent": "Semua Konten", + "searchCoverage": "Cari Liputan", + "newContent": "Konten Terbaru", + "video": "Audio Visual", + "audio": "Audio", + "image": "Foto", + "text": "Teks", + "document": "Dokumen", + "category": "Kategori", + "seeAll": "Lihat Semua", + "coverageOnly": "Liputan", + "contentCategory": "Kategori Konten", + "seeMore": "Lihat Lebih Banyak", + "area": "Wilayah", + "searchRegional": "Cari Polda", + "divisionCoverage": "Liputan Satker", + "searchDivision": "Cari Satker", + "logIn": "Masuk", + "logOut": "Keluar", + "register": "Daftar", + "profile": "Profil", + "contentManagement": "Kelola Konten", + "live": "Live", + "seeLess": "Lihat Lebih Sedikit", + "notFound": "Tidak Ditemukan", + "division": "Satker" + }, + "FilterPage": { + "image": "Foto", + "video": "Audio Visual", + "text": "Teks", + "audio": "Audio", + "allImage": "Semua Foto", + "allVideo": "Semua Audio Visual", + "allText": "Semua Teks", + "allAudio": "Semua Audio", + "search": "Pencarian", + "searchTitle": "Cari Judul...", + "monthYear": "Bulan dan Tahun", + "thereIs": "Terdapat", + "downloadableImage": "artikel berisi Foto yang dapat di unduh", + "downloadableVideo": "artikel berisi Audio Visual yang dapat di unduh", + "downloadableText": "artikel berisi Teks yang dapat di unduh", + "downloadableAudio": "artikel berisi Audio yang dapat di unduh", + "date": "Tanggal", + "selectYear": "Pilih Bulan dan Tahun", + "selectDate": "Pilih Tanggal", + "categories": "Kategori", + "sortBy": "Urutkan Berdasarkan", + "latest": "Terbaru", + "mostPopular": "Terpopuler" } } diff --git a/service/content/content.ts b/service/content/content.ts index 95caaeba..686ea83c 100644 --- a/service/content/content.ts +++ b/service/content/content.ts @@ -1,4 +1,7 @@ -import { httpGetInterceptor, httpPostInterceptor } from "../http-config/http-interceptor-service"; +import { + httpGetInterceptor, + httpPostInterceptor, +} from "../http-config/http-interceptor-service"; // export async function listDataAll( // isForSelf, @@ -41,40 +44,103 @@ export async function listDataAll( ); } -export async function listDataImage(limit: any, page: any, isForSelf: any, isApproval: any, categoryFilter: any, statusFilter: any, needApprovalFromLevel: any, creator: any, source: any, startDate: any, endDate: any, title: string = "") { +export async function listDataImage( + limit: any, + page: any, + isForSelf: any, + isApproval: any, + categoryFilter: any, + statusFilter: any, + needApprovalFromLevel: any, + creator: any, + source: any, + startDate: any, + endDate: any, + title: string = "" +) { return await httpGetInterceptor( `media/list?enablePage=1&sortBy=createdAt&sort=desc&size=${limit}&page=${page}&typeId=1&isForSelf=${isForSelf}&isApproval=${isApproval}&categoryId=${categoryFilter}&statusId=${statusFilter}&needApprovalFromLevel=${needApprovalFromLevel}&creatorUserLevelName=${source}&creatorName=${creator}&startDate=${startDate}&endDate=${endDate}&title=${title}` ); } -export async function listDataVideo(limit: any, page: any, isForSelf: any, isApproval: any, categoryFilter: any, statusFilter: any, needApprovalFromLevel: any, creator: any, source: any, startDate: any, endDate: any, title: string = "") { +export async function listDataVideo( + limit: any, + page: any, + isForSelf: any, + isApproval: any, + categoryFilter: any, + statusFilter: any, + needApprovalFromLevel: any, + creator: any, + source: any, + startDate: any, + endDate: any, + title: string = "" +) { return await httpGetInterceptor( `media/list?enablePage=1&sortBy=createdAt&sort=desc&size=${limit}&page=${page}&typeId=2&isForSelf=${isForSelf}&isApproval=${isApproval}&categoryId=${categoryFilter}&statusId=${statusFilter}&needApprovalFromLevel=${needApprovalFromLevel}&creatorUserLevelName=${source}&creatorName=${creator}&startDate=${startDate}&endDate=${endDate}&title=${title}` ); } -export async function listDataTeks(limit: any, page: any, isForSelf: any, isApproval: any, categoryFilter: any, statusFilter: any, needApprovalFromLevel: any, creator: any, source: any, startDate: any, endDate: any, title: string = "") { +export async function listDataTeks( + limit: any, + page: any, + isForSelf: any, + isApproval: any, + categoryFilter: any, + statusFilter: any, + needApprovalFromLevel: any, + creator: any, + source: any, + startDate: any, + endDate: any, + title: string = "" +) { return await httpGetInterceptor( `media/list?enablePage=1&sortBy=createdAt&sort=desc&size=${limit}&page=${page}&typeId=3&isForSelf=${isForSelf}&isApproval=${isApproval}&categoryId=${categoryFilter}&statusId=${statusFilter}&needApprovalFromLevel=${needApprovalFromLevel}&creatorUserLevelName=${source}&creatorName=${creator}&startDate=${startDate}&endDate=${endDate}&title=${title}` ); } -export async function listDataAudio(page: any, limit: any, isForSelf: any, isApproval: any, categoryFilter: any, statusFilter: any, needApprovalFromLevel: any, creator: any, source: any, startDate: any, endDate: any, title: string = "") { +export async function listDataAudio( + limit: any, + page: any, + isForSelf: any, + isApproval: any, + categoryFilter: any, + statusFilter: any, + needApprovalFromLevel: any, + creator: any, + source: any, + startDate: any, + endDate: any, + title: string = "" +) { return await httpGetInterceptor( `media/list?enablePage=1&sortBy=createdAt&sort=desc&size=${limit}&page=${page}&typeId=4&isForSelf=${isForSelf}&isApproval=${isApproval}&categoryId=${categoryFilter}&statusId=${statusFilter}&needApprovalFromLevel=${needApprovalFromLevel}&creatorUserLevelName=${source}&creatorName=${creator}&startDate=${startDate}&endDate=${endDate}&title=${title}` ); } -export async function listSPIT(page: any, limit: any, title = "", isPublish: any) { - return await httpGetInterceptor(`media/spit/pagination?enablePage=1&page=${page}&size=${limit}&sort=desc&sortBy=contentTitleId&title=${title}&isPublish=${isPublish}`); +export async function listSPIT( + page: any, + limit: any, + title = "", + isPublish: any +) { + return await httpGetInterceptor( + `media/spit/pagination?enablePage=1&page=${page}&size=${limit}&sort=desc&sortBy=contentTitleId&title=${title}&isPublish=${isPublish}` + ); } export async function listNulisAI(limit: any, page: any, title: string = "") { - return await httpGetInterceptor(`media/nulis-ai/pagination?enablePage=1&page=${page}&size=${limit}&title=${title}`); + return await httpGetInterceptor( + `media/nulis-ai/pagination?enablePage=1&page=${page}&size=${limit}&title=${title}` + ); } export async function getTagsBySubCategoryId(subCategory: any) { - return await httpGetInterceptor(`media/tags/list?subCategoryId=${subCategory}`); + return await httpGetInterceptor( + `media/tags/list?subCategoryId=${subCategory}` + ); } export async function listEnableCategory(type: any) { @@ -100,8 +166,8 @@ export async function createMedia(data: any) { export async function uploadThumbnail(id: any, data: any) { const url = `media/upload?id=${id}&operation=thumbnail`; const headers = { - 'Content-Type': 'multipart/form-data' - } + "Content-Type": "multipart/form-data", + }; return httpPostInterceptor(url, data, { headers }); } @@ -130,6 +196,6 @@ export async function saveContentRewrite(data: any) { return httpPostInterceptor(url, data); } export async function saveUserReports(data: any) { - const url = 'public/users/reports'; - return httpPostInterceptor( url, data ); + const url = "public/users/reports"; + return httpPostInterceptor(url, data); } diff --git a/service/contest/contest.ts b/service/contest/contest.ts index 08b72e64..ba751b9d 100644 --- a/service/contest/contest.ts +++ b/service/contest/contest.ts @@ -22,3 +22,8 @@ export async function getContestById(id: any, pages = 0) { const url = `contest?id=${id}&page=${pages}`; return httpGetInterceptor(url); } + +export async function postCreateContest(data: any) { + const url = "contest"; + return httpPostInterceptor(url, data); +} diff --git a/service/http-config/http-interceptor-service.ts b/service/http-config/http-interceptor-service.ts index 8f929ac7..90979859 100644 --- a/service/http-config/http-interceptor-service.ts +++ b/service/http-config/http-interceptor-service.ts @@ -3,6 +3,7 @@ import axiosInterceptorInstance from "./axios-interceptor-instance"; import Cookies from "js-cookie"; export async function httpGetInterceptor(pathUrl: any) { + const pathname = window.location.pathname; const response = await axiosInterceptorInstance .get(pathUrl) .catch((error) => error.response); @@ -17,7 +18,9 @@ export async function httpGetInterceptor(pathUrl: any) { Object.keys(Cookies.get()).forEach((cookieName) => { Cookies.remove(cookieName); }); - // window.location.href = "/"; + if (pathname?.includes("/contributor/") || pathname?.includes("/admin/") || pathname?.includes("/supervisor/")) { + window.location.href = "/"; + } } else { return { error: true, diff --git a/vendor/ckeditor5/node_modules/.bin/tsc b/vendor/ckeditor5/node_modules/.bin/tsc index 49798517..c4864b9a 100644 --- a/vendor/ckeditor5/node_modules/.bin/tsc +++ b/vendor/ckeditor5/node_modules/.bin/tsc @@ -2,7 +2,11 @@ basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')") case `uname` in - *CYGWIN*|*MINGW*|*MSYS*) basedir=`cygpath -w "$basedir"`;; + *CYGWIN*|*MINGW*|*MSYS*) + if command -v cygpath > /dev/null 2>&1; then + basedir=`cygpath -w "$basedir"` + fi + ;; esac if [ -x "$basedir/node" ]; then diff --git a/vendor/ckeditor5/node_modules/.bin/tsserver b/vendor/ckeditor5/node_modules/.bin/tsserver index cc53aac9..6c19ce3d 100644 --- a/vendor/ckeditor5/node_modules/.bin/tsserver +++ b/vendor/ckeditor5/node_modules/.bin/tsserver @@ -2,7 +2,11 @@ basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')") case `uname` in - *CYGWIN*|*MINGW*|*MSYS*) basedir=`cygpath -w "$basedir"`;; + *CYGWIN*|*MINGW*|*MSYS*) + if command -v cygpath > /dev/null 2>&1; then + basedir=`cygpath -w "$basedir"` + fi + ;; esac if [ -x "$basedir/node" ]; then
- {formatDateToIndonesian(new Date(item?.createdAt))}{" "} - {item?.timezone ? item?.timezone : "WIB"} |{" "} - + {formatDateToIndonesian(new Date(item?.createdAt))} {item?.timezone ? item?.timezone : "WIB"} |{" "} + { const [menuOpen, setMenuOpen] = useState(false); const router = useRouter(); - const pathname = usePathname(); const params = useParams(); const locale = params?.locale; const [language, setLanguage] = useState<"id" | "en">("id"); @@ -40,7 +41,10 @@ const Navbar = () => { const levelName = getCookiesDecrypt("ulnae"); const roleId = getCookiesDecrypt("urie"); const [detail, setDetail] = useState(); - const t = useTranslations("Menu"); + const t = useTranslations("LandingPage"); + const [search, setSearch] = useState(""); + const [onSearch, setOnSearch] = useState(""); + const pathname = usePathname(); const onLogout = () => { Object.keys(Cookies.get()).forEach((cookieName) => { @@ -64,7 +68,7 @@ const Navbar = () => { const response = await getInfoProfile(); if (!response?.error) { const details = response?.data?.data; - + setDetail(details); console.log("data", details); } @@ -73,6 +77,16 @@ const Navbar = () => { initState(); }, []); + const handleChange = (e: any) => { + setSearch(e.target.value); + }; + + // const handleKeypress = (e: any) => { + // if (e.which == 13) { + // handleSearch(); + // } + // }; + return ( @@ -100,7 +114,7 @@ const Navbar = () => { - + { {t("content")} - - router.push(generateLocalizedPath("/video/filter", String(locale)))} className="flex items-start gap-1.5 p-2 "> - - - Video - - - router.push(generateLocalizedPath("/audio/filter", String(locale)))} className="flex place-items-start gap-1.5 p-2 "> - - - Audio - - - router.push(generateLocalizedPath("/image/filter", String(locale)))} className="flex place-items-start gap-1.5 p-2"> + + router.push("/image/filter")} className="flex place-items-start gap-1.5 p-2"> - Foto + {t("image")} - router.push(generateLocalizedPath("/document/filter", String(locale)))} className="flex place-items-start gap-1.5 p-2"> + router.push("/video/filter")} className="flex items-start gap-1.5 p-2 "> + {pathname?.split("/")[1] == "in" ? ( + <> + + + {t("video")} + + > + ) : ( + <> + + + {t("video")} + + > + )} + {/* + + {t("video")} + */} + + router.push("/document/filter")} className="flex place-items-start gap-1.5 p-2"> - Teks + {t("text")} + + + router.push("/audio/filter")} className="flex place-items-start gap-1.5 p-2 "> + + + {t("audio")}{" "} @@ -149,7 +178,7 @@ const Navbar = () => { /> - Jadwal + {t("schedule")} @@ -166,7 +195,7 @@ const Navbar = () => { /> - Indeks + {t("index")} @@ -175,7 +204,7 @@ const Navbar = () => { - Live + {t("live")} @@ -183,39 +212,23 @@ const Navbar = () => { + {/* Languange */} - {/* Tombol Utama */} - setIsOpen(!isOpen)} className="flex items-center space-x-2 p-2 text-gray-700 bg-slate-200 rounded-lg"> - - {language === "id" ? "Ind" : "Eng"} - - - - - - - - {/* Dropdown Menu */} - {isOpen && ( - - handleLanguageChange("id")} className={`flex items-center space-x-2 w-full px-4 py-2 ${language === "id" ? "font-medium" : ""}`}> - - Ind - - handleLanguageChange("en")} className={`flex items-center space-x-2 w-full px-4 py-2 ${language === "en" ? "font-medium" : ""}`}> - - Eng - - - )} + + + {/* Dark Mode */} + - + setOnSearch(e.target.value)} + onKeyPress={() => router.push(`/all/filter?title=${onSearch}`)} + type="text" + placeholder={t("search")} + className="pl-8 pr-4 py-1 w-28 text-[13px] border rounded-full focus:outline-none dark:text-white" + /> { + {/* {fullName ? ( <> @@ -318,7 +332,7 @@ const Navbar = () => { - Log out + {t("logOut")} @@ -372,7 +386,7 @@ const Navbar = () => { - Log out + {t("logOut")} @@ -382,11 +396,11 @@ const Navbar = () => { ) : ( // Masuk and Daftar buttons for roleId === null - - Masuk + + {t("logIn")} - Daftar + {t("register")} )} @@ -407,32 +421,32 @@ const Navbar = () => { fill="currentColor" /> - Konten + {t("content")} router.push(generateLocalizedPath("/video/filter", String(locale)))} className="flex items-start gap-1.5 p-2 hover:bg-white"> - Video + {t("video")} router.push(generateLocalizedPath("/audio/filter", String(locale)))} className="flex place-items-start gap-1.5 p-2 hover:bg-white"> - Audio + {t("audio")} router.push(generateLocalizedPath("/image/filter", String(locale)))} className="flex place-items-start gap-1.5 p-2 hover:bg-white"> - Foto + {t("image")} router.push(generateLocalizedPath("/document/filter", String(locale)))} className="flex place-items-start gap-1.5 p-2 hover:bg-white"> - Teks + {t("text")} @@ -448,7 +462,7 @@ const Navbar = () => { /> - Jadwal + {t("schedule")} @@ -465,7 +479,7 @@ const Navbar = () => { /> - Indeks + {t("index")} @@ -481,8 +495,11 @@ const Navbar = () => { + - {/* Tombol Utama Bahasa */} + + + {/* Tombol Utama Bahasa setIsOpen(!isOpen)} className="flex items-center space-x-2 p-2 text-gray-700 bg-slate-200 rounded-lg"> { - + */} - {/* Dropdown Menu */} + {/* Dropdown Menu {isOpen && ( handleLanguageChange("id")} className={`flex items-center space-x-2 w-full px-4 py-2 ${language === "id" ? "font-medium" : ""}`}> @@ -509,7 +526,7 @@ const Navbar = () => { Eng - )} + )} */}
- - Video -
- - Audio -
- Foto + {t("image")}
+ + {t("video")} +
- Teks + {t("text")} +
+ + {t("audio")}{" "}
- Video + {t("video")}
- Audio + {t("audio")}
- Teks + {t("text")}
- {formatDateToIndonesian( - new Date(video?.createdAt) - )}{" "} - {video?.timezone ? video?.timezone : "WIB"} |{" "} - {" "} - {video.clickCount}{" "} + {formatDateToIndonesian(new Date(video?.createdAt))} {video?.timezone ? video?.timezone : "WIB"} | {video.clickCount}{" "}
- {formatDateToIndonesian( - new Date(image?.createdAt) - )}{" "} - {image?.timezone ? image?.timezone : "WIB"}|{" "} - {" "} - {image?.clickCount}{" "} + {formatDateToIndonesian(new Date(image?.createdAt))} {image?.timezone ? image?.timezone : "WIB"}| {image?.clickCount}{" "}
- Liputan resmi yang bersumber dari kegiatan Polri di Mabes dan Polda - seluruh Indonesia -
{t("officialCoverage")}