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) => {