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(() => {
|
useEffect(() => {
|
||||||
initData();
|
initData();
|
||||||
|
|
|
||||||
|
|
@ -114,8 +114,7 @@ export default function EditUserForm() {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const passwordVal = form.watch("password");
|
|
||||||
const confPasswordVal = form.watch("confirmPassword");
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
initData();
|
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(() => {
|
useEffect(() => {
|
||||||
initFetch();
|
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(() => {
|
useEffect(() => {
|
||||||
getDataAdditional();
|
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(() => {
|
useEffect(() => {
|
||||||
getDataAdditional();
|
getDataAdditional();
|
||||||
|
|
|
||||||
|
|
@ -125,16 +125,16 @@ export default function CreateCategoryModal() {
|
||||||
});
|
});
|
||||||
|
|
||||||
const contentType = form.watch("contentType");
|
const contentType = form.watch("contentType");
|
||||||
const isAllContentChecked = listContent.every((item) =>
|
const isAllContentChecked = contentType && listContent.every((item) =>
|
||||||
contentType?.includes(item.id)
|
contentType.includes(item.id)
|
||||||
);
|
);
|
||||||
|
|
||||||
const users = form.watch("selectedUser");
|
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 target = form.watch("publishTo");
|
||||||
const isAllTargetChecked = publishToList.every((item) =>
|
const isAllTargetChecked = target && publishToList.every((item) =>
|
||||||
target?.includes(item.id)
|
target.includes(item.id)
|
||||||
);
|
);
|
||||||
|
|
||||||
const { getRootProps, getInputProps } = useDropzone({
|
const { getRootProps, getInputProps } = useDropzone({
|
||||||
|
|
|
||||||
|
|
@ -183,16 +183,16 @@ export default function EditCategoryModal(props: {
|
||||||
}
|
}
|
||||||
|
|
||||||
const contentType = form.watch("contentType");
|
const contentType = form.watch("contentType");
|
||||||
const isAllContentChecked = listContent.every((item) =>
|
const isAllContentChecked = contentType && listContent.every((item) =>
|
||||||
contentType?.includes(item.id)
|
contentType.includes(item.id)
|
||||||
);
|
);
|
||||||
|
|
||||||
const users = form.watch("selectedUser");
|
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 target = form.watch("publishTo");
|
||||||
const isAllTargetChecked = publishToList.every((item) =>
|
const isAllTargetChecked = target && publishToList.every((item) =>
|
||||||
target?.includes(item.id)
|
target.includes(item.id)
|
||||||
);
|
);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|
|
||||||
|
|
@ -68,11 +68,11 @@ export function UnitMapping(props: {
|
||||||
|
|
||||||
const unitType = form.watch("items");
|
const unitType = form.watch("items");
|
||||||
|
|
||||||
const isAllUnitChecked = unitList.every((item) =>
|
const isAllUnitChecked = unitType && unitList.every((item) =>
|
||||||
unitType?.includes(String(item.id))
|
unitType.includes(String(item.id))
|
||||||
);
|
);
|
||||||
const isAllSatkerChecked = satkerList.every((item) =>
|
const isAllSatkerChecked = unitType && satkerList.every((item) =>
|
||||||
unitType?.includes(String(item.id))
|
unitType.includes(String(item.id))
|
||||||
);
|
);
|
||||||
|
|
||||||
const setupUnit = (data: UnitType[]) => {
|
const setupUnit = (data: UnitType[]) => {
|
||||||
|
|
|
||||||
|
|
@ -91,8 +91,8 @@ export default function CreateFAQModal() {
|
||||||
});
|
});
|
||||||
|
|
||||||
const target = form.watch("publishTo");
|
const target = form.watch("publishTo");
|
||||||
const isAllTargetChecked = publishToList.every((item) =>
|
const isAllTargetChecked = target && publishToList.every((item) =>
|
||||||
target?.includes(item.id)
|
target.includes(item.id)
|
||||||
);
|
);
|
||||||
|
|
||||||
const onSubmit = async (data: z.infer<typeof FormSchema>) => {
|
const onSubmit = async (data: z.infer<typeof FormSchema>) => {
|
||||||
|
|
|
||||||
|
|
@ -74,11 +74,11 @@ export function UnitMapping(props: {
|
||||||
|
|
||||||
const unitType = form.watch("items");
|
const unitType = form.watch("items");
|
||||||
|
|
||||||
const isAllUnitChecked = unitList.every((item) =>
|
const isAllUnitChecked = unitType && unitList.every((item) =>
|
||||||
unitType?.includes(String(item.id))
|
unitType.includes(String(item.id))
|
||||||
);
|
);
|
||||||
const isAllSatkerChecked = satkerList.every((item) =>
|
const isAllSatkerChecked = unitType && satkerList.every((item) =>
|
||||||
unitType?.includes(String(item.id))
|
unitType.includes(String(item.id))
|
||||||
);
|
);
|
||||||
const isAllPolresChecked = polresList.every((item) =>
|
const isAllPolresChecked = polresList.every((item) =>
|
||||||
unitType?.includes(String(item.id))
|
unitType?.includes(String(item.id))
|
||||||
|
|
|
||||||
|
|
@ -281,11 +281,11 @@ export default function DetailDaily() {
|
||||||
|
|
||||||
const output = form.watch("output");
|
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 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) => {
|
const handleAllCheckedChange = (checked: boolean | string) => {
|
||||||
if (checked) {
|
if (checked) {
|
||||||
|
|
@ -322,7 +322,7 @@ export default function DetailDaily() {
|
||||||
} else {
|
} else {
|
||||||
if (id == "2") {
|
if (id == "2") {
|
||||||
const temp = [];
|
const temp = [];
|
||||||
for (const element of unit) {
|
for (const element of unit ?? []) {
|
||||||
if (element == "1") {
|
if (element == "1") {
|
||||||
temp.push("1");
|
temp.push("1");
|
||||||
}
|
}
|
||||||
|
|
@ -331,7 +331,7 @@ export default function DetailDaily() {
|
||||||
} else {
|
} else {
|
||||||
form.setValue(
|
form.setValue(
|
||||||
"unit",
|
"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 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 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) => {
|
const handleAllCheckedChange = (checked: boolean | string) => {
|
||||||
if (checked) {
|
if (checked) {
|
||||||
|
|
@ -335,7 +335,7 @@ export default function EditDaily() {
|
||||||
} else {
|
} else {
|
||||||
if (id == "2") {
|
if (id == "2") {
|
||||||
const temp = [];
|
const temp = [];
|
||||||
for (const element of unit) {
|
for (const element of unit ?? []) {
|
||||||
if (element == "1") {
|
if (element == "1") {
|
||||||
temp.push("1");
|
temp.push("1");
|
||||||
}
|
}
|
||||||
|
|
@ -344,7 +344,7 @@ export default function EditDaily() {
|
||||||
} else {
|
} else {
|
||||||
form.setValue(
|
form.setValue(
|
||||||
"unit",
|
"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 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 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) => {
|
const handleAllCheckedChange = (checked: boolean | string) => {
|
||||||
if (checked) {
|
if (checked) {
|
||||||
|
|
@ -283,7 +283,7 @@ export default function CreateDaily() {
|
||||||
} else {
|
} else {
|
||||||
if (id == "2") {
|
if (id == "2") {
|
||||||
const temp = [];
|
const temp = [];
|
||||||
for (const element of unit) {
|
for (const element of unit ?? []) {
|
||||||
if (element == "1") {
|
if (element == "1") {
|
||||||
temp.push("1");
|
temp.push("1");
|
||||||
}
|
}
|
||||||
|
|
@ -292,7 +292,7 @@ export default function CreateDaily() {
|
||||||
} else {
|
} else {
|
||||||
form.setValue(
|
form.setValue(
|
||||||
"unit",
|
"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 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 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) => {
|
const handleAllCheckedChange = (checked: boolean | string) => {
|
||||||
if (checked) {
|
if (checked) {
|
||||||
|
|
@ -318,11 +318,11 @@ export default function DetailDaily() {
|
||||||
|
|
||||||
const handleUnitCheckedChange = (id: string, checked: boolean | string) => {
|
const handleUnitCheckedChange = (id: string, checked: boolean | string) => {
|
||||||
if (checked) {
|
if (checked) {
|
||||||
form.setValue("unit", [...unit, id]);
|
form.setValue("unit", [...(unit ?? []), id]);
|
||||||
} else {
|
} else {
|
||||||
if (id == "2") {
|
if (id == "2") {
|
||||||
const temp = [];
|
const temp = [];
|
||||||
for (const element of unit) {
|
for (const element of unit ?? []) {
|
||||||
if (element == "1") {
|
if (element == "1") {
|
||||||
temp.push("1");
|
temp.push("1");
|
||||||
}
|
}
|
||||||
|
|
@ -331,7 +331,7 @@ export default function DetailDaily() {
|
||||||
} else {
|
} else {
|
||||||
form.setValue(
|
form.setValue(
|
||||||
"unit",
|
"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 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 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) => {
|
const handleAllCheckedChange = (checked: boolean | string) => {
|
||||||
if (checked) {
|
if (checked) {
|
||||||
|
|
@ -335,7 +335,7 @@ export default function EditDaily() {
|
||||||
} else {
|
} else {
|
||||||
if (id == "2") {
|
if (id == "2") {
|
||||||
const temp = [];
|
const temp = [];
|
||||||
for (const element of unit) {
|
for (const element of unit ?? []) {
|
||||||
if (element == "1") {
|
if (element == "1") {
|
||||||
temp.push("1");
|
temp.push("1");
|
||||||
}
|
}
|
||||||
|
|
@ -344,7 +344,7 @@ export default function EditDaily() {
|
||||||
} else {
|
} else {
|
||||||
form.setValue(
|
form.setValue(
|
||||||
"unit",
|
"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 media = form.watch("media");
|
||||||
const unit = form.watch("unit");
|
const unit = form.watch("unit");
|
||||||
|
|
||||||
const isAllChecked = items.every((item) => output?.includes(item.id));
|
const isAllChecked = output && items.every((item) => output.includes(item.id));
|
||||||
const isAllMediaChecked = medias.every((item) => media?.includes(item.id));
|
const isAllMediaChecked = media && medias.every((item) => media.includes(item.id));
|
||||||
const isAllUnitChecked = units.every((item) => unit?.includes(item.id));
|
const isAllUnitChecked = unit && units.every((item) => unit.includes(item.id));
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
async function initState() {
|
async function initState() {
|
||||||
|
|
|
||||||
|
|
@ -81,8 +81,8 @@ export default function CreateSpvFAQModal() {
|
||||||
});
|
});
|
||||||
|
|
||||||
const target = form.watch("publishTo");
|
const target = form.watch("publishTo");
|
||||||
const isAllTargetChecked = publishToList.every((item) =>
|
const isAllTargetChecked = target && publishToList.every((item) =>
|
||||||
target?.includes(item.id)
|
target.includes(item.id)
|
||||||
);
|
);
|
||||||
|
|
||||||
const onSubmit = async (data: z.infer<typeof FormSchema>) => {
|
const onSubmit = async (data: z.infer<typeof FormSchema>) => {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue