fixing error

This commit is contained in:
hanif salafi 2025-07-24 14:37:12 +07:00
parent 2d6ef04f45
commit 6590743d90
17 changed files with 51 additions and 59 deletions

View File

@ -76,8 +76,7 @@ export default function EditUserForm() {
},
});
const passwordVal = form.watch("password");
const confPasswordVal = form.watch("confirmPassword");
useEffect(() => {
initData();

View File

@ -114,8 +114,7 @@ export default function EditUserForm() {
},
});
const passwordVal = form.watch("password");
const confPasswordVal = form.watch("confirmPassword");
useEffect(() => {
initData();

View File

@ -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();

View File

@ -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();

View File

@ -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();

View File

@ -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({

View File

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

View File

@ -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[]) => {

View File

@ -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<typeof FormSchema>) => {

View File

@ -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))

View File

@ -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)
);
}
}

View File

@ -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)
);
}
}

View File

@ -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)
);
}
}

View File

@ -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)
);
}
}

View File

@ -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)
);
}
}

View File

@ -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() {

View File

@ -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<typeof FormSchema>) => {