diff --git a/src/components/common/TemplateFiller.tsx b/src/components/common/TemplateFiller.tsx index cae9c81..35927a1 100644 --- a/src/components/common/TemplateFiller.tsx +++ b/src/components/common/TemplateFiller.tsx @@ -112,7 +112,8 @@ const TemplateFiller = forwardRef( customFields: newCustomFields, }); setTemplate(newTemplate); - }, [templateId, formInstanceId, form]); + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [templateId, formInstanceId]); useEffect(() => { void loadTemplate(); diff --git a/src/modules/manager/specifications/SpecificationsDetails.tsx b/src/modules/manager/specifications/SpecificationsDetails.tsx index f618575..518260c 100644 --- a/src/modules/manager/specifications/SpecificationsDetails.tsx +++ b/src/modules/manager/specifications/SpecificationsDetails.tsx @@ -71,17 +71,13 @@ const SpecificationsDetails: React.FC = ({ const isEditMode = () => editMode; const loadFormTemplate = useCallback( - async (printSpecifications?: GeneralIdRef) => { - const { data } = form.state; - const printSpecArray = - (data.printSpecifications as CustomFieldValue[]) || []; - + async (printSpecArray: CustomFieldValue[]) => { if (printSpecArray && printSpecArray.length > 0) { if ( ((printSpecArray[0] as CustomFieldValue).value as GeneralIdRef).id === BigInt(0) ) { - data.printSpecifications = undefined; + return; } } @@ -95,12 +91,9 @@ const SpecificationsDetails: React.FC = ({ } if (template) { setFormTemplate(template); - form.setState({ loaded: true }); - } else { - form.setState({ loaded: false }); } }, - [form], + [], ); const handleValidationChanged = useCallback(() => { @@ -142,11 +135,10 @@ const SpecificationsDetails: React.FC = ({ const { printSpecifications } = form.state.data; const printSpecArray = (printSpecifications as CustomFieldValue[]) || []; if (printSpecArray && printSpecArray.length > 0) { - loadFormTemplate( - (printSpecArray[0] as CustomFieldValue).value as GeneralIdRef, - ); + loadFormTemplate(printSpecArray); } - }, [form.state.data.printSpecifications, loadFormTemplate, form]); + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [form.state.data.printSpecifications]); const doSubmit = async (buttonName: string) => { try {