- saving progress;
This commit is contained in:
@@ -35,12 +35,14 @@ const AddCompany = () => {
|
||||
handleSubmit,
|
||||
formState: { errors },
|
||||
setValue,
|
||||
watch
|
||||
watch,
|
||||
getValues
|
||||
} = useForm({
|
||||
defaultValues: {},
|
||||
mode: 'onChange'
|
||||
});
|
||||
const isPiva = watch('vatNumber');
|
||||
//const isPiva = watch('vatNumber');
|
||||
|
||||
const setEmptyValues = () => {
|
||||
const formData = {
|
||||
@@ -138,6 +140,11 @@ const AddCompany = () => {
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
}
|
||||
|
||||
const shouldDisableFiscalCode = () => {
|
||||
const formData = getValues();
|
||||
return !formData.type || formData.type && formData.type === 'giuridica';
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
setInputPiva(isPiva);
|
||||
}, [isPiva]);
|
||||
@@ -145,7 +152,7 @@ const AddCompany = () => {
|
||||
useEffect(() => {
|
||||
checkVatNumber(debouncedPivaValue);
|
||||
}, [debouncedPivaValue])
|
||||
|
||||
console.log('APP_EVALUATION_FLOW_ID', APP_EVALUATION_FLOW_ID)
|
||||
return (
|
||||
<div className="appPage">
|
||||
<div className="appPage__pageHeader">
|
||||
@@ -176,6 +183,23 @@ const AddCompany = () => {
|
||||
/>
|
||||
</div>
|
||||
|
||||
{APP_EVALUATION_FLOW_ID === '2'
|
||||
? <div className="appForm__cols">
|
||||
<FormField
|
||||
type="radio"
|
||||
fieldName="type"
|
||||
label={__('Type', 'gepafin')}
|
||||
control={control}
|
||||
errors={errors}
|
||||
config={{ required: __('È obbligatorio', 'gepafin') }}
|
||||
defaultValue="giuridica"
|
||||
options={[
|
||||
{ name: 'giuridica', label: 'Giuridica' },
|
||||
{ name: 'fisica', label: 'Fisica' },
|
||||
]}
|
||||
/>
|
||||
</div> : null}
|
||||
|
||||
<div className="appForm__cols">
|
||||
<FormField
|
||||
type="textinput"
|
||||
@@ -186,15 +210,25 @@ const AddCompany = () => {
|
||||
config={{ required: __('È obbligatorio', 'gepafin') }}
|
||||
/>
|
||||
|
||||
<FormField
|
||||
type="textinput"
|
||||
disabled={APP_EVALUATION_FLOW_ID === '1'}
|
||||
fieldName="codiceFiscale"
|
||||
label={__('Codice fiscale', 'gepafin')}
|
||||
control={control}
|
||||
errors={errors}
|
||||
config={{ required: __('È obbligatorio', 'gepafin') }}
|
||||
/>
|
||||
{APP_EVALUATION_FLOW_ID === '1'
|
||||
? <FormField
|
||||
type="textinput"
|
||||
disabled
|
||||
fieldName="codiceFiscale"
|
||||
label={__('Codice fiscale', 'gepafin')}
|
||||
control={control}
|
||||
errors={errors}
|
||||
config={{ required: __('È obbligatorio', 'gepafin') }}
|
||||
/>
|
||||
: <FormField
|
||||
type="textinput"
|
||||
disabled={shouldDisableFiscalCode()}
|
||||
fieldName="codiceFiscale"
|
||||
label={__('Codice fiscale', 'gepafin')}
|
||||
control={control}
|
||||
errors={errors}
|
||||
config={{ required: __('È obbligatorio', 'gepafin') }}
|
||||
/>}
|
||||
</div>
|
||||
|
||||
<div className="appForm__cols">
|
||||
|
||||
Reference in New Issue
Block a user