Skip to content

Commit

Permalink
fix: if picklist not available use standard input
Browse files Browse the repository at this point in the history
  • Loading branch information
SPageot committed May 17, 2022
1 parent 681cbbf commit 39c14f3
Showing 1 changed file with 33 additions and 15 deletions.
48 changes: 33 additions & 15 deletions src/components/forms/CreateCoBenefitsForm.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import _ from 'lodash';
import u from 'updeep';
import React, { useState, useEffect } from 'react';
import { useIntl, FormattedMessage } from 'react-intl';
Expand All @@ -22,6 +23,9 @@ import {
SimpleSelectSizeEnum,
SimpleSelectTypeEnum,
SimpleSelectStateEnum,
StandardInput,
InputStateEnum,
InputSizeEnum,
} from '..';

const CreateCoBenefitsForm = ({ value, onChange }) => {
Expand Down Expand Up @@ -58,21 +62,35 @@ const CreateCoBenefitsForm = ({ value, onChange }) => {
</Body>
</StyledLabelContainer>
<InputContainer>
<SimpleSelect
width="100%"
addInput={intl.formatMessage({ id: 'cobenefits' })}
variant={
errorCoBenefitsMessage?.cobenefit
? InputVariantEnum.error
: undefined
}
size={SimpleSelectSizeEnum.large}
type={SimpleSelectTypeEnum.basic}
options={pickLists.methodology}
state={SimpleSelectStateEnum.default}
selected={value.cobenefit ? [value.cobenefit] : undefined}
onChange={changeValue => onInputChange('cobenefit', changeValue)}
/>
{!_.isEmpty(pickLists?.coBenefits) ? (
<SimpleSelect
width="100%"
addInput={intl.formatMessage({ id: 'co-benefit' })}
variant={
errorCoBenefitsMessage?.cobenefit
? InputVariantEnum.error
: undefined
}
size={SimpleSelectSizeEnum.large}
type={SimpleSelectTypeEnum.basic}
options={pickLists?.coBenefits}
state={SimpleSelectStateEnum.default}
selected={value.cobenefit ? [value.cobenefit] : undefined}
onChange={changeValue =>
onInputChange('cobenefit', changeValue)
}
/>
) : (
<StandardInput
size={InputSizeEnum.large}
placeholderText={intl.formatMessage({ id: 'co-benefit' })}
state={InputStateEnum.default}
value={value.cobenefit}
onChange={changeValue =>
onInputChange('cobenefit', changeValue)
}
/>
)}
{errorCoBenefitsMessage?.cobenefit && (
<Body size="Small" color="red">
{errorCoBenefitsMessage.cobenefit}
Expand Down

0 comments on commit 39c14f3

Please sign in to comment.