From 7c8c4f434b59495d224cb61a64c39c7b8bf3569b Mon Sep 17 00:00:00 2001 From: sabdayagra Date: Tue, 7 Jan 2025 18:52:16 +0700 Subject: [PATCH 01/12] feat: add rewrite section --- .../content-management/galery/page.tsx | 48 +++++- .../rewrite/create/[id]/page.tsx | 145 ++++++++++++++++++ .../rewrite/detail/[id]/page.tsx | 5 +- .../content-management/users/page.tsx | 3 - components/form/content/image-form.tsx | 17 +- components/landing-page/navbar.tsx | 106 ++++++++++++- .../landing-page/sidebar-management.tsx | 8 +- service/landing/landing.ts | 98 +++--------- 8 files changed, 310 insertions(+), 120 deletions(-) create mode 100644 app/[locale]/(public)/content-management/rewrite/create/[id]/page.tsx diff --git a/app/[locale]/(public)/content-management/galery/page.tsx b/app/[locale]/(public)/content-management/galery/page.tsx index ee538a07..18e2295e 100644 --- a/app/[locale]/(public)/content-management/galery/page.tsx +++ b/app/[locale]/(public)/content-management/galery/page.tsx @@ -13,6 +13,9 @@ import withReactContent from "sweetalert2-react-content"; import { getCookiesDecrypt } from "@/lib/utils"; import Swal from "sweetalert2"; import { useToast } from "@/components/ui/use-toast"; +import { Icon } from "@iconify/react/dist/iconify.js"; +import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger } from "@/components/ui/dropdown-menu"; +import { Button } from "@/components/ui/button"; const Galery = (props: any) => { const [profile, setProfile] = useState(); @@ -28,7 +31,7 @@ const Galery = (props: any) => { const { isInstitute, instituteId } = props; const userId = getCookiesDecrypt("uie"); const userRoleId = getCookiesDecrypt("urie"); - + const { toast } = useToast(); const [totalContent, setTotalContent] = useState(); const [categoryFilter] = useState([]); const [formatFilter] = useState([]); @@ -217,6 +220,9 @@ const Galery = (props: any) => { await navigator.clipboard.writeText(`https://mediahub.polri.go.id/video/detail/${url}`); setCopySuccess("Copied"); // toast.success("Link Berhasil Di Copy"); + toast({ + title: "Link Berhasil Di Copy", + }); }; const [hasMounted, setHasMounted] = useState(false); @@ -277,12 +283,44 @@ const Galery = (props: any) => { contentVideo?.length > 0 ? (
{contentVideo?.map((video: any) => ( - + - - +
+ + + +
{video?.mediaUpload?.title}
- + + + + + + + + + + + + + +

Content Rewrite

+ +
+ +
+ +
+
+
+
+
))} diff --git a/app/[locale]/(public)/content-management/rewrite/create/[id]/page.tsx b/app/[locale]/(public)/content-management/rewrite/create/[id]/page.tsx new file mode 100644 index 00000000..0237434c --- /dev/null +++ b/app/[locale]/(public)/content-management/rewrite/create/[id]/page.tsx @@ -0,0 +1,145 @@ +"use client"; + +import HeaderManagement from "@/components/landing-page/header-management"; +import SidebarManagement from "@/components/landing-page/sidebar-management"; +import { useRouter } from "@/i18n/routing"; +import { getCookiesDecrypt } from "@/lib/utils"; +import { useSearchParams } from "next/navigation"; +import React, { useState } from "react"; +import Swal from "sweetalert2"; +import withReactContent from "sweetalert2-react-content"; +import { Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectTrigger, SelectValue } from "@/components/ui/select"; + +const page = () => { + // const { states } = props; + const [profile, setProfile] = useState(); + const MySwal = withReactContent(Swal); + const router = useRouter(); + const [, setLoadingState] = useState(false); + const searchParams = useSearchParams(); + const id: any = searchParams?.get("title"); + const [content, setContent] = useState([]); + const [isFromSPIT, setIsFromSPIT] = useState(false); + const [listSuggestion, setListSuggestion] = useState(); + const [main, setMain] = useState(); + const userId = getCookiesDecrypt("uie"); + const userRoleId = getCookiesDecrypt("urie"); + const [articleIds, setArticleIds] = useState([]); + const [isGeneratedArticle, setIsGeneratedArticle] = useState(false); + const [selectedArticleId, setSelectedArticleId] = useState(null); + const [articleBody, setArticleBody] = useState(""); + const [selectedAdvConfig, setSelectedAdvConfig] = useState(""); + const [selectedWritingStyle, setSelectedWritingStyle] = useState(""); + const [selectedContextType, setSelectedContextType] = useState(""); + const [selectedLanguage, setSelectedLanguage] = useState(""); + const [selectedTitle, setSelectedTitle] = useState(""); + const [selectedMainKeyword, setSelectedMainKeyword] = useState(""); + const [selectedSEO, setSelectedSEO] = useState(""); + const [selectedSize, setSelectedSize] = useState(""); + const [detailArticle, setDetailArticle] = useState(null); + const [contentType, setContentType] = useState("all"); + + const userLevelId = getCookiesDecrypt("ulie"); + const roleId = getCookiesDecrypt("urie"); + return ( + <> + + +
+ +
+
+
Content Rewrite
+
+
+
+
+

Bahasa

+ +
+
+

Context Type

+ +
+
+

Writing Style

+ +
+
+

Article Size

+ +
+
+
+

Judul

+ setSelectedTitle(e.target.value)} + /> +
+
+
+
+
+
+ + ); +}; + +export default page; diff --git a/app/[locale]/(public)/content-management/rewrite/detail/[id]/page.tsx b/app/[locale]/(public)/content-management/rewrite/detail/[id]/page.tsx index 910fa8fe..fb0f6b34 100644 --- a/app/[locale]/(public)/content-management/rewrite/detail/[id]/page.tsx +++ b/app/[locale]/(public)/content-management/rewrite/detail/[id]/page.tsx @@ -78,8 +78,6 @@ const page = (props: any) => { getInitData(); }, []); - let componentMounted = true; - const validationSchema = Yup.object().shape({ title: Yup.string().required("Judul tidak boleh kosong"), }); @@ -288,12 +286,11 @@ const page = (props: any) => {
- {/* setArticleBody(event.editor?.getData())} /> */} {/* */} {articleBody === null || articleBody === "" ?
Deskripsi tidak boleh kosong
: ""}
- {/* )} */} + {/* )} */} diff --git a/app/[locale]/(public)/content-management/users/page.tsx b/app/[locale]/(public)/content-management/users/page.tsx index 7ae41b9d..c5942206 100644 --- a/app/[locale]/(public)/content-management/users/page.tsx +++ b/app/[locale]/(public)/content-management/users/page.tsx @@ -154,9 +154,6 @@ const page = () => { - {/* */} diff --git a/components/form/content/image-form.tsx b/components/form/content/image-form.tsx index 3bd4a3d5..4d216f4b 100644 --- a/components/form/content/image-form.tsx +++ b/components/form/content/image-form.tsx @@ -912,22 +912,7 @@ export default function FormImage() { )}
- ( - // - - )} - /> + รง {errors.description?.message && (

{errors.description.message} diff --git a/components/landing-page/navbar.tsx b/components/landing-page/navbar.tsx index 2e8a6cd6..e6d84a41 100644 --- a/components/landing-page/navbar.tsx +++ b/components/landing-page/navbar.tsx @@ -15,7 +15,10 @@ import Cookies from "js-cookie"; import { getInfoProfile } from "@/service/auth"; import { useTranslations } from "next-intl"; import { useRouter } from "@/i18n/routing"; +import { Button } from "@/components/ui/button"; import LocalSwitcher from "../partials/header/locale-switcher"; +import { Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, DialogTrigger } from "@/components/ui/dialog"; +import { listRole } from "@/service/landing/landing"; type Detail = { id: number; @@ -45,6 +48,12 @@ const Navbar = () => { const [search, setSearch] = useState(""); const [onSearch, setOnSearch] = useState(""); const pathname = usePathname(); + const [role, setRole] = useState(); + const [menuActive, setMenuActive] = useState(); + const [category, setCategory] = useState(); + + let active = ""; + let menu = ""; const onLogout = () => { Object.keys(Cookies.get()).forEach((cookieName) => { @@ -77,6 +86,39 @@ const Navbar = () => { initState(); }, []); + useEffect(() => { + async function initState() { + setMenuActive(menu); + const res = await listRole(); + setRole(res?.data?.data); + } + + // async function getNotif() { + // if (roleId != undefined) { + // const response = await getUserNotifications(0, 2); + // setNotifications(response?.data?.data?.content); + // console.log("respon:", response); + // } + // } + + // async function getNotifUpdate() { + // if (roleId != undefined) { + // const response = await getUserNotifications(0, 3); + // setNotificationsUpdate(response?.data?.data?.content); // console.log("respon:", response); + // } + // } + + // async function getPolritvStatus() { + // const response = await getYtPolritvStatus(); + // console.log("Polritv status :", response?.data?.message); + // setIsPolriTvOnline(response.data?.message == "Online"); + // } + + initState(); + // getNotif(); + // getNotifUpdate(); + }, []); + const handleChange = (e: any) => { setSearch(e.target.value); }; @@ -396,12 +438,36 @@ const Navbar = () => { ) : ( // Masuk and Daftar buttons for roleId === null

- + {t("logIn")} - - {t("register")} - + + + + + +
+

Kategori Registrasi

+

Silahkan pilih salah satu

+
+
+ {role?.map((row: any) => ( +
+ setCategory(event.target.value)} /> + +
+ ))} +
+
+ + + Selanjutnya{" "} + + +
+
)}
@@ -570,12 +636,36 @@ const Navbar = () => { ) : ( <> - + {t("logIn")} - - {t("register")} - {" "} + + + + + +
+

Kategori Registrasi

+

Silahkan pilih salah satu

+
+
+ {role?.map((row: any) => ( +
+ setCategory(event.target.value)} /> + +
+ ))} +
+
+ + + Selanjutnya{" "} + + +
+
)} diff --git a/components/landing-page/sidebar-management.tsx b/components/landing-page/sidebar-management.tsx index fdfa3194..63846867 100644 --- a/components/landing-page/sidebar-management.tsx +++ b/components/landing-page/sidebar-management.tsx @@ -96,7 +96,7 @@ const SidebarManagement = () => {
-
+

Galeri {profile?.institute?.name}

@@ -107,7 +107,7 @@ const SidebarManagement = () => {
-
+

Galeri Saya

@@ -118,7 +118,7 @@ const SidebarManagement = () => {
-
+

Galeri Rewrite

@@ -129,7 +129,7 @@ const SidebarManagement = () => {
-
+

Tim Pengguna

diff --git a/service/landing/landing.ts b/service/landing/landing.ts index d3c05670..822a395a 100644 --- a/service/landing/landing.ts +++ b/service/landing/landing.ts @@ -1,26 +1,16 @@ -import { - httpDeleteInterceptor, - httpGetInterceptor, - httpPostInterceptor, -} from "../http-config/http-interceptor-service"; +import { httpDeleteInterceptor, httpGetInterceptor, httpPostInterceptor } from "../http-config/http-interceptor-service"; export async function getHeroData() { - return await httpGetInterceptor( - `media/public/list?enablePage=1&sort=desc&sortBy=createdAt&size=5&page=0&typeId=1&title=&categoryId=&fileFormats=&tags=&group=&startDate=&endDate=&month=&year=` - ); + return await httpGetInterceptor(`media/public/list?enablePage=1&sort=desc&sortBy=createdAt&size=5&page=0&typeId=1&title=&categoryId=&fileFormats=&tags=&group=&startDate=&endDate=&month=&year=`); } export async function getCategoryData() { - return await httpGetInterceptor( - `media/categories/list/publish?enablePage=1&sort=desc&sortBy=updatedAt&size=12&type=` - ); + return await httpGetInterceptor(`media/categories/list/publish?enablePage=1&sort=desc&sortBy=updatedAt&size=12&type=`); } export async function getListContent(props: any) { return await httpGetInterceptor( - `media/public/list?enablePage=1&sort=desc&sortBy=${props.sortBy}&size=${ - props.size - }&page=${props.page}&typeId=${props.contentTypeId}&title=${ + `media/public/list?enablePage=1&sort=desc&sortBy=${props.sortBy}&size=${props.size}&page=${props.page}&typeId=${props.contentTypeId}&title=${ props.title ? props.title : "" }&categoryId=&fileFormats=&tags=&group=&startDate=&endDate=&month=&year=` ); @@ -31,9 +21,7 @@ export async function getPrivacy() { } export async function getIndeksData() { - return await httpGetInterceptor( - `blog/public/pagination?enablePage=1&page=0&size=20` - ); + return await httpGetInterceptor(`blog/public/pagination?enablePage=1&page=0&size=20`); } export async function getDetail(slug: string) { @@ -41,9 +29,7 @@ export async function getDetail(slug: string) { } export async function getDetailIndeks() { - return await httpGetInterceptor( - `blog/public/pagination?enablePage=1&page=0&size=6` - ); + return await httpGetInterceptor(`blog/public/pagination?enablePage=1&page=0&size=6`); } export async function getFeedback() { @@ -55,49 +41,20 @@ export async function postUserFeedback() { } export async function listCategory(type = "") { - return await httpGetInterceptor( - `media/categories/list/enable?enablePage=1&sort=desc&sortBy=updatedAt&size=12&type=${type}` - ); + return await httpGetInterceptor(`media/categories/list/enable?enablePage=1&sort=desc&sortBy=updatedAt&size=12&type=${type}`); } export async function publicDetailBlog(slug: any) { return await httpGetInterceptor(`blog/public/read/${slug}`); } -export async function listData( - type: string, - search: string, - category: string, - size = 10, - page = 0, - sortBy = "createdAt", - format = "", - tag = "", - group = "", - startDate = "", - endDate = "", - month = "", - year = "" -) { +export async function listData(type: string, search: string, category: string, size = 10, page = 0, sortBy = "createdAt", format = "", tag = "", group = "", startDate = "", endDate = "", month = "", year = "") { return await httpGetInterceptor( `media/public/list?enablePage=1&sort=desc&sortBy=${sortBy}&size=${size}&page=${page}&typeId=${type}&title=${search}&categoryId=${category}&fileFormats=${format}&tags=${tag}&group=${group}&startDate=${startDate}&endDate=${endDate}&month=${month}&year=${year}` ); } -export async function listDataRegional( - type: string, - search: string, - category: string, - format = "", - tag = "", - startDate = "", - endDate = "", - month = "", - year = "", - size = 10, - page = 0, - sortBy = "createdAt" -) { +export async function listDataRegional(type: string, search: string, category: string, format = "", tag = "", startDate = "", endDate = "", month = "", year = "", size = 10, page = 0, sortBy = "createdAt") { return await httpGetInterceptor( `media/public/regional-list?enablePage=1&size=${size}&page=${page}&sort=desc&sortBy=${sortBy}&typeId=${type}&title=${search}&categoryId=${category}&fileFormats=${format}&tags=${tag}&startDate=${startDate}&endDate=${endDate}&month=${month}&year=${year}` ); @@ -118,51 +75,32 @@ export async function getListPorvinces() { export async function getUsersTeams(id: any) { return await httpGetInterceptor(`users?instituteId=${id}`); } -export async function mediaWishlist( - type: any, - instituteId: any, - search: any, - category: any, - size: string, - page: number, - sortBy: undefined, - format: string -) { - return await httpGetInterceptor( - `/media/wishlist/list?enablePage=1&size=${size}&page=${page}&typeId=${type}&instituteId=${instituteId}` - ); +export async function mediaWishlist(type: any, instituteId: any, search: any, category: any, size: string, page: number, sortBy: undefined, format: string) { + return await httpGetInterceptor(`/media/wishlist/list?enablePage=1&size=${size}&page=${page}&typeId=${type}&instituteId=${instituteId}`); } export async function checkWishlistStatus(mediaId: any) { return await httpGetInterceptor(`/media/wishlist/status?mediaId=${mediaId}`); } +export async function listRole() { + const url = "public/users/roles"; + return httpGetInterceptor(url); +} + export async function deleteWishlist(id: any) { return await httpDeleteInterceptor(`media/wishlist?id=${id}`); } export async function getContentRewritePagination(page = 0, size = 10) { - return await httpGetInterceptor( - `media/rewrite/pagination?size=${size}&page=${page}` - ); + return await httpGetInterceptor(`media/rewrite/pagination?size=${size}&page=${page}`); } export async function getContentRewrite(id: any) { return await httpGetInterceptor(`media/rewrite?id=${id}`); } -export async function listDataAll( - type: any, - search: any, - category: any, - format = "", - tag = "", - group = "", - startDate = "", - endDate = "", - month = "", - year = "" -) { +export async function listDataAll(type: any, search: any, category: any, format = "", tag = "", group = "", startDate = "", endDate = "", month = "", year = "") { return await httpGetInterceptor( `media/public/list?enablePage=1&size=20&sort=desc&typeId=${type}&title=${search}&categoryId=${category}&fileFormats=${format}&tags=${tag}&group=${group}&startDate=${startDate}&endDate=${endDate}&month=${month}&year=${year}` ); From cd9a8501305a3f8d3298b170aa87c4020c6c7625 Mon Sep 17 00:00:00 2001 From: hanif salafi Date: Tue, 7 Jan 2025 20:54:20 +0700 Subject: [PATCH 02/12] feat: update fixing navbar --- components/landing-page/navbar.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/components/landing-page/navbar.tsx b/components/landing-page/navbar.tsx index e6d84a41..c1ada334 100644 --- a/components/landing-page/navbar.tsx +++ b/components/landing-page/navbar.tsx @@ -335,8 +335,8 @@ const Navbar = () => {
{"Image"}
-
{detail?.fullname}
-

({detail?.fullname})

+
{detail?.fullname}
+

({detail?.fullname})

@@ -389,8 +389,8 @@ const Navbar = () => {
{"Image"}
-
{detail?.fullname}
-

({detail?.fullname})

+
{detail?.fullname}
+

({detail?.fullname})

From 1a7aa27262aa04afb9453b89aa310ae6699369af Mon Sep 17 00:00:00 2001 From: hanif salafi Date: Tue, 7 Jan 2025 21:46:16 +0700 Subject: [PATCH 03/12] feat: update navbar --- components/landing-page/navbar.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/landing-page/navbar.tsx b/components/landing-page/navbar.tsx index c1ada334..981ecfee 100644 --- a/components/landing-page/navbar.tsx +++ b/components/landing-page/navbar.tsx @@ -438,12 +438,12 @@ const Navbar = () => { ) : ( // Masuk and Daftar buttons for roleId === null
- + {t("logIn")} - +
From 83e419b5f2b29e5a42be92097be81e3b23b5b05a Mon Sep 17 00:00:00 2001 From: hanif salafi Date: Tue, 7 Jan 2025 21:49:59 +0700 Subject: [PATCH 04/12] feat: update fixing error --- components/form/content/audio-update-form.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/form/content/audio-update-form.tsx b/components/form/content/audio-update-form.tsx index 8df8e277..f104309e 100644 --- a/components/form/content/audio-update-form.tsx +++ b/components/form/content/audio-update-form.tsx @@ -145,7 +145,7 @@ export default function FormAudioUpdate() { const getCategories = async () => { try { const category = await listEnableCategory(fileTypeId); - const resCategory: Category[] = category.data.data.content; + const resCategory: Category[] = category?.data.data.content; setCategories(resCategory); console.log("data category", resCategory); @@ -171,7 +171,7 @@ export default function FormAudioUpdate() { async function initState() { if (id) { const response = await detailMedia(id); - const details = response.data?.data; + const details = response?.data?.data; setDetail(details); From e00c1f3326f1395469daa5c4667861cea5cd86ed Mon Sep 17 00:00:00 2001 From: hanif salafi Date: Tue, 7 Jan 2025 23:53:22 +0700 Subject: [PATCH 05/12] feat: move satker and polda, update detail video and image on contributor --- .../{ => (polda)}/polda/[polda_name]/page.tsx | 0 .../(public)/{ => (polda)}/polda/layout.tsx | 0 .../satker/[satker_name]/page.tsx | 0 .../(public)/{ => (satker)}/satker/layout.tsx | 0 components/form/content/image-detail-form.tsx | 166 +++++++-------- components/form/content/video-detail-form.tsx | 193 +++++++++++++----- components/landing-page/division.tsx | 4 +- components/landing-page/new-content.tsx | 5 + service/landing/landing.ts | 4 +- 9 files changed, 240 insertions(+), 132 deletions(-) rename app/[locale]/(public)/{ => (polda)}/polda/[polda_name]/page.tsx (100%) rename app/[locale]/(public)/{ => (polda)}/polda/layout.tsx (100%) rename app/[locale]/(public)/{ => (satker)}/satker/[satker_name]/page.tsx (100%) rename app/[locale]/(public)/{ => (satker)}/satker/layout.tsx (100%) diff --git a/app/[locale]/(public)/polda/[polda_name]/page.tsx b/app/[locale]/(public)/(polda)/polda/[polda_name]/page.tsx similarity index 100% rename from app/[locale]/(public)/polda/[polda_name]/page.tsx rename to app/[locale]/(public)/(polda)/polda/[polda_name]/page.tsx diff --git a/app/[locale]/(public)/polda/layout.tsx b/app/[locale]/(public)/(polda)/polda/layout.tsx similarity index 100% rename from app/[locale]/(public)/polda/layout.tsx rename to app/[locale]/(public)/(polda)/polda/layout.tsx diff --git a/app/[locale]/(public)/satker/[satker_name]/page.tsx b/app/[locale]/(public)/(satker)/satker/[satker_name]/page.tsx similarity index 100% rename from app/[locale]/(public)/satker/[satker_name]/page.tsx rename to app/[locale]/(public)/(satker)/satker/[satker_name]/page.tsx diff --git a/app/[locale]/(public)/satker/layout.tsx b/app/[locale]/(public)/(satker)/satker/layout.tsx similarity index 100% rename from app/[locale]/(public)/satker/layout.tsx rename to app/[locale]/(public)/(satker)/satker/layout.tsx diff --git a/components/form/content/image-detail-form.tsx b/components/form/content/image-detail-form.tsx index f2bb4025..b88f67dc 100644 --- a/components/form/content/image-detail-form.tsx +++ b/components/form/content/image-detail-form.tsx @@ -133,11 +133,11 @@ export default function FormImageDetail() { const [filePlacements, setFilePlacements] = useState([]); const [detailThumb, setDetailThumb] = useState([]); const [thumbsSwiper, setThumbsSwiper] = useState(null); + const [isUserMabesApprover, setIsUserMabesApprover] = useState(false); const [selectedTarget, setSelectedTarget] = useState(""); const [files, setFiles] = useState([]); const [rejectedFiles, setRejectedFiles] = useState([]); - const [isMabesApprover, setIsMabesApprover] = useState(false); let fileTypeId = "1"; @@ -157,7 +157,7 @@ export default function FormImageDetail() { userLevelId == "216" && roleId == "3" ) { - setIsMabesApprover(true); + setIsUserMabesApprover(true); } }, [userLevelId, roleId]); @@ -306,7 +306,7 @@ export default function FormImageDetail() { mediaUploadId: id, statusId: status, message: description, - files: isMabesApprover ? getPlacement() : [], + files: isUserMabesApprover ? getPlacement() : [], }; loading(); const response = await submitApproval(data); @@ -330,9 +330,11 @@ export default function FormImageDetail() { } close(); + submitApprovalSuccesss(); return false; } + const setupPlacement = ( index: number, placement: string, @@ -396,8 +398,10 @@ export default function FormImageDetail() { icon: "success", confirmButtonColor: "#3085d6", confirmButtonText: "OK", - }).then(() => { - router.push("/in/contributor/content/image"); + }).then((result) => { + if (result.isConfirmed) { + router.push("/contributor/content/image"); + } }); }; @@ -516,7 +520,7 @@ export default function FormImageDetail() {
- +
@@ -675,82 +679,84 @@ export default function FormImageDetail() {
-
-
- - setupPlacement(index, "all", Boolean(e)) - } - /> - -
-
- - setupPlacement(index, "mabes", Boolean(e)) - } - /> - -
-
- - setupPlacement(index, "polda", Boolean(e)) - } - /> - -
+ {isUserMabesApprover && +
+
+ + setupPlacement(index, "all", Boolean(e)) + } + /> + +
+
+ + setupPlacement(index, "mabes", Boolean(e)) + } + /> + +
+
+ + setupPlacement(index, "polda", Boolean(e)) + } + /> + +
-
- - setupPlacement( - index, - "international", - Boolean(e) - ) - } - /> - +
+ + setupPlacement( + index, + "international", + Boolean(e) + ) + } + /> + +
-
+ }
)) diff --git a/components/form/content/video-detail-form.tsx b/components/form/content/video-detail-form.tsx index c703bfc5..c6331988 100644 --- a/components/form/content/video-detail-form.tsx +++ b/components/form/content/video-detail-form.tsx @@ -134,10 +134,11 @@ export default function FormVideoDetail() { const [detailVideo, setDetailVideo] = useState([]); const [thumbsSwiper, setThumbsSwiper] = useState(null); + const [filePlacements, setFilePlacements] = useState([]); const [selectedTarget, setSelectedTarget] = useState(""); const [files, setFiles] = useState([]); const [rejectedFiles, setRejectedFiles] = useState([]); - const [isMabesApprover, setIsMabesApprover] = useState(false); + const [isUserMabesApprover, setIsUserMabesApprover] = useState(false); let fileTypeId = "2"; @@ -168,7 +169,7 @@ export default function FormVideoDetail() { userLevelId == "216" && roleId == "3" ) { - setIsMabesApprover(true); + setIsUserMabesApprover(true); } }, [userLevelId, roleId]); @@ -254,9 +255,16 @@ export default function FormVideoDetail() { }, [refresh, setValue]); const actionApproval = (e: string) => { + const temp = []; + for (const element of detail.files) { + temp.push([]); + } + setFilePlacements(temp); setStatus(e); - setModalOpen(true); + setFiles(detail.files); + setDescription(""); + setModalOpen(true); }; const submit = async () => { @@ -286,8 +294,7 @@ export default function FormVideoDetail() { mediaUploadId: id, statusId: status, message: description, - files: [], - // files: isMabesApprover ? getPlacement() : [], + files: isUserMabesApprover ? getPlacement() : [], }; loading(); @@ -310,10 +317,57 @@ export default function FormVideoDetail() { } close(); + submitApprovalSuccesss(); return false; } + const getPlacement = () => { + console.log("getPlaa", filePlacements); + const temp = []; + for (let i = 0; i < filePlacements?.length; i++) { + if (filePlacements[i].length !== 0) { + const now = filePlacements[i].filter((a) => a !== "all"); + const data = { mediaFileId: files[i].id, placement: now.join(",") }; + temp.push(data); + } + } + return temp; + }; + + const setupPlacement = ( + index: number, + placement: string, + checked: boolean + ) => { + let temp = [...filePlacements]; + if (checked) { + if (placement === "all") { + temp[index] = ["all", "mabes", "polda", "international"]; + } else { + const now = temp[index]; + now.push(placement); + if (now.length === 3 && !now.includes("all")) { + now.push("all"); + } + temp[index] = now; + } + } else { + if (placement === "all") { + temp[index] = []; + } else { + const now = temp[index].filter((a) => a !== placement); + console.log("now", now); + temp[index] = now; + if (now.length === 3 && now.includes("all")) { + const newData = now.filter((b) => b !== "all"); + temp[index] = newData; + } + } + } + setFilePlacements(temp); + }; + function handleDeleteFileApproval(id: number) { const selectedFiles = files.filter((file) => file.id != id); setFiles(selectedFiles); @@ -344,8 +398,10 @@ export default function FormVideoDetail() { icon: "success", confirmButtonColor: "#3085d6", confirmButtonText: "OK", - }).then(() => { - router.push("/in/contributor/content/video"); + }).then((result) => { + if (result.isConfirmed) { + router.push("/contributor/content/video"); + } }); }; @@ -610,7 +666,7 @@ export default function FormVideoDetail() { Berikan Komentar {status == "2" - ? files?.map((file) => ( + ? files?.map((file, index) => (
-
-
- - -
-
- - -
-
- - -
+ {isUserMabesApprover && +
+
+ + setupPlacement(index, "all", Boolean(e)) + } + /> + +
+
+ + setupPlacement(index, "mabes", Boolean(e)) + } + /> + +
+
+ + setupPlacement(index, "polda", Boolean(e)) + } + /> + +
-
- - +
+ + setupPlacement( + index, + "international", + Boolean(e) + ) + } + /> + +
-
+ }
)) @@ -744,7 +843,7 @@ export default function FormVideoDetail() { diff --git a/components/landing-page/division.tsx b/components/landing-page/division.tsx index eab1ded1..39608ce1 100644 --- a/components/landing-page/division.tsx +++ b/components/landing-page/division.tsx @@ -94,7 +94,7 @@ const Division = () => { filteredList.map((region, index) => !seeAllValue ? ( index < 7 ? ( - +
{region.name}
@@ -104,7 +104,7 @@ const Division = () => { "" ) ) : ( - +
{region.name}
diff --git a/components/landing-page/new-content.tsx b/components/landing-page/new-content.tsx index bdc42672..c92a95e3 100644 --- a/components/landing-page/new-content.tsx +++ b/components/landing-page/new-content.tsx @@ -18,17 +18,22 @@ const NewContent = (props: { type: string }) => { const pathname = usePathname(); const params = useParams(); const locale = params?.locale; + const poldaName = params?.polda_name; + const satkerName = params?.satker_name; const t = useTranslations("LandingPage"); useEffect(() => { initFetch(); }, [selectedTab]); const initFetch = async () => { + console.log("Satker Name : ", satkerName); const request = { + title: "", page: 0, size: 5, sortBy: props.type == "popular" ? "clickCount" : "createdAt", contentTypeId: selectedTab == "image" ? "1" : selectedTab == "video" ? "2" : selectedTab == "text" ? "3" : selectedTab == "audio" ? "4" : "", + group: poldaName && String(poldaName)?.length > 1 ? poldaName : "", }; const response = await getListContent(request); console.log("category", response); diff --git a/service/landing/landing.ts b/service/landing/landing.ts index 822a395a..0e8c4afc 100644 --- a/service/landing/landing.ts +++ b/service/landing/landing.ts @@ -10,9 +10,7 @@ export async function getCategoryData() { export async function getListContent(props: any) { return await httpGetInterceptor( - `media/public/list?enablePage=1&sort=desc&sortBy=${props.sortBy}&size=${props.size}&page=${props.page}&typeId=${props.contentTypeId}&title=${ - props.title ? props.title : "" - }&categoryId=&fileFormats=&tags=&group=&startDate=&endDate=&month=&year=` + `media/public/list?enablePage=1&sort=desc&sortBy=${props.sortBy}&size=${props.size}&page=${props.page}&typeId=${props.contentTypeId}&title=${props.title}&group=${props.group}&categoryId=&fileFormats=&tags=&startDate=&endDate=&month=&year=` ); } From 415537536237273b4107af0311bb133f83b8f5b1 Mon Sep 17 00:00:00 2001 From: hanif salafi Date: Wed, 8 Jan 2025 00:44:23 +0700 Subject: [PATCH 06/12] feat: update all features on polda and satker --- .../shared/curated-content/page.tsx | 1 - .../[polda_name]/audio/detail/[slug]/page.tsx | 334 ++++++++ .../polda/[polda_name]/audio/filter/page.tsx | 520 ++++++++++++ .../polda/[polda_name]/audio/layout.tsx | 20 + .../document/detail/[slug]/page.tsx | 333 ++++++++ .../[polda_name]/document/filter/page.tsx | 549 +++++++++++++ .../polda/[polda_name]/document/layout.tsx | 20 + .../[polda_name]/image/detail/[slug]/page.tsx | 347 ++++++++ .../polda/[polda_name]/image/filter/page.tsx | 515 ++++++++++++ .../polda/[polda_name]/image/layout.tsx | 12 + .../indeks/detail/[slug]/page.tsx | 96 +++ .../polda/[polda_name]/indeks/layout.tsx | 20 + .../polda/[polda_name]/indeks/page.tsx | 116 +++ .../(polda)/polda/[polda_name]/page.tsx | 4 +- .../polda/[polda_name]/schedule/layout.tsx | 20 + .../polda/[polda_name]/schedule/page.tsx | 741 ++++++++++++++++++ .../[polda_name]/video/detail/[slug]/page.tsx | 343 ++++++++ .../polda/[polda_name]/video/filter/page.tsx | 545 +++++++++++++ .../polda/[polda_name]/video/layout.tsx | 20 + .../audio/detail/[slug]/page.tsx | 334 ++++++++ .../[satker_name]/audio/filter/page.tsx | 520 ++++++++++++ .../satker/[satker_name]/audio/layout.tsx | 20 + .../document/detail/[slug]/page.tsx | 333 ++++++++ .../[satker_name]/document/filter/page.tsx | 549 +++++++++++++ .../satker/[satker_name]/document/layout.tsx | 20 + .../image/detail/[slug]/page.tsx | 347 ++++++++ .../[satker_name]/image/filter/page.tsx | 515 ++++++++++++ .../satker/[satker_name]/image/layout.tsx | 12 + .../indeks/detail/[slug]/page.tsx | 96 +++ .../satker/[satker_name]/indeks/layout.tsx | 20 + .../satker/[satker_name]/indeks/page.tsx | 116 +++ .../(satker)/satker/[satker_name]/page.tsx | 4 +- .../satker/[satker_name]/schedule/layout.tsx | 20 + .../satker/[satker_name]/schedule/page.tsx | 741 ++++++++++++++++++ .../video/detail/[slug]/page.tsx | 343 ++++++++ .../[satker_name]/video/filter/page.tsx | 545 +++++++++++++ .../satker/[satker_name]/video/layout.tsx | 20 + .../(public)/audio/detail/[slug]/page.tsx | 2 +- .../(public)/document/detail/[slug]/page.tsx | 2 +- .../(public)/image/detail/[slug]/page.tsx | 2 +- .../(public)/video/detail/[slug]/page.tsx | 2 +- app/[locale]/page.tsx | 4 +- .../landing-page/header-banner-satker.tsx | 2 +- components/landing-page/navbar.tsx | 21 +- components/landing-page/new-content.tsx | 6 +- 45 files changed, 9131 insertions(+), 21 deletions(-) create mode 100644 app/[locale]/(public)/(polda)/polda/[polda_name]/audio/detail/[slug]/page.tsx create mode 100644 app/[locale]/(public)/(polda)/polda/[polda_name]/audio/filter/page.tsx create mode 100644 app/[locale]/(public)/(polda)/polda/[polda_name]/audio/layout.tsx create mode 100644 app/[locale]/(public)/(polda)/polda/[polda_name]/document/detail/[slug]/page.tsx create mode 100644 app/[locale]/(public)/(polda)/polda/[polda_name]/document/filter/page.tsx create mode 100644 app/[locale]/(public)/(polda)/polda/[polda_name]/document/layout.tsx create mode 100644 app/[locale]/(public)/(polda)/polda/[polda_name]/image/detail/[slug]/page.tsx create mode 100644 app/[locale]/(public)/(polda)/polda/[polda_name]/image/filter/page.tsx create mode 100644 app/[locale]/(public)/(polda)/polda/[polda_name]/image/layout.tsx create mode 100644 app/[locale]/(public)/(polda)/polda/[polda_name]/indeks/detail/[slug]/page.tsx create mode 100644 app/[locale]/(public)/(polda)/polda/[polda_name]/indeks/layout.tsx create mode 100644 app/[locale]/(public)/(polda)/polda/[polda_name]/indeks/page.tsx create mode 100644 app/[locale]/(public)/(polda)/polda/[polda_name]/schedule/layout.tsx create mode 100644 app/[locale]/(public)/(polda)/polda/[polda_name]/schedule/page.tsx create mode 100644 app/[locale]/(public)/(polda)/polda/[polda_name]/video/detail/[slug]/page.tsx create mode 100644 app/[locale]/(public)/(polda)/polda/[polda_name]/video/filter/page.tsx create mode 100644 app/[locale]/(public)/(polda)/polda/[polda_name]/video/layout.tsx create mode 100644 app/[locale]/(public)/(satker)/satker/[satker_name]/audio/detail/[slug]/page.tsx create mode 100644 app/[locale]/(public)/(satker)/satker/[satker_name]/audio/filter/page.tsx create mode 100644 app/[locale]/(public)/(satker)/satker/[satker_name]/audio/layout.tsx create mode 100644 app/[locale]/(public)/(satker)/satker/[satker_name]/document/detail/[slug]/page.tsx create mode 100644 app/[locale]/(public)/(satker)/satker/[satker_name]/document/filter/page.tsx create mode 100644 app/[locale]/(public)/(satker)/satker/[satker_name]/document/layout.tsx create mode 100644 app/[locale]/(public)/(satker)/satker/[satker_name]/image/detail/[slug]/page.tsx create mode 100644 app/[locale]/(public)/(satker)/satker/[satker_name]/image/filter/page.tsx create mode 100644 app/[locale]/(public)/(satker)/satker/[satker_name]/image/layout.tsx create mode 100644 app/[locale]/(public)/(satker)/satker/[satker_name]/indeks/detail/[slug]/page.tsx create mode 100644 app/[locale]/(public)/(satker)/satker/[satker_name]/indeks/layout.tsx create mode 100644 app/[locale]/(public)/(satker)/satker/[satker_name]/indeks/page.tsx create mode 100644 app/[locale]/(public)/(satker)/satker/[satker_name]/schedule/layout.tsx create mode 100644 app/[locale]/(public)/(satker)/satker/[satker_name]/schedule/page.tsx create mode 100644 app/[locale]/(public)/(satker)/satker/[satker_name]/video/detail/[slug]/page.tsx create mode 100644 app/[locale]/(public)/(satker)/satker/[satker_name]/video/filter/page.tsx create mode 100644 app/[locale]/(public)/(satker)/satker/[satker_name]/video/layout.tsx diff --git a/app/[locale]/(protected)/shared/curated-content/page.tsx b/app/[locale]/(protected)/shared/curated-content/page.tsx index fceac0cd..8f6e1514 100644 --- a/app/[locale]/(protected)/shared/curated-content/page.tsx +++ b/app/[locale]/(protected)/shared/curated-content/page.tsx @@ -15,7 +15,6 @@ import { import { Link } from "@/components/navigation"; import { formatDateToIndonesian, generateLocalizedPath } from "@/utils/globals"; import { Icon } from "@iconify/react/dist/iconify.js"; -import newContent from "@/components/landing-page/new-content"; import { locale } from "dayjs"; import { useEffect, useState } from "react"; import { getListContent } from "@/service/landing/landing"; diff --git a/app/[locale]/(public)/(polda)/polda/[polda_name]/audio/detail/[slug]/page.tsx b/app/[locale]/(public)/(polda)/polda/[polda_name]/audio/detail/[slug]/page.tsx new file mode 100644 index 00000000..fffbae98 --- /dev/null +++ b/app/[locale]/(public)/(polda)/polda/[polda_name]/audio/detail/[slug]/page.tsx @@ -0,0 +1,334 @@ +"use client"; + +import { useParams, usePathname } from "next/navigation"; +import React, { useEffect, useState } from "react"; +import { Icon } from "@iconify/react/dist/iconify.js"; +import NewContent from "@/components/landing-page/new-content"; +import { Link, useRouter } from "@/i18n/routing"; +import { Textarea } from "@/components/ui/textarea"; +import { BarWave } from "react-cssfx-loading"; +import { useToast } from "@/components/ui/use-toast"; +import { checkWishlistStatus, deleteWishlist, getDetail, saveWishlist } from "@/service/landing/landing"; +import { getCookiesDecrypt } from "@/lib/utils"; +import { close, error, loading } from "@/config/swal"; + +const DetailAudio = () => { + const [selectedSize, setSelectedSize] = useState("L"); + const [selectedTab, setSelectedTab] = useState("video"); + const router = useRouter(); + const pathname = usePathname(); + const params = useParams(); + const slug = String(params?.slug); + const [detailDataAudio, setDetailDataAudio] = useState(); + const [isSaved, setIsSaved] = useState(false); + const [wishlistId, setWishlistId] = useState(); + const { toast } = useToast(); + const [isDownloadAll, setIsDownloadAll] = useState(false); + const [downloadProgress, setDownloadProgress] = useState(0); + const [isFromSPIT, setIsFromSPIT] = useState(false); + const [main, setMain] = useState(); + const [resolutionSelected, setResolutionSelected] = useState("720"); + const [imageSizeSelected, setImageSizeSelected] = useState("l"); + + const userId = getCookiesDecrypt("uie"); + + useEffect(() => { + initFetch(); + checkWishlist(); + }, []); + + const initFetch = async () => { + const response = await getDetail(String(slug)); + console.log("detailAudio", response); + setIsFromSPIT(response?.data?.data?.isFromSPIT); + setMain({ + id: response?.data?.data?.files[0]?.id, + type: response?.data?.data?.fileType.name, + url: + Number(response?.data?.data?.fileType?.id) == 4 + ? response?.data?.data?.files[0]?.secondaryUrl + : Number(response?.data?.data?.fileType?.id) == 2 + ? `${process.env.NEXT_PUBLIC_API}/media/view?id=${response?.data?.data?.files[0]?.id}&operation=file&type=video` + : response?.data?.data?.files[0]?.url, + thumbnailFileUrl: response?.data?.data?.files[0]?.thumbnailFileUrl, + names: response?.data?.data?.files[0]?.fileName, + format: response?.data?.data?.files[0]?.format, + widthPixel: response?.data?.data?.files[0]?.widthPixel, + heightPixel: response?.data?.data?.files[0]?.heightPixel, + size: response?.data?.data?.files[0]?.size, + caption: response?.data?.data?.files[0]?.caption, + }); + setDetailDataAudio(response?.data?.data); + }; + + const doBookmark = async () => { + if (userId) { + const data = { + mediaUploadId: slug?.split("-")?.[0], + }; + + loading(); + const res = await saveWishlist(data); + if (res?.error) { + error(res.message); + return false; + } + close(); + toast({ + title: "Konten berhasil disimpan", + }); + checkWishlist(); + } else { + router.push("/auth"); + } + }; + async function checkWishlist() { + if (userId) { + const res = await checkWishlistStatus(slug.split("-")?.[0]); + console.log(res?.data?.data); + const isAlreadyOnWishlist = res?.data?.data !== "-1"; + setWishlistId(res?.data?.data); + setIsSaved(isAlreadyOnWishlist); + } + } + + const handleDeleteWishlist = async () => { + if (userId) { + loading(); + const res = await deleteWishlist(wishlistId); + + if (res?.error) { + error(res.message); + return false; + } + + toast({ + title: "Konten berhasil dihapus", + }); + close(); + checkWishlist(); + } else { + router.push("/auth"); + } + }; + + async function sendActivityLog(activityTypeId: number) { + const data = { + activityTypeId, + mediaId: slug.split("-")?.[0], + url: window.location.href, + }; + // set activity + // const response = await postActivityLog(data, token); + // console.log(response); + } + + const handleDownload = () => { + if (downloadProgress === 0) { + if (!userId) { + router.push("/auth/login"); + } else { + sendActivityLog(2); + sendActivityLog(3); + + if (isDownloadAll) { + let url: string; + const baseId = slug.split("-")?.[0]; + + // if (type === "1") { + // url = `${process.env.NEXT_PUBLIC_API}/media/file/download-zip?id=${baseId}&resolution=${resolutionSelected}`; + // } else if (type === "2") { + // url = `${process.env.NEXT_PUBLIC_API}/media/file/download-zip?id=${baseId}&resolution=${imageSizeSelected}`; + // } else { + url = `${process.env.NEXT_PUBLIC_API}/media/file/download-zip?id=${baseId}`; + // } + + downloadFile(url, "FileDownload.zip"); + } else { + if (isFromSPIT && main?.url?.includes("spit.humas")) { + downloadFile(`${main?.url}`, `${main.names}`); + } else { + downloadFile(`${main?.url}`, `${main.names}`); + } + } + // } else if (type === "1" && resolutionSelected?.length > 0) { + // if (isFromSPIT && main?.url?.includes("spit.humas")) { + // downloadFile(`${main?.url}`, `${main.names}`); + // } else { + // const url = `${process.env.NEXT_PUBLIC_API}/media/view?id=${main?.id}&operation=file&type=video&resolution=${resolutionSelected}p`; + // downloadFile(url, `${main.names}`); + // } + // } else if (type === "2" && imageSizeSelected?.length > 0) { + // const url = `${process.env.NEXT_PUBLIC_API}/media/view?id=${main?.id}&operation=file&type=image&resolution=${imageSizeSelected}`; + // downloadFile(url, `${main.names}`); + // } else if (type === "3" || type === "4") { + // downloadFile(`${main?.url}`, `${main.names}`); + // } + } + } + }; + + const downloadFile = (fileUrl: string, name: string) => { + const xhr = new XMLHttpRequest(); + + xhr.open("GET", fileUrl, true); + xhr.responseType = "blob"; + + xhr.addEventListener("progress", (event) => { + if (event.lengthComputable) { + const percentCompleted = Math.round((event.loaded / event.total) * 100); + setDownloadProgress(percentCompleted); + } + }); + + xhr.addEventListener("readystatechange", () => { + if (xhr.readyState === 4 && xhr.status === 200) { + const contentType = xhr.getResponseHeader("content-type") || "application/octet-stream"; + const extension = contentType.split("/")[1]; + const filename = `${name}.${extension}`; + + const blob = new Blob([xhr.response], { + type: contentType, + }); + const downloadUrl = URL.createObjectURL(blob); + const a = document.createElement("a"); + + a.href = downloadUrl; + a.download = filename; + document.body.append(a); + a.click(); + a.remove(); + } + }); + + xhr.onloadend = () => { + setDownloadProgress(0); + }; + + xhr.send(); + }; + + const sizes = [ + { label: "XL", value: "3198 x 1798 px" }, + { label: "L", value: "2399 x 1349 px" }, + { label: "M", value: "1599 x 899 px" }, + { label: "S", value: "1066 x 599 px" }, + { label: "XS", value: "800 x 450 px" }, + ]; + + return ( + <> +
+ {/* Container Utama */} +
+ {/* Bagian Kiri */} +
+
+ + +
+
+ {/* Footer Informasi */} +
+

+ oleh {detailDataAudio?.uploadedBy?.userLevel?.name} | Diupdate pada {detailDataAudio?.updatedAt} WIB |  + +   + {detailDataAudio?.clickCount} +

+

Kreator: {detailDataAudio?.creatorName}

+
+ {/* Keterangan */} +
+

{detailDataAudio?.title}

+
+
+
+ + {/* Bagian Kanan */} +
+ {isSaved ? ( + handleDeleteWishlist()} className="flex flex-col mb-3 items-center justify-center cursor-pointer"> + +

Hapus

+
+ ) : ( + doBookmark()} className="flex flex-col mb-3 items-center justify-center cursor-pointer"> + +

Simpan

+
+ )} + + {/* garis */} +
+ + + {detailDataAudio?.category?.name} + + + + +
+ + {/* Opsi Ukuran Foto */} +

Opsi Ukuran Audio

+ +
+ +
+ {sizes.map((size: any) => ( +
+
+ setSelectedSize(size.label)} className="text-red-600 focus:ring-red-600" /> +
{size.label}
+
+
+
{size.value}
+
+
+ ))} +
+ + {/* Download Semua */} +
+ +
+ + {/* Tombol Download */} + +
+
+
+ +
+ {/* Comment */} +
+

Berikan Komentar

+