diff --git a/app/[locale]/(protected)/contributor/report/components/report-table.tsx b/app/[locale]/(protected)/contributor/report/components/report-table.tsx index 6c942857..976a1e27 100644 --- a/app/[locale]/(protected)/contributor/report/components/report-table.tsx +++ b/app/[locale]/(protected)/contributor/report/components/report-table.tsx @@ -108,7 +108,7 @@ const ReportTable = () => { const [previewData, setPreviewData] = React.useState(null); const handlePreview = (id: string) => { - const url = `https://netidhub.com/api/media/report/view?id=${id}`; + const url = `https://new.netidhub.com/api/media/report/view?id=${id}`; setPreviewData({ url }); setOpenPreview(true); }; diff --git a/components/form/content/audio-detail-form.tsx b/components/form/content/audio-detail-form.tsx index 78bce3b5..7c15c3eb 100644 --- a/components/form/content/audio-detail-form.tsx +++ b/components/form/content/audio-detail-form.tsx @@ -290,15 +290,8 @@ export default function FormAudioDetail() { setSelectedPublishers(publisherIds); } - const matchingCategory = categories.find( - (category) => category.id === details.categoryId - ); - - if (matchingCategory) { - setSelectedTarget(matchingCategory.name); - } - - setSelectedTarget(details?.categoryId); + // Set the selected target to the category ID from details + setSelectedTarget(String(details.category.id)); const filesData = details?.files || []; const audioFiles = filesData.filter( @@ -518,18 +511,28 @@ export default function FormAudioDetail() {
{ // console.log("Selected Category:", id); // setSelectedTarget(id); @@ -501,6 +494,15 @@ export default function FormImageDetail() { + {/* Show the category from details if it doesn't exist in categories list */} + {detail && !categories.find(cat => String(cat.id) === String(detail.category.id)) && ( + + {detail.category.name} + + )} {categories.map((category) => ( {category.name} diff --git a/components/form/content/image-update-form.tsx b/components/form/content/image-update-form.tsx index 1d5f75a0..4f6f0f1a 100644 --- a/components/form/content/image-update-form.tsx +++ b/components/form/content/image-update-form.tsx @@ -69,6 +69,7 @@ type Detail = { description: string; htmldescription: string; slug: string; + categoryId: number; category: { id: string; name: string; @@ -267,6 +268,8 @@ export default function FormImageUpdate() { const details = response?.data?.data; setDetail(details); + + // Set the selected target to the category ID from details setSelectedTarget(String(details.category.id)); // Set form values immediately and then again after a delay to ensure editor is ready @@ -301,16 +304,6 @@ export default function FormImageUpdate() { if (details?.tags) { setTags(details.tags.split(",").map((tag: string) => tag.trim())); } - - // const matchingCategory = categories.find( - // (category) => category.id === details.categoryId - // ); - - // if (matchingCategory) { - // setSelectedTarget(matchingCategory.name); - // } - - // setSelectedTarget(details.categoryId); // Untuk dropdown } } initState(); @@ -716,6 +709,15 @@ export default function FormImageUpdate() { + {/* Show the category from details if it doesn't exist in categories list */} + {detail && !categories.find(cat => String(cat.id) === String(detail.category.id)) && ( + + {detail.category.name} + + )} {categories.map((category) => ( category.id === details.categoryId - ); - - if (matchingCategory) { - setSelectedTarget(matchingCategory.name); - } - - setSelectedTarget(details.categoryId); // Untuk dropdown + // Set the selected target to the category ID from details + setSelectedTarget(String(details.category.id)); const filesData = details.files || []; const fileUrls = filesData.map((file: any) => ({ @@ -467,18 +460,28 @@ export default function FormTeksDetail() {
{ - console.log("Selected Category:", id); - setSelectedTarget(id); - }} + disabled + value={String(detail?.category?.id)} + // onValueChange={(id) => { + // console.log("Selected Category:", id); + // setSelectedTarget(id); + // }} > + {/* Show the category from details if it doesn't exist in categories list */} + {detail && !categories.find(cat => String(cat.id) === String(detail.category.id)) && ( + + {detail.category.name} + + )} {categories.map((category) => ( - + {category.name} ))} diff --git a/components/form/content/video-update-form.tsx b/components/form/content/video-update-form.tsx index 3810fbe7..0cea11d7 100644 --- a/components/form/content/video-update-form.tsx +++ b/components/form/content/video-update-form.tsx @@ -76,7 +76,8 @@ type Detail = { title: string; description: string; slug: string; - categoryId: { + categoryId: number; + category: { id: number; name: string; }; @@ -765,6 +766,15 @@ export default function FormVideoUpdate() { + {/* Show the category from details if it doesn't exist in categories list */} + {detail && !categories.find(cat => String(cat.id) === String(detail.category.id)) && ( + + {detail.category.name} + + )} {categories.map((category) => (