fixing error
This commit is contained in:
parent
2d6ef04f45
commit
6590743d90
|
|
@ -76,8 +76,7 @@ export default function EditUserForm() {
|
|||
},
|
||||
});
|
||||
|
||||
const passwordVal = form.watch("password");
|
||||
const confPasswordVal = form.watch("confirmPassword");
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
initData();
|
||||
|
|
|
|||
|
|
@ -114,8 +114,7 @@ export default function EditUserForm() {
|
|||
},
|
||||
});
|
||||
|
||||
const passwordVal = form.watch("password");
|
||||
const confPasswordVal = form.watch("confirmPassword");
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
initData();
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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({
|
||||
|
|
|
|||
|
|
@ -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(() => {
|
||||
|
|
|
|||
|
|
@ -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[]) => {
|
||||
|
|
|
|||
|
|
@ -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>) => {
|
||||
|
|
|
|||
|
|
@ -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))
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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() {
|
||||
|
|
|
|||
|
|
@ -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>) => {
|
||||
|
|
|
|||
Loading…
Reference in New Issue