Skip to content

Commit

Permalink
Fix layout of external repay
Browse files Browse the repository at this point in the history
  • Loading branch information
sophialittlejohn committed Aug 9, 2024
1 parent 499a414 commit aab291d
Showing 1 changed file with 43 additions and 49 deletions.
92 changes: 43 additions & 49 deletions centrifuge-app/src/pages/Loan/ExternalRepayForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -183,55 +183,49 @@ export function ExternalRepayForm({ loan, destination }: { loan: ExternalLoan; d
<Stack as={Form} gap={3} noValidate ref={repayFormRef}>
<Stack gap={1}>
<Shelf gap={1}>
<Box flex={4}>
<Field
validate={combine(nonNegativeNumberNotRequired(), (val) => {
if (Dec(val || 0).gt(maxQuantity.toDecimal())) {
return `Quantity exeeds max (${maxQuantity.toString()})`
}
return ''
})}
name="quantity"
>
{({ field, form }: FieldProps) => {
return (
<CurrencyInput
{...field}
label="Quantity"
disabled={isRepayLoading}
onChange={(value) => form.setFieldValue('quantity', value)}
placeholder="0"
onSetMax={() =>
form.setFieldValue('quantity', loan.pricing.outstandingQuantity.toDecimal().toNumber())
}
/>
)
}}
</Field>
</Box>
<Box flex={2}>
<Field name="price">
{({ field, form }: FieldProps) => {
return (
<CurrencyInput
{...field}
label="Price"
disabled={isRepayLoading}
onChange={(value) => form.setFieldValue('price', value)}
decimals={8}
/>
)
}}
</Field>
</Box>
<Box flex={5}>
<CurrencyInput
label="Principal"
disabled={true}
currency={displayCurrency}
value={principal.toNumber()}
/>
</Box>
<Field
validate={combine(nonNegativeNumberNotRequired(), (val) => {
if (Dec(val || 0).gt(maxQuantity.toDecimal())) {
return `Quantity exeeds max (${maxQuantity.toString()})`
}
return ''
})}
name="quantity"
>
{({ field, form }: FieldProps) => {
return (
<CurrencyInput
{...field}
label="Quantity"
disabled={isRepayLoading}
onChange={(value) => form.setFieldValue('quantity', value)}
placeholder="0"
onSetMax={() =>
form.setFieldValue('quantity', loan.pricing.outstandingQuantity.toDecimal().toNumber())
}
/>
)
}}
</Field>
<Field name="price">
{({ field, form }: FieldProps) => {
return (
<CurrencyInput
{...field}
label="Price"
disabled={isRepayLoading}
onChange={(value) => form.setFieldValue('price', value)}
decimals={8}
currency={displayCurrency}
/>
)
}}
</Field>
</Shelf>
<Shelf justifyContent="space-between">
<Text variant="label2" color="textPrimary">
= {formatBalance(principal, displayCurrency, 2)} principal
</Text>
</Shelf>
</Stack>

Expand Down

0 comments on commit aab291d

Please sign in to comment.