From c7b2456a781d1ba2ebea42700fbdaa823c860ee8 Mon Sep 17 00:00:00 2001 From: Sabda Yagra Date: Tue, 11 Nov 2025 08:33:35 +0700 Subject: [PATCH] fix: conflict in image-update-form --- components/form/content/image-update-form.tsx | 248 ------------------ 1 file changed, 248 deletions(-) diff --git a/components/form/content/image-update-form.tsx b/components/form/content/image-update-form.tsx index 6fc507c6..0eebba89 100644 --- a/components/form/content/image-update-form.tsx +++ b/components/form/content/image-update-form.tsx @@ -247,162 +247,6 @@ export default function FormImageUpdate() { ) as PlacementType[]; }; -<<<<<<< HEAD - setCategories(resCategory); - // console.log("data category", resCategory); - - if (scheduleId && scheduleType === "3") { - const findCategory = resCategory.find((o) => - o.name.toLowerCase().includes("pers rilis") - ); - - if (findCategory) { - // setValue("categoryId", findCategory.id); - setSelectedCategory(findCategory.id); - const response = await getTagsBySubCategoryId(findCategory.id); - setTags(response?.data?.data); - } - } - } catch (error) { - console.error("Failed to fetch categories:", error); - } - }; - - useEffect(() => { - async function initState() { - if (id) { - const response = await detailMedia(id); - const details = response?.data?.data; - - setDetail(details); - - // Set the selected target to the category ID from details - setSelectedTarget(String(details.category.id)); - setTempFile(details?.files); - - setValue("title", details.title); - setValue("description", details.htmlDescription); - setValue("creatorName", details.creatorName); - - setTimeout(() => { - setValue("title", details.title); - setValue("description", details.htmlDescription); - setValue("creatorName", details.creatorName); - }, 500); - - if (details?.files) { - const formattedFiles = details.files.map((file: any) => ({ - ...file, - id: file.id, - fileName: file.fileName, - size: file.size, - thumbnailFileUrl: file.thumbnailFileUrl, - url: file.url, - })); - - setFiles(formattedFiles); - - // Inisialisasi filePlacements dari detail - const initialFilePlacements = details.files.map((file: any) => { - if (file.placements) { - // Map dari format backend ke format internal - const mappedPlacements = file.placements - .split(",") - .map((p: string) => { - const trimmed = p.trim(); - switch (trimmed) { - case "all": - return "all"; - case "mabes": - return "nasional"; - case "polda": - return "wilayah"; - case "satker": - return "satker"; - case "international": - return "international"; - default: - return trimmed; - } - }); - return mappedPlacements; - } - return []; - }); - setFilePlacements(initialFilePlacements); - - // Inisialisasi fileCheckedLevels dari detail - const initialFileCheckedLevels = details.files.map((file: any) => { - if (file.customLocationPlacements) { - const levelIds = file.customLocationPlacements - .split(",") - .map((id: string) => Number(id.trim())) - .filter((id: number) => !isNaN(id)); - return new Set(levelIds); - } - return new Set(); - }); - setFileCheckedLevels(initialFileCheckedLevels); - - // Inisialisasi fileUnitSelections dari detail - const initialFileUnitSelections = details.files.map((file: any) => { - const selection = { - semua: false, - nasional: false, - wilayah: false, - international: false, - polda: false, - satker: false, - }; - - if (file.placements) { - const placements = file.placements - .split(",") - .map((p: string) => p.trim()); - - // Map dari format backend ke checkbox - if (placements.includes("all")) { - selection.semua = true; - selection.nasional = true; - selection.wilayah = true; - selection.international = true; - selection.polda = true; - selection.satker = true; - } else { - if (placements.includes("mabes")) { - selection.nasional = true; - } - if (placements.includes("wilayah")) { - selection.wilayah = true; - } - if (placements.includes("polda")) { - selection.polda = true; - selection.wilayah = true; // Auto-check wilayah when polda is present - } - if (placements.includes("satker")) { - selection.satker = true; - selection.wilayah = true; // Auto-check wilayah when satker is present - } - if (placements.includes("international")) { - selection.international = true; - } - } - } - - return selection; - }); - setFileUnitSelections(initialFileUnitSelections); - } - - if (details?.publishedFor) { - // Split string "7" to an array ["7"] if needed - setPublishedFor(details.publishedFor.split(",")); - } - - if (details?.tags) { - setTags(details.tags.split(",").map((tag: string) => tag.trim())); - } -======= const toggleExpand = (idStr: string) => { setExpandedPolda((prev) => ({ ...prev, [idStr]: !prev[idStr] })); }; @@ -421,7 +265,6 @@ export default function FormImageUpdate() { console.error("Error fetching destinations", e); } finally { setIsLoading(false); ->>>>>>> 5b6ffd086332104beb9f02b1414b48cda3f030a0 } })(); }, []); @@ -984,23 +827,9 @@ export default function FormImageUpdate() { file: any, duration: string ) { -<<<<<<< HEAD - // console.log(idx, id, file, duration); - - // const placements = getPlacement(file.placements); - // console.log("Placementttt: : ", placements); - - const resCsrf = await getCsrfToken(); - const csrfToken = resCsrf?.data?.token; - // console.log("CSRF TOKEN : ", csrfToken); - const headers = { - "X-XSRF-TOKEN": csrfToken, - }; -======= const resCsrf = await getCsrfToken(); const csrfToken = resCsrf?.data?.token; const headers = { "X-XSRF-TOKEN": csrfToken }; ->>>>>>> 5b6ffd086332104beb9f02b1414b48cda3f030a0 if (!file.secondaryUrl || file.secondaryUrl == "") { const upload = new Upload(file, { @@ -1031,10 +860,6 @@ export default function FormImageUpdate() { const percent = Math.floor((bytesAccepted / bytesTotal) * 100); progressInfo[idx].percentage = percent; counterUpdateProgress++; -<<<<<<< HEAD - // console.log(counterUpdateProgress); -======= ->>>>>>> 5b6ffd086332104beb9f02b1414b48cda3f030a0 setProgressList(progressInfo); setCounterProgress(counterUpdateProgress); }, @@ -1253,53 +1078,6 @@ export default function FormImageUpdate() { onChange={(e) => setTranslatedTitle(e.target.value)} placeholder="English version" /> -<<<<<<< HEAD - {errors.title?.message && ( -

- {errors.title.message} -

- )} - */} -
-
- - -
-======= ->>>>>>> 5b6ffd086332104beb9f02b1414b48cda3f030a0
)} @@ -1955,31 +1733,6 @@ export default function FormImageUpdate() { ))} -<<<<<<< HEAD -
- -

- {t("suggestion-box", { defaultValue: "Suggestion Box" })} (0) -

-
-
-

{t("information", { defaultValue: "Information" })}:

- {/*

{detail?.status}

*/} -
- -
-
- -
-
- - - -=======
{/* Publish Target */} @@ -2003,7 +1756,6 @@ export default function FormImageUpdate() {
))} ->>>>>>> 5b6ffd086332104beb9f02b1414b48cda3f030a0