From 8515a9956e44fe7f8bbc9c62389de50c5c711b82 Mon Sep 17 00:00:00 2001 From: Rama Priyanto Date: Mon, 9 Jun 2025 14:16:37 +0700 Subject: [PATCH 1/2] fix:penugasan redirect, approval image --- components/form/content/image-detail-form.tsx | 317 ++++++++++-------- components/form/task/task-detail-form.tsx | 8 +- components/form/task/task-form.tsx | 46 +-- components/partials/auth/login-form.tsx | 19 +- 4 files changed, 222 insertions(+), 168 deletions(-) diff --git a/components/form/content/image-detail-form.tsx b/components/form/content/image-detail-form.tsx index 3cd600ca..9ff0264a 100644 --- a/components/form/content/image-detail-form.tsx +++ b/components/form/content/image-detail-form.tsx @@ -66,6 +66,7 @@ import { UnitMapping } from "@/app/[locale]/(protected)/contributor/agenda-setti import SuggestionModal from "@/components/modal/suggestions-modal"; import { formatDateToIndonesian } from "@/utils/globals"; import ApprovalHistoryModal from "@/components/modal/approval-history-modal"; +import Image from "next/image"; const imageSchema = z.object({ title: z.string().min(1, { message: "Judul diperlukan" }), @@ -437,6 +438,22 @@ export default function FormImageDetail() { successCallback(); }; + const [portraitMap, setPortraitMap] = useState({}); + + const handleImageLoad = (e: any, index: number) => { + const { naturalWidth, naturalHeight } = e.target; + const isPortrait = naturalHeight > naturalWidth; + + setPortraitMap((prev: any) => ({ + ...prev, + [index]: isPortrait, + })); + }; + + useEffect(() => { + console.log("portrai", portraitMap); + }, [portraitMap]); + return (
{detail !== undefined ? ( @@ -513,19 +530,19 @@ export default function FormImageDetail() { thumbs={{ swiper: thumbsSwiper }} modules={[FreeMode, Navigation, Thumbs]} navigation={false} - className="w-full" + className="h-[480px] object-cover w-full" > {detailThumb?.map((data: any) => ( {` ))} -
+
( {` @@ -579,11 +596,11 @@ export default function FormImageDetail() {
- + Thumbnail Gambar Utama
@@ -699,119 +716,139 @@ export default function FormImageDetail() { )} */} - + {t("leave-comment")} - {status == "2" - ? files?.map((file, index) => ( -
- -
-
- {file.fileName} - - handleDeleteFileApproval(file.id) - } - > - - +
+ {status == "2" + ? files?.map((file, index) => ( +
+
+ {`files-${index handleImageLoad(e, index)} + className={`h-[100px] object-cover ${ + portraitMap[index] ? "w-auto" : "!w-[200px]" + }`} + />
- {isUserMabesApprover && ( -
-
- - setupPlacement(index, "all", Boolean(e)) - } - /> - -
-
- - setupPlacement(index, "mabes", Boolean(e)) - } - /> - -
-
- - setupPlacement(index, "polda", Boolean(e)) - } - /> - - {wilayahPublish.polda && ( - - setSelectedPolda(data) +
+ + {isUserMabesApprover && ( +
+
+ + setupPlacement(index, "all", Boolean(e)) } /> - )} -
- -
- + {t("all")} + +
+
+ + setupPlacement( + index, + "mabes", + Boolean(e) + ) + } + /> + +
+
+ + setupPlacement( + index, + "polda", + Boolean(e) + ) + } + /> + + {wilayahPublish.polda && ( + + setSelectedPolda(data) + } + /> )} - onCheckedChange={(e) => - setupPlacement( - index, - "international", - Boolean(e) - ) - } - /> - +
+ +
+ + setupPlacement( + index, + "international", + Boolean(e) + ) + } + /> + +
-
- )} + )} +
-
- )) - : ""} + )) + : ""} +