diff --git a/app/[locale]/(protected)/admin/settings/category/component/edit.tsx b/app/[locale]/(protected)/admin/settings/category/component/edit.tsx index aebf2356..32fb17f5 100644 --- a/app/[locale]/(protected)/admin/settings/category/component/edit.tsx +++ b/app/[locale]/(protected)/admin/settings/category/component/edit.tsx @@ -146,12 +146,12 @@ export default function EditCategoryModal(props: { form.setValue("id", String(data?.id)); form.setValue("title", String(data?.name)); form.setValue("description", String(data?.description)); - form.setValue("contentType", data?.mediaTypes?.split(",")); + form.setValue("contentType", data?.mediaTypes?.split(",") || []); form.setValue( "selectedUser", removeAndReturn(data?.publishedFor, [2, 3, 4]) ); - form.setValue("publishTo", data?.publishedLocation?.split(",")); + form.setValue("publishTo", data?.publishedLocation?.split(",") || []); form.setValue("file", thumbnailLink); setUnitData(filterString(data?.publishedLocationLevel, "under")); diff --git a/app/[locale]/(protected)/curator/task-plan/mediahub/create-daily/detail/[id]/page.tsx b/app/[locale]/(protected)/curator/task-plan/mediahub/create-daily/detail/[id]/page.tsx index bfac22e5..a08a3594 100644 --- a/app/[locale]/(protected)/curator/task-plan/mediahub/create-daily/detail/[id]/page.tsx +++ b/app/[locale]/(protected)/curator/task-plan/mediahub/create-daily/detail/[id]/page.tsx @@ -301,7 +301,7 @@ export default function DetailDaily() { const handleItemCheckedChange = (id: string, checked: boolean | string) => { form.setValue( "output", - checked ? [...output, id] : output.filter((value) => value !== id) + checked ? [...(output ?? []), id] : (output ?? []).filter((value) => value !== id) ); }; @@ -318,7 +318,7 @@ export default function DetailDaily() { const handleUnitCheckedChange = (id: string, checked: boolean | string) => { if (checked) { - form.setValue("unit", [...unit, id]); + form.setValue("unit", [...(unit ?? []), id]); } else { if (id == "2") { const temp = []; diff --git a/app/[locale]/(protected)/curator/task-plan/mediahub/create-daily/edit/[id]/page.tsx b/app/[locale]/(protected)/curator/task-plan/mediahub/create-daily/edit/[id]/page.tsx index 507660c6..744c351c 100644 --- a/app/[locale]/(protected)/curator/task-plan/mediahub/create-daily/edit/[id]/page.tsx +++ b/app/[locale]/(protected)/curator/task-plan/mediahub/create-daily/edit/[id]/page.tsx @@ -314,7 +314,7 @@ export default function EditDaily() { const handleItemCheckedChange = (id: string, checked: boolean | string) => { form.setValue( "output", - checked ? [...output, id] : output.filter((value) => value !== id) + checked ? [...(output ?? []), id] : (output ?? []).filter((value) => value !== id) ); }; @@ -331,7 +331,7 @@ export default function EditDaily() { const handleUnitCheckedChange = (id: string, checked: boolean | string) => { if (checked) { - form.setValue("unit", [...unit, id]); + form.setValue("unit", [...(unit ?? []), id]); } else { if (id == "2") { const temp = []; diff --git a/app/[locale]/(protected)/curator/task-plan/mediahub/create-daily/page.tsx b/app/[locale]/(protected)/curator/task-plan/mediahub/create-daily/page.tsx index 59f50b12..4e779f6c 100644 --- a/app/[locale]/(protected)/curator/task-plan/mediahub/create-daily/page.tsx +++ b/app/[locale]/(protected)/curator/task-plan/mediahub/create-daily/page.tsx @@ -262,7 +262,7 @@ export default function CreateDaily() { const handleItemCheckedChange = (id: string, checked: boolean | string) => { form.setValue( "output", - checked ? [...output, id] : output.filter((value) => value !== id) + checked ? [...(output ?? []), id] : (output ?? []).filter((value) => value !== id) ); }; @@ -279,7 +279,7 @@ export default function CreateDaily() { const handleUnitCheckedChange = (id: string, checked: boolean | string) => { if (checked) { - form.setValue("unit", [...unit, id]); + form.setValue("unit", [...(unit ?? []), id]); } else { if (id == "2") { const temp = []; diff --git a/app/[locale]/(protected)/curator/task-plan/medsos-mediahub/create-daily/detail/[id]/page.tsx b/app/[locale]/(protected)/curator/task-plan/medsos-mediahub/create-daily/detail/[id]/page.tsx index 24c5c0d3..f9566647 100644 --- a/app/[locale]/(protected)/curator/task-plan/medsos-mediahub/create-daily/detail/[id]/page.tsx +++ b/app/[locale]/(protected)/curator/task-plan/medsos-mediahub/create-daily/detail/[id]/page.tsx @@ -301,7 +301,7 @@ export default function DetailDaily() { const handleItemCheckedChange = (id: string, checked: boolean | string) => { form.setValue( "output", - checked ? [...output, id] : output.filter((value) => value !== id) + checked ? [...(output ?? []), id] : (output ?? []).filter((value) => value !== id) ); }; diff --git a/app/[locale]/(protected)/curator/task-plan/medsos-mediahub/create-daily/edit/[id]/page.tsx b/app/[locale]/(protected)/curator/task-plan/medsos-mediahub/create-daily/edit/[id]/page.tsx index 160a16a4..ad77714f 100644 --- a/app/[locale]/(protected)/curator/task-plan/medsos-mediahub/create-daily/edit/[id]/page.tsx +++ b/app/[locale]/(protected)/curator/task-plan/medsos-mediahub/create-daily/edit/[id]/page.tsx @@ -314,7 +314,7 @@ export default function EditDaily() { const handleItemCheckedChange = (id: string, checked: boolean | string) => { form.setValue( "output", - checked ? [...output, id] : output.filter((value) => value !== id) + checked ? [...(output ?? []), id] : (output ?? []).filter((value) => value !== id) ); }; @@ -331,7 +331,7 @@ export default function EditDaily() { const handleUnitCheckedChange = (id: string, checked: boolean | string) => { if (checked) { - form.setValue("unit", [...unit, id]); + form.setValue("unit", [...(unit ?? []), id]); } else { if (id == "2") { const temp = []; diff --git a/app/[locale]/(protected)/curator/task-plan/medsos-mediahub/create-daily/page.tsx b/app/[locale]/(protected)/curator/task-plan/medsos-mediahub/create-daily/page.tsx index 857fe674..17abc374 100644 --- a/app/[locale]/(protected)/curator/task-plan/medsos-mediahub/create-daily/page.tsx +++ b/app/[locale]/(protected)/curator/task-plan/medsos-mediahub/create-daily/page.tsx @@ -398,10 +398,8 @@ export default function CreateDaily() { form.setValue( "output", checked - ? [...output, item.id] - : output.filter( - (value) => value !== item.id - ) + ? [...(output ?? []), item.id] + : (output ?? []).filter((value) => value !== item.id) ); }} /> @@ -470,10 +468,8 @@ export default function CreateDaily() { form.setValue( "unit", checked - ? [...unit, item.id] - : unit.filter( - (value) => value !== item.id - ) + ? [...(unit ?? []), item.id] + : (unit ?? []).filter((value) => value !== item.id) ); }} /> @@ -648,8 +644,8 @@ export default function CreateDaily() { form.setValue( "media", checked - ? [...media, item.id] - : media.filter( + ? [...(media ?? []), item.id] + : (media ?? []).filter( (value) => value !== item.id ) );