From 2d6ef04f45534eadb602170566054b6ab8c556e3 Mon Sep 17 00:00:00 2001 From: hanif salafi Date: Thu, 24 Jul 2025 14:19:15 +0700 Subject: [PATCH 1/4] fixing error --- .../admin/settings/category/component/edit.tsx | 4 ++-- .../mediahub/create-daily/detail/[id]/page.tsx | 4 ++-- .../mediahub/create-daily/edit/[id]/page.tsx | 4 ++-- .../task-plan/mediahub/create-daily/page.tsx | 4 ++-- .../create-daily/detail/[id]/page.tsx | 2 +- .../create-daily/edit/[id]/page.tsx | 4 ++-- .../medsos-mediahub/create-daily/page.tsx | 16 ++++++---------- 7 files changed, 17 insertions(+), 21 deletions(-) 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 ) ); From 6590743d90613a3966d969597c388d8f5f64b8e6 Mon Sep 17 00:00:00 2001 From: hanif salafi Date: Thu, 24 Jul 2025 14:37:12 +0700 Subject: [PATCH 2/4] fixing error --- .../management-user/external/detail/[id]/page.tsx | 3 +-- .../admin/management-user/external/edit/[id]/page.tsx | 3 +-- .../admin/management-user/internal/create/page.tsx | 4 +--- .../management-user/internal/detail/[id]/page.tsx | 4 +--- .../admin/management-user/internal/edit/[id]/page.tsx | 4 +--- .../admin/settings/category/component/create.tsx | 10 +++++----- .../admin/settings/category/component/edit.tsx | 10 +++++----- .../admin/settings/category/component/unit-mapping.tsx | 8 ++++---- .../admin/settings/faq/component/create.tsx | 4 ++-- .../contributor/agenda-setting/unit-mapping.tsx | 8 ++++---- .../mediahub/create-daily/detail/[id]/page.tsx | 8 ++++---- .../task-plan/mediahub/create-daily/edit/[id]/page.tsx | 8 ++++---- .../curator/task-plan/mediahub/create-daily/page.tsx | 8 ++++---- .../medsos-mediahub/create-daily/detail/[id]/page.tsx | 10 +++++----- .../medsos-mediahub/create-daily/edit/[id]/page.tsx | 8 ++++---- .../task-plan/medsos-mediahub/create-daily/page.tsx | 6 +++--- .../(protected)/supervisor/faq/components/create.tsx | 4 ++-- 17 files changed, 51 insertions(+), 59 deletions(-) diff --git a/app/[locale]/(protected)/admin/management-user/external/detail/[id]/page.tsx b/app/[locale]/(protected)/admin/management-user/external/detail/[id]/page.tsx index e72f21c6..f8a2432a 100644 --- a/app/[locale]/(protected)/admin/management-user/external/detail/[id]/page.tsx +++ b/app/[locale]/(protected)/admin/management-user/external/detail/[id]/page.tsx @@ -76,8 +76,7 @@ export default function EditUserForm() { }, }); - const passwordVal = form.watch("password"); - const confPasswordVal = form.watch("confirmPassword"); + useEffect(() => { initData(); diff --git a/app/[locale]/(protected)/admin/management-user/external/edit/[id]/page.tsx b/app/[locale]/(protected)/admin/management-user/external/edit/[id]/page.tsx index 38f63d1f..ccab876f 100644 --- a/app/[locale]/(protected)/admin/management-user/external/edit/[id]/page.tsx +++ b/app/[locale]/(protected)/admin/management-user/external/edit/[id]/page.tsx @@ -114,8 +114,7 @@ export default function EditUserForm() { }, }); - const passwordVal = form.watch("password"); - const confPasswordVal = form.watch("confirmPassword"); + useEffect(() => { initData(); diff --git a/app/[locale]/(protected)/admin/management-user/internal/create/page.tsx b/app/[locale]/(protected)/admin/management-user/internal/create/page.tsx index 7311a6ac..818e90b6 100644 --- a/app/[locale]/(protected)/admin/management-user/internal/create/page.tsx +++ b/app/[locale]/(protected)/admin/management-user/internal/create/page.tsx @@ -192,9 +192,7 @@ export default function CreateUserForm() { }, }); - const passwordVal = form.watch("password"); - const confPasswordVal = form.watch("confirmPassword"); - const selectedRole = form.watch("role"); + useEffect(() => { initFetch(); diff --git a/app/[locale]/(protected)/admin/management-user/internal/detail/[id]/page.tsx b/app/[locale]/(protected)/admin/management-user/internal/detail/[id]/page.tsx index 4be86550..23bea489 100644 --- a/app/[locale]/(protected)/admin/management-user/internal/detail/[id]/page.tsx +++ b/app/[locale]/(protected)/admin/management-user/internal/detail/[id]/page.tsx @@ -191,9 +191,7 @@ export default function DetailUserForm() { }, }); - const passwordVal = form.watch("password"); - const confPasswordVal = form.watch("confirmPassword"); - const selectedRole = form.watch("role"); + useEffect(() => { getDataAdditional(); diff --git a/app/[locale]/(protected)/admin/management-user/internal/edit/[id]/page.tsx b/app/[locale]/(protected)/admin/management-user/internal/edit/[id]/page.tsx index 7cbeb810..81f8095e 100644 --- a/app/[locale]/(protected)/admin/management-user/internal/edit/[id]/page.tsx +++ b/app/[locale]/(protected)/admin/management-user/internal/edit/[id]/page.tsx @@ -195,9 +195,7 @@ export default function EditUserForm() { }, }); - const passwordVal = form.watch("password"); - const confPasswordVal = form.watch("confirmPassword"); - const selectedRole = form.watch("role"); + useEffect(() => { getDataAdditional(); diff --git a/app/[locale]/(protected)/admin/settings/category/component/create.tsx b/app/[locale]/(protected)/admin/settings/category/component/create.tsx index 569aaa32..c3a1f512 100644 --- a/app/[locale]/(protected)/admin/settings/category/component/create.tsx +++ b/app/[locale]/(protected)/admin/settings/category/component/create.tsx @@ -125,16 +125,16 @@ export default function CreateCategoryModal() { }); const contentType = form.watch("contentType"); - const isAllContentChecked = listContent.every((item) => - contentType?.includes(item.id) + const isAllContentChecked = contentType && listContent.every((item) => + contentType.includes(item.id) ); const users = form.watch("selectedUser"); - const isAllUserChecked = userList.every((item) => users?.includes(item.id)); + const isAllUserChecked = users && userList.every((item) => users.includes(item.id)); const target = form.watch("publishTo"); - const isAllTargetChecked = publishToList.every((item) => - target?.includes(item.id) + const isAllTargetChecked = target && publishToList.every((item) => + target.includes(item.id) ); const { getRootProps, getInputProps } = useDropzone({ diff --git a/app/[locale]/(protected)/admin/settings/category/component/edit.tsx b/app/[locale]/(protected)/admin/settings/category/component/edit.tsx index 32fb17f5..249992cd 100644 --- a/app/[locale]/(protected)/admin/settings/category/component/edit.tsx +++ b/app/[locale]/(protected)/admin/settings/category/component/edit.tsx @@ -183,16 +183,16 @@ export default function EditCategoryModal(props: { } const contentType = form.watch("contentType"); - const isAllContentChecked = listContent.every((item) => - contentType?.includes(item.id) + const isAllContentChecked = contentType && listContent.every((item) => + contentType.includes(item.id) ); const users = form.watch("selectedUser"); - const isAllUserChecked = userList.every((item) => users?.includes(item.id)); + const isAllUserChecked = users && userList.every((item) => users.includes(item.id)); const target = form.watch("publishTo"); - const isAllTargetChecked = publishToList.every((item) => - target?.includes(item.id) + const isAllTargetChecked = target && publishToList.every((item) => + target.includes(item.id) ); useEffect(() => { diff --git a/app/[locale]/(protected)/admin/settings/category/component/unit-mapping.tsx b/app/[locale]/(protected)/admin/settings/category/component/unit-mapping.tsx index 34f037d6..109583ed 100644 --- a/app/[locale]/(protected)/admin/settings/category/component/unit-mapping.tsx +++ b/app/[locale]/(protected)/admin/settings/category/component/unit-mapping.tsx @@ -68,11 +68,11 @@ export function UnitMapping(props: { const unitType = form.watch("items"); - const isAllUnitChecked = unitList.every((item) => - unitType?.includes(String(item.id)) + const isAllUnitChecked = unitType && unitList.every((item) => + unitType.includes(String(item.id)) ); - const isAllSatkerChecked = satkerList.every((item) => - unitType?.includes(String(item.id)) + const isAllSatkerChecked = unitType && satkerList.every((item) => + unitType.includes(String(item.id)) ); const setupUnit = (data: UnitType[]) => { diff --git a/app/[locale]/(protected)/admin/settings/faq/component/create.tsx b/app/[locale]/(protected)/admin/settings/faq/component/create.tsx index 504d9fa5..c2de04e6 100644 --- a/app/[locale]/(protected)/admin/settings/faq/component/create.tsx +++ b/app/[locale]/(protected)/admin/settings/faq/component/create.tsx @@ -91,8 +91,8 @@ export default function CreateFAQModal() { }); const target = form.watch("publishTo"); - const isAllTargetChecked = publishToList.every((item) => - target?.includes(item.id) + const isAllTargetChecked = target && publishToList.every((item) => + target.includes(item.id) ); const onSubmit = async (data: z.infer) => { diff --git a/app/[locale]/(protected)/contributor/agenda-setting/unit-mapping.tsx b/app/[locale]/(protected)/contributor/agenda-setting/unit-mapping.tsx index aea59fb3..622519a7 100644 --- a/app/[locale]/(protected)/contributor/agenda-setting/unit-mapping.tsx +++ b/app/[locale]/(protected)/contributor/agenda-setting/unit-mapping.tsx @@ -74,11 +74,11 @@ export function UnitMapping(props: { const unitType = form.watch("items"); - const isAllUnitChecked = unitList.every((item) => - unitType?.includes(String(item.id)) + const isAllUnitChecked = unitType && unitList.every((item) => + unitType.includes(String(item.id)) ); - const isAllSatkerChecked = satkerList.every((item) => - unitType?.includes(String(item.id)) + const isAllSatkerChecked = unitType && satkerList.every((item) => + unitType.includes(String(item.id)) ); const isAllPolresChecked = polresList.every((item) => unitType?.includes(String(item.id)) 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 a08a3594..1b0bf930 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 @@ -281,11 +281,11 @@ export default function DetailDaily() { const output = form.watch("output"); - const isAllChecked = items.every((item) => output?.includes(item.id)); + const isAllChecked = output && items.every((item) => output.includes(item.id)); const unit = form.watch("unit"); - const isAllUnitChecked = units.every((item) => unit?.includes(item.id)); + const isAllUnitChecked = unit && units.every((item) => unit.includes(item.id)); const handleAllCheckedChange = (checked: boolean | string) => { if (checked) { @@ -322,7 +322,7 @@ export default function DetailDaily() { } else { if (id == "2") { const temp = []; - for (const element of unit) { + for (const element of unit ?? []) { if (element == "1") { temp.push("1"); } @@ -331,7 +331,7 @@ export default function DetailDaily() { } else { form.setValue( "unit", - unit.filter((value) => value !== id) + (unit ?? []).filter((value) => value !== id) ); } } 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 744c351c..2d9e6958 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 @@ -294,11 +294,11 @@ export default function EditDaily() { const output = form.watch("output"); - const isAllChecked = items.every((item) => output?.includes(item.id)); + const isAllChecked = output && items.every((item) => output.includes(item.id)); const unit = form.watch("unit"); - const isAllUnitChecked = units.every((item) => unit?.includes(item.id)); + const isAllUnitChecked = unit && units.every((item) => unit.includes(item.id)); const handleAllCheckedChange = (checked: boolean | string) => { if (checked) { @@ -335,7 +335,7 @@ export default function EditDaily() { } else { if (id == "2") { const temp = []; - for (const element of unit) { + for (const element of unit ?? []) { if (element == "1") { temp.push("1"); } @@ -344,7 +344,7 @@ export default function EditDaily() { } else { form.setValue( "unit", - unit.filter((value) => value !== id) + (unit ?? []).filter((value) => value !== id) ); } } 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 4e779f6c..d7c07553 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 @@ -242,11 +242,11 @@ export default function CreateDaily() { const output = form.watch("output"); - const isAllChecked = items.every((item) => output?.includes(item.id)); + const isAllChecked = output && items.every((item) => output.includes(item.id)); const unit = form.watch("unit"); - const isAllUnitChecked = units.every((item) => unit?.includes(item.id)); + const isAllUnitChecked = unit && units.every((item) => unit.includes(item.id)); const handleAllCheckedChange = (checked: boolean | string) => { if (checked) { @@ -283,7 +283,7 @@ export default function CreateDaily() { } else { if (id == "2") { const temp = []; - for (const element of unit) { + for (const element of unit ?? []) { if (element == "1") { temp.push("1"); } @@ -292,7 +292,7 @@ export default function CreateDaily() { } else { form.setValue( "unit", - unit.filter((value) => value !== id) + (unit ?? []).filter((value) => value !== id) ); } } 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 f9566647..42b00511 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 @@ -281,11 +281,11 @@ export default function DetailDaily() { const output = form.watch("output"); - const isAllChecked = items.every((item) => output?.includes(item.id)); + const isAllChecked = output && items.every((item) => output.includes(item.id)); const unit = form.watch("unit"); - const isAllUnitChecked = units.every((item) => unit?.includes(item.id)); + const isAllUnitChecked = unit && units.every((item) => unit.includes(item.id)); const handleAllCheckedChange = (checked: boolean | string) => { if (checked) { @@ -318,11 +318,11 @@ 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 = []; - for (const element of unit) { + for (const element of unit ?? []) { if (element == "1") { temp.push("1"); } @@ -331,7 +331,7 @@ export default function DetailDaily() { } else { form.setValue( "unit", - unit.filter((value) => value !== id) + (unit ?? []).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 ad77714f..7ab95115 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 @@ -294,11 +294,11 @@ export default function EditDaily() { const output = form.watch("output"); - const isAllChecked = items.every((item) => output?.includes(item.id)); + const isAllChecked = output && items.every((item) => output.includes(item.id)); const unit = form.watch("unit"); - const isAllUnitChecked = units.every((item) => unit?.includes(item.id)); + const isAllUnitChecked = unit && units.every((item) => unit.includes(item.id)); const handleAllCheckedChange = (checked: boolean | string) => { if (checked) { @@ -335,7 +335,7 @@ export default function EditDaily() { } else { if (id == "2") { const temp = []; - for (const element of unit) { + for (const element of unit ?? []) { if (element == "1") { temp.push("1"); } @@ -344,7 +344,7 @@ export default function EditDaily() { } else { form.setValue( "unit", - unit.filter((value) => value !== id) + (unit ?? []).filter((value) => value !== id) ); } } 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 17abc374..11354f29 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 @@ -264,9 +264,9 @@ export default function CreateDaily() { const media = form.watch("media"); const unit = form.watch("unit"); - const isAllChecked = items.every((item) => output?.includes(item.id)); - const isAllMediaChecked = medias.every((item) => media?.includes(item.id)); - const isAllUnitChecked = units.every((item) => unit?.includes(item.id)); + const isAllChecked = output && items.every((item) => output.includes(item.id)); + const isAllMediaChecked = media && medias.every((item) => media.includes(item.id)); + const isAllUnitChecked = unit && units.every((item) => unit.includes(item.id)); useEffect(() => { async function initState() { diff --git a/app/[locale]/(protected)/supervisor/faq/components/create.tsx b/app/[locale]/(protected)/supervisor/faq/components/create.tsx index a5af317c..4000890b 100644 --- a/app/[locale]/(protected)/supervisor/faq/components/create.tsx +++ b/app/[locale]/(protected)/supervisor/faq/components/create.tsx @@ -81,8 +81,8 @@ export default function CreateSpvFAQModal() { }); const target = form.watch("publishTo"); - const isAllTargetChecked = publishToList.every((item) => - target?.includes(item.id) + const isAllTargetChecked = target && publishToList.every((item) => + target.includes(item.id) ); const onSubmit = async (data: z.infer) => { From 66cfb09a46442ca779629cec7899672ddac9d1c8 Mon Sep 17 00:00:00 2001 From: hanif salafi Date: Thu, 24 Jul 2025 14:52:59 +0700 Subject: [PATCH 3/4] fixing error --- .../admin/management-user/external/detail/[id]/page.tsx | 2 -- .../admin/management-user/external/edit/[id]/page.tsx | 5 +++-- .../admin/management-user/internal/create/page.tsx | 6 ++++-- .../admin/management-user/internal/detail/[id]/page.tsx | 2 +- .../admin/management-user/internal/edit/[id]/page.tsx | 6 ++++-- 5 files changed, 12 insertions(+), 9 deletions(-) diff --git a/app/[locale]/(protected)/admin/management-user/external/detail/[id]/page.tsx b/app/[locale]/(protected)/admin/management-user/external/detail/[id]/page.tsx index f8a2432a..ad272826 100644 --- a/app/[locale]/(protected)/admin/management-user/external/detail/[id]/page.tsx +++ b/app/[locale]/(protected)/admin/management-user/external/detail/[id]/page.tsx @@ -76,8 +76,6 @@ export default function EditUserForm() { }, }); - - useEffect(() => { initData(); }, []); diff --git a/app/[locale]/(protected)/admin/management-user/external/edit/[id]/page.tsx b/app/[locale]/(protected)/admin/management-user/external/edit/[id]/page.tsx index ccab876f..ed402dc7 100644 --- a/app/[locale]/(protected)/admin/management-user/external/edit/[id]/page.tsx +++ b/app/[locale]/(protected)/admin/management-user/external/edit/[id]/page.tsx @@ -114,7 +114,8 @@ export default function EditUserForm() { }, }); - + const passwordVal = form.watch("password"); + const confPasswordVal = form.watch("confirmPassword"); useEffect(() => { initData(); @@ -353,7 +354,7 @@ export default function EditUserForm() { rules={["minLength", "specialChar", "number", "capital", "match"]} minLength={8} value={passwordVal || ""} - valueAgain={confPasswordVal} + valueAgain={confPasswordVal || ""} onChange={(isValid) => { form.setValue("isValidPassword", isValid); }} diff --git a/app/[locale]/(protected)/admin/management-user/internal/create/page.tsx b/app/[locale]/(protected)/admin/management-user/internal/create/page.tsx index 818e90b6..ba4eb2de 100644 --- a/app/[locale]/(protected)/admin/management-user/internal/create/page.tsx +++ b/app/[locale]/(protected)/admin/management-user/internal/create/page.tsx @@ -192,7 +192,9 @@ export default function CreateUserForm() { }, }); - + const passwordVal = form.watch("password"); + const confPasswordVal = form.watch("confirmPassword"); + const selectedRole = form.watch("role"); useEffect(() => { initFetch(); @@ -750,7 +752,7 @@ export default function CreateUserForm() { rules={["minLength", "specialChar", "number", "capital", "match"]} minLength={8} value={passwordVal || ""} - valueAgain={confPasswordVal} + valueAgain={confPasswordVal || ""} onChange={(isValid) => { form.setValue("isValidPassword", isValid); }} diff --git a/app/[locale]/(protected)/admin/management-user/internal/detail/[id]/page.tsx b/app/[locale]/(protected)/admin/management-user/internal/detail/[id]/page.tsx index 23bea489..cec7845c 100644 --- a/app/[locale]/(protected)/admin/management-user/internal/detail/[id]/page.tsx +++ b/app/[locale]/(protected)/admin/management-user/internal/detail/[id]/page.tsx @@ -191,7 +191,7 @@ export default function DetailUserForm() { }, }); - + const selectedRole = form.watch("role"); useEffect(() => { getDataAdditional(); diff --git a/app/[locale]/(protected)/admin/management-user/internal/edit/[id]/page.tsx b/app/[locale]/(protected)/admin/management-user/internal/edit/[id]/page.tsx index 81f8095e..d21b5135 100644 --- a/app/[locale]/(protected)/admin/management-user/internal/edit/[id]/page.tsx +++ b/app/[locale]/(protected)/admin/management-user/internal/edit/[id]/page.tsx @@ -195,7 +195,9 @@ export default function EditUserForm() { }, }); - + const passwordVal = form.watch("password"); + const confPasswordVal = form.watch("confirmPassword"); + const selectedRole = form.watch("role"); useEffect(() => { getDataAdditional(); @@ -755,7 +757,7 @@ export default function EditUserForm() { rules={["minLength", "specialChar", "number", "capital", "match"]} minLength={8} value={passwordVal || ""} - valueAgain={confPasswordVal} + valueAgain={confPasswordVal || ""} onChange={(isValid) => { form.setValue("isValidPassword", isValid); }} From c4c854a37a8aca2ebecc52b5fa4ce8963386a5df Mon Sep 17 00:00:00 2001 From: hanif salafi Date: Thu, 24 Jul 2025 15:16:02 +0700 Subject: [PATCH 4/4] fixing error --- .../mediahub/create-daily/detail/[id]/page.tsx | 12 ++++++------ .../mediahub/create-daily/edit/[id]/page.tsx | 14 +++++++------- .../task-plan/mediahub/create-daily/page.tsx | 14 +++++++------- .../create-daily/detail/[id]/page.tsx | 12 ++++++------ .../create-daily/edit/[id]/page.tsx | 14 +++++++------- .../medsos-mediahub/create-daily/page.tsx | 14 +++++++------- 6 files changed, 40 insertions(+), 40 deletions(-) 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 1b0bf930..bc3e5de7 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 @@ -542,14 +542,14 @@ export default function DetailDaily() { id={list.id} name={`all${list.id}`} checked={ - unit.includes("2") + unit?.includes("2") ?? false ? true : !!selected[list.id] } onCheckedChange={() => handleParentChange(list.id) } - disabled={unit.includes("2")} + disabled={unit?.includes("2") ?? false} />