diff --git a/app/[locale]/(public)/image/detail/[slug]/page.tsx b/app/[locale]/(public)/image/detail/[slug]/page.tsx index 4062fcf3..b4ed98d7 100644 --- a/app/[locale]/(public)/image/detail/[slug]/page.tsx +++ b/app/[locale]/(public)/image/detail/[slug]/page.tsx @@ -8,13 +8,29 @@ import NewContent from "@/components/landing-page/new-content"; import { useToast } from "@/components/ui/use-toast"; import { getCookiesDecrypt } from "@/lib/utils"; import { close, error, loading, successCallback, warning } from "@/config/swal"; -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 { Link, useRouter } from "@/i18n/routing"; -import { Popover, PopoverContent, PopoverTrigger } from "@/components/ui/popover"; +import { + Popover, + PopoverContent, + PopoverTrigger, +} from "@/components/ui/popover"; import { Input } from "@/components/ui/input"; import { Button } from "@/components/ui/button"; import { sendMediaUploadToEmail } from "@/service/media-tracking/media-tracking"; -import { checkMaliciousText, formatDateToIndonesian, getPublicLocaleTimestamp } from "@/utils/globals"; +import { + checkMaliciousText, + formatDateToIndonesian, + getPublicLocaleTimestamp, +} from "@/utils/globals"; import withReactContent from "sweetalert2-react-content"; import Swal from "sweetalert2"; import parse from "html-react-parser"; @@ -22,7 +38,6 @@ import { Skeleton } from "@/components/ui/skeleton"; import { useTranslations } from "next-intl"; import Image from "next/image"; - interface Size { label: string; value: string; @@ -64,8 +79,11 @@ const DetailInfo = () => { const poldaName = params?.polda_name; const satkerName = params?.satker_name; - let prefixPath = poldaName ? `/polda/${poldaName}` : satkerName ? `/satker/${satkerName}` : "/"; - + let prefixPath = poldaName + ? `/polda/${poldaName}` + : satkerName + ? `/satker/${satkerName}` + : "/"; useEffect(() => { const timer = setTimeout(() => { @@ -178,14 +196,14 @@ const DetailInfo = () => { const sizes: Size[] = Object.entries(scaleFactors).map(([label, factor]) => { const width = Number(main?.widthPixel); const height = Number(main?.heightPixel); - + if (isNaN(width) || isNaN(height) || width === 0) { return { label, value: "Invalid size" }; } - + const newWidth = Math.round(width * factor); const newHeight = Math.round((width * factor) / (width / height)); - + return { label, value: `${newWidth} x ${newHeight} px` }; }); @@ -263,7 +281,8 @@ const DetailInfo = () => { 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}`; @@ -297,7 +316,11 @@ const DetailInfo = () => { if (type == "wa" && width <= 768) { window.open(`whatsapp://send?${url}`, "_blank"); } else if (type == "wa" && width > 768) { - window.open(`https://web.whatsapp.com/send?${url}`, "_blank", "noreferrer"); + window.open( + `https://web.whatsapp.com/send?${url}`, + "_blank", + "noreferrer" + ); } else { window.open(url); } @@ -386,7 +409,9 @@ const DetailInfo = () => { } async function sendSuggestionChild(parentId: any) { - const inputElement = document.querySelector(`#input-comment-${parentId}`) as HTMLInputElement; + const inputElement = document.querySelector( + `#input-comment-${parentId}` + ) as HTMLInputElement; if (inputElement && inputElement.value.length > 3) { loading(); @@ -399,7 +424,9 @@ const DetailInfo = () => { console.log(data); const response = await createPublicSuggestion(data); console.log(response); - const responseGet: any = await getPublicSuggestionList(slug?.split("-")?.[0]); + const responseGet: any = await getPublicSuggestionList( + slug?.split("-")?.[0] + ); console.log(responseGet.data?.data); setListSuggestion(responseGet.data?.data); @@ -477,9 +504,11 @@ const DetailInfo = () => { `; - - const toBase64 = (str: string) => (typeof window === "undefined" ? Buffer.from(str).toString("base64") : window.btoa(str)); - + + const toBase64 = (str: string) => + typeof window === "undefined" + ? Buffer.from(str).toString("base64") + : window.btoa(str); return ( <> @@ -494,7 +523,16 @@ const DetailInfo = () => { ) : (
- Main + Main
)} @@ -510,7 +548,16 @@ const DetailInfo = () => {
{detailDataImage?.files?.map((file: any, index: number) => ( setSelectedImage(index)} key={file?.id}> - image-small + image-small ))}
@@ -520,7 +567,10 @@ const DetailInfo = () => {

- {t("by")} {detailDataImage?.uploadedBy?.userLevel?.name} + {t("by")}  + + {detailDataImage?.uploadedBy?.userLevel?.name} +

{/*

 | {t("updatedOn")} @@ -528,7 +578,10 @@ const DetailInfo = () => {

*/}

 | {t("updatedOn")}  - {formatDateToIndonesian(new Date(detailDataImage?.updatedAt))} {"WIB"} + {formatDateToIndonesian( + new Date(detailDataImage?.updatedAt) + )}{" "} + {"WIB"}

 |  @@ -546,20 +599,33 @@ const DetailInfo = () => { {/* Keterangan */}

-

{detailDataImage?.title}

-
+

+ {detailDataImage?.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" + >

{t("delete")}

) : ( - 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" + >

{t("save")}

@@ -567,30 +633,52 @@ const DetailInfo = () => { {/* garis */}
+
+
+ + {detailDataImage?.category?.name} + +
- - {detailDataImage?.category?.name} - - -
{/* Opsi Ukuran Foto */} -

{t("imageSize")}

+

+ {t("imageSize")} +

{sizes.map((size: any) => (
-
- setImageSizeSelected(e.target.value)} className="text-red-600 focus:ring-red-600" /> +
+ setImageSizeSelected(e.target.value)} + className="text-red-600 focus:ring-red-600" + />
{size?.label}
{size?.value}
@@ -601,15 +689,30 @@ const DetailInfo = () => { {/* Download Semua */}
{/* Tombol Download */} -
@@ -655,8 +819,15 @@ const DetailInfo = () => {

{t("comment")}

-