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 index 46e77a78..85118303 100644 --- 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 @@ -8,7 +8,15 @@ 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, createPublicSuggestion, deletePublicSuggestion, deleteWishlist, getDetail, getPublicSuggestionList, saveWishlist } from "@/service/landing/landing"; +import { + checkWishlistStatus, + createPublicSuggestion, + deletePublicSuggestion, + deleteWishlist, + getDetail, + getPublicSuggestionList, + saveWishlist, +} from "@/service/landing/landing"; import { getCookiesDecrypt } from "@/lib/utils"; import { close, error, loading, warning } from "@/config/swal"; import { useTranslations } from "next-intl"; @@ -18,7 +26,6 @@ import Swal from "sweetalert2"; import parse from "html-react-parser"; import { postActivityLog } from "@/service/content/content"; - const DetailAudio = () => { const [selectedSize, setSelectedSize] = useState("L"); const [selectedTab, setSelectedTab] = useState("video"); @@ -196,7 +203,8 @@ const DetailAudio = () => { xhr.addEventListener("readystatechange", () => { if (xhr.readyState === 4 && xhr.status === 200) { - const contentType = xhr.getResponseHeader("content-type") || "application/octet-stream"; + const contentType = + xhr.getResponseHeader("content-type") || "application/octet-stream"; const extension = contentType.split("/")[1]; const filename = `${name}.${extension}`; @@ -228,7 +236,7 @@ const DetailAudio = () => { { label: "S", value: "1066 x 599 px" }, { label: "XS", value: "800 x 450 px" }, ]; - async function sendSuggestionParent() { + async function sendSuggestionParent() { if (message?.length > 3) { loading(); const data = { @@ -280,41 +288,45 @@ const DetailAudio = () => { document.querySelector(`#${e}`)?.classList.toggle("none"); setVisibleInput(visibleInput === e ? null : e); }; - async function sendSuggestionChild(parentId: any) { - const inputElement = document.querySelector(`#input-comment-${parentId}`) as HTMLInputElement; - - if (inputElement && inputElement.value.length > 3) { - loading(); - const data = { - mediaUploadId: slug?.split("-")?.[0], - message: inputElement.value, - parentId, - }; - - console.log(data); - const response = await createPublicSuggestion(data); - console.log(response); - const responseGet: any = await getPublicSuggestionList(slug?.split("-")?.[0]); - console.log(responseGet.data?.data); - setListSuggestion(responseGet.data?.data); - - // Reset input field - inputElement.value = ""; - - // document.querySelector("#comment-id-" + parentId)?.style.display = "none"; - - close(); - } - } - async function deleteDataSuggestion(dataId: any) { + async function sendSuggestionChild(parentId: any) { + const inputElement = document.querySelector( + `#input-comment-${parentId}` + ) as HTMLInputElement; + + if (inputElement && inputElement.value.length > 3) { loading(); - const response = await deletePublicSuggestion(dataId); + const data = { + mediaUploadId: slug?.split("-")?.[0], + message: inputElement.value, + parentId, + }; + + console.log(data); + const response = await createPublicSuggestion(data); console.log(response); - const responseGet = await getPublicSuggestionList(slug.split("-")?.[0]); - console.log(responseGet.data?.data); - setListSuggestion(responseGet.data?.data); + const responseGet: any = await getPublicSuggestionList( + slug?.split("-")?.[0] + ); + console.log(responseGet?.data?.data); + setListSuggestion(responseGet?.data?.data); + + // Reset input field + inputElement.value = ""; + + // document.querySelector("#comment-id-" + parentId)?.style.display = "none"; + close(); } + } + async function deleteDataSuggestion(dataId: any) { + loading(); + const response = await deletePublicSuggestion(dataId); + console.log(response); + const responseGet = await getPublicSuggestionList(slug.split("-")?.[0]); + console.log(responseGet?.data?.data); + setListSuggestion(responseGet?.data?.data); + close(); + } const deleteData = (dataId: any) => { MySwal.fire({ title: "Delete Comment", @@ -331,17 +343,17 @@ const DetailAudio = () => { }); }; const postDataChild = (id: any) => { - const checkMessage = checkMaliciousText(message); - if (checkMessage == "") { - if (Number(userRoleId) < 1 || userRoleId == undefined) { - router.push("/auth"); - } else { - sendSuggestionChild(id); - } + const checkMessage = checkMaliciousText(message); + if (checkMessage == "") { + if (Number(userRoleId) < 1 || userRoleId == undefined) { + router.push("/auth"); } else { - warning(checkMessage); + sendSuggestionChild(id); } - }; + } else { + warning(checkMessage); + } + }; return ( <>
@@ -351,13 +363,23 @@ const DetailAudio = () => {
- +
{/* Footer Informasi */}

- oleh {detailDataAudio?.uploadedBy?.userLevel?.name} | Diupdate pada {detailDataAudio?.updatedAt} WIB |  + oleh  + + {detailDataAudio?.uploadedBy?.userLevel?.name} + +  | Diupdate pada {detailDataAudio?.updatedAt}{" "} + WIB |    {detailDataAudio?.clickCount} @@ -366,20 +388,33 @@ const DetailAudio = () => {

{/* Keterangan */}
-

{detailDataAudio?.title}

-
+

+ {detailDataAudio?.title} +

+
{/* Bagian Kanan */}
{isSaved ? ( - handleDeleteWishlist()} className="flex flex-col mb-3 items-center justify-center cursor-pointer"> + 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"> + doBookmark()} + className="flex flex-col mb-3 items-center justify-center cursor-pointer" + >

Simpan

@@ -388,13 +423,20 @@ const DetailAudio = () => { {/* garis */}
- + {detailDataAudio?.category?.name}
{detailDataAudio?.tags?.split(",").map((tag: string) => ( - router.push(`/all/filter?tag=${tag}`)} key={tag} className="bg-gray-200 text-gray-700 text-xs px-3 py-1 rounded-full cursor-pointer hover:bg-gray-500"> + router.push(`/all/filter?tag=${tag}`)} + key={tag} + className="bg-gray-200 text-gray-700 text-xs px-3 py-1 rounded-full cursor-pointer hover:bg-gray-500" + > {tag} ))} @@ -403,15 +445,27 @@ const DetailAudio = () => {
{/* Opsi Ukuran Foto */} -

Opsi Ukuran Audio

+

+ Opsi Ukuran Audio +

{sizes.map((size: any) => (
-
- setSelectedSize(size.label)} className="text-red-600 focus:ring-red-600" /> +
+ setSelectedSize(size.label)} + className="text-red-600 focus:ring-red-600" + />
{size.label}
@@ -424,15 +478,30 @@ const DetailAudio = () => { {/* Download Semua */}
{/* Tombol Download */} -