-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(fe-piattaforma): fe updates 07212022
- Loading branch information
niccolo.valente
committed
Jul 21, 2022
1 parent
c3dad78
commit 545e6c6
Showing
33 changed files
with
874 additions
and
599 deletions.
There are no files selected for viewing
50 changes: 0 additions & 50 deletions
50
...ponents/AdministrativeArea/Entities/General/DeleteAuthorityModal/DeleteAuthorityModal.tsx
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 0 additions & 49 deletions
49
...strativeArea/Entities/General/DeleteReferentDelegateModal/DeleteReferentDelegateModal.tsx
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
122 changes: 122 additions & 0 deletions
122
...c/components/AdministrativeArea/Entities/Headquarters/FormFacilitator/FormFacilitator.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
import clsx from 'clsx'; | ||
import React, { useEffect, useState } from 'react'; | ||
import withFormHandler, { | ||
withFormHandlerProps, | ||
} from '../../../../../hoc/withFormHandler'; | ||
import FormUser from '../../../../../pages/forms/formUser'; | ||
import { selectUsers } from '../../../../../redux/features/administrativeArea/administrativeAreaSlice'; | ||
import { useAppSelector } from '../../../../../redux/hooks'; | ||
import { | ||
formFieldI, | ||
newForm, | ||
newFormField, | ||
} from '../../../../../utils/formHelper'; | ||
import Form from '../../../../Form/form'; | ||
import Input from '../../../../Form/input'; | ||
import Select from '../../../../Form/select'; | ||
|
||
interface FacilitatorI { | ||
creation?: boolean; | ||
formDisabled?: boolean; | ||
sendNewValues?: (param?: { [key: string]: formFieldI['value'] }) => void; | ||
setIsFormValid?: (param: boolean | undefined) => void; | ||
} | ||
|
||
interface FacilitatorFormI extends FacilitatorI, withFormHandlerProps {} | ||
|
||
const FormFacilitator: React.FC<FacilitatorFormI> = (props) => { | ||
const { | ||
setFormValues = () => ({}), | ||
form, | ||
onInputChange = () => ({}), | ||
sendNewValues = () => ({}), | ||
isValidForm, | ||
setIsFormValid = () => ({}), | ||
getFormValues = () => ({}), | ||
creation = false, | ||
formDisabled = false, | ||
} = props; | ||
|
||
const [newFormValues, setNewFormValues] = useState<{ | ||
[key: string]: formFieldI['value']; | ||
}>({}); | ||
const userDetails = useAppSelector(selectUsers).detail?.dettaglioUtente; | ||
|
||
useEffect(() => { | ||
if (form && newFormValues) | ||
sendNewValues({ ...newFormValues, ...getFormValues() }); | ||
}, [form, newFormValues]); | ||
|
||
useEffect(() => { | ||
if (userDetails) { | ||
setFormValues(userDetails); | ||
} | ||
}, [userDetails]); | ||
|
||
const onInputDataChange = ( | ||
value: formFieldI['value'], | ||
field?: formFieldI['field'] | ||
) => { | ||
onInputChange(value, field); | ||
setIsFormValid(isValidForm); | ||
}; | ||
|
||
const bootClass = 'justify-content-between px-0 px-lg-5 mx-2'; | ||
|
||
return ( | ||
<> | ||
<FormUser | ||
creation={creation} | ||
formDisabled={!!formDisabled} | ||
sendNewValues={(newData?: { [key: string]: formFieldI['value'] }) => | ||
setNewFormValues({ ...newData }) | ||
} | ||
setIsFormValid={(value: boolean | undefined) => setIsFormValid(!!value)} | ||
/> | ||
<Form> | ||
<Form.Row className={clsx(bootClass, 'mt-0')}> | ||
{formDisabled ? ( | ||
<Input | ||
{...form?.tipoContratto} | ||
required | ||
label='Tipo di Contratto' | ||
col='col-12 col-lg-6' | ||
// placeholder='Tipologia di contratto' | ||
onInputChange={(value, field) => { | ||
onInputDataChange(value, field); | ||
}} | ||
/> | ||
) : ( | ||
<Select | ||
{...form?.tipoContratto} | ||
required | ||
value={form?.tipoContratto.value as string} | ||
col='col-12 col-lg-6' | ||
label='Tipo di Contratto' | ||
options={[ | ||
{ label: 'Volontario', value: 'Volontario' }, | ||
{ label: 'Dipendente', value: 'Dipendente' }, | ||
{ | ||
label: 'Collaboratore', | ||
value: 'Collaboratore', | ||
}, | ||
]} | ||
onInputChange={onInputDataChange} | ||
wrapperClassName='mb-5' | ||
aria-label='contratto' | ||
/> | ||
)} | ||
</Form.Row> | ||
</Form> | ||
</> | ||
); | ||
}; | ||
|
||
const form = newForm([ | ||
newFormField({ | ||
field: 'tipoContratto', | ||
id: 'tipoContratto', | ||
}), | ||
]); | ||
|
||
export default withFormHandler({ form }, FormFacilitator); |
Oops, something went wrong.