Skip to content

Commit

Permalink
feat: populate all dropdowns with picklists
Browse files Browse the repository at this point in the history
  • Loading branch information
danielstefanequilobe committed Feb 9, 2022
1 parent 5005d03 commit 4b929f5
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 24 deletions.
41 changes: 29 additions & 12 deletions src/components/forms/CreateUnitsForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,15 @@ const CreateUnitsForm = withRouter(({ onClose, left, top, width, height }) => {
[pickLists],
);

const selectCountriesOptions = useMemo(
() =>
pickLists.countries.map(country => ({
value: country,
label: country,
})),
[pickLists],
);

const handleEditUnits = async () => {
setErrorMessage({});
const dataToSend = _.cloneDeep(newUnits);
Expand Down Expand Up @@ -370,22 +379,30 @@ const CreateUnitsForm = withRouter(({ onClose, left, top, width, height }) => {
</Body>
</StyledLabelContainer>
<InputContainer>
<StandardInput
variant={errorInputAlert(
'countryJurisdictionOfOwner',
)}
size={InputSizeEnum.large}
placeholderText={intl.formatMessage({
id: 'country-jurisdiction-of-owner',
})}
state={InputStateEnum.default}
value={newUnits.countryJurisdictionOfOwner}
onChange={value =>
<Select
size={SelectSizeEnum.large}
type={SelectTypeEnum.basic}
options={selectCountriesOptions}
selected={
newUnits.countryJurisdictionOfOwner
? [
{
label: newUnits.countryJurisdictionOfOwner,
value: newUnits.countryJurisdictionOfOwner,
},
]
: undefined
}
onChange={selectedOptions =>
setNewUnits(prev => ({
...prev,
countryJurisdictionOfOwner: value,
countryJurisdictionOfOwner:
selectedOptions[0].value,
}))
}
placeholder={intl.formatMessage({
id: 'country-jurisdiction-of-owner',
})}
/>
</InputContainer>
{errorMessage?.countryJurisdictionOfOwner && (
Expand Down
43 changes: 31 additions & 12 deletions src/components/forms/EditUnitsForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,15 @@ const EditUnitsForm = ({ onClose }) => {
[pickLists],
);

const selectCountriesOptions = useMemo(
() =>
pickLists.countries.map(country => ({
value: country,
label: country,
})),
[pickLists],
);

const handleTabChange = (event, newValue) => {
setTabValue(newValue);
};
Expand Down Expand Up @@ -373,22 +382,32 @@ const EditUnitsForm = ({ onClose }) => {
</Body>
</StyledLabelContainer>
<InputContainer>
<StandardInput
variant={errorInputVariant(
'countryJurisdictionOfOwner',
)}
size={InputSizeEnum.large}
placeholderText={intl.formatMessage({
id: 'country-jurisdiction-of-owner',
})}
state={InputStateEnum.default}
value={editedUnits.countryJurisdictionOfOwner}
onChange={value =>
<Select
size={SelectSizeEnum.large}
type={SelectTypeEnum.basic}
options={selectCountriesOptions}
selected={
climatewarehouseUnits.countryJurisdictionOfOwner
? [
{
label:
climatewarehouseUnits.countryJurisdictionOfOwner,
value:
climatewarehouseUnits.countryJurisdictionOfOwner,
},
]
: undefined
}
onChange={selectedOptions =>
setEditUnits(prev => ({
...prev,
countryJurisdictionOfOwner: value,
countryJurisdictionOfOwner:
selectedOptions[0].value,
}))
}
placeholder={intl.formatMessage({
id: 'country-jurisdiction-of-owner',
})}
/>
</InputContainer>
{errorMessageAlert('countryJurisdictionOfOwner')}
Expand Down

0 comments on commit 4b929f5

Please sign in to comment.