Skip to content

Commit

Permalink
Merge pull request #185 from Libree/refactor/loan_offer
Browse files Browse the repository at this point in the history
Refactor/loan offer
  • Loading branch information
valentinnavalos authored Aug 22, 2023
2 parents dd65011 + f8843f9 commit 4261b68
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 11 deletions.
4 changes: 2 additions & 2 deletions packages/web-app/src/containers/actionBuilder/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ const Action: React.FC<ActionsComponentProps> = ({
return <MintTokens {...{ actionIndex, allowRemove }} />;
case 'fund_opportunity':
return <FundOpportunityAction {...{ actionIndex }} />;
case 'loan_offer':
return <LoanOfferAction {...{ actionIndex, allowRemove }} />;
case 'loan_offer':
return <LoanOfferAction {...{ actionIndex, allowRemove }} />;
case 'external_contract_modal':
return <SCC actionIndex={actionIndex} />;
case 'external_contract_action':
Expand Down
34 changes: 25 additions & 9 deletions packages/web-app/src/containers/configureLoanOffer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,11 @@ const ConfigureLoanOfferForm: React.FC<ConfigureLoanOfferFormProps> = ({
const { data } = useDaoDetailsQuery()
const { pwn } = useInstalledPlugins(data?.address)

const [name] =
const [name, collateralType] =
useWatch({
name: [
`actions.${actionIndex}.name`,
`actions.${actionIndex}.inputs.collateralType`,
],
});

Expand Down Expand Up @@ -223,14 +224,29 @@ const ConfigureLoanOfferForm: React.FC<ConfigureLoanOfferFormProps> = ({
fieldState: { error },
}) => (
<>
<StyledInput
mode={error ? 'critical' : 'default'}
name={name}
type="text"
value={value}
placeholder="0x..."
onBlur={onBlur}
/>
{collateralType as CollateralType === 'ERC20' ? (
<StyledSelect
name={name}
value={value}
onChange={onChange}
defaultValue={""}
>
<option value="" disabled>{t('labels.selectAnOption')}</option>
{SUPPORTED_TOKENS[SupportedNetwork.MUMBAI].map((token) => (
<option key={token.address} value={token.address}>{token.name}</option>
))}
</StyledSelect>
) : (
<StyledInput
mode={error ? 'critical' : 'default'}
name={name}
type="text"
value={value}
placeholder="..."
onBlur={onBlur}
onChange={onChange}
/>
)}
{error?.message && (
<AlertInline label={error.message} mode="critical" />
)}
Expand Down

0 comments on commit 4261b68

Please sign in to comment.