Browse Source

Replace formatting of quantity with input addon

debug-collab-settlement
Thomas Eizinger 3 years ago
parent
commit
ec712b33ae
No known key found for this signature in database GPG Key ID: 651AC83A6C6C8B96
  1. 7
      taker-frontend/src/App.tsx
  2. 31
      taker-frontend/src/components/Trade.tsx

7
taker-frontend/src/App.tsx

@ -100,9 +100,6 @@ export const App = () => {
500,
);
const format = (val: any) => `$` + val;
const parse = (val: any) => val.replace(/^\$/, "");
return (
<>
<Nav walletInfo={walletInfo} connectedToMaker={connectedToMaker} />
@ -119,7 +116,7 @@ export const App = () => {
<Trade
connectedToMaker={connectedToMaker}
orderId={order?.id}
quantity={format(effectiveQuantity)}
quantity={effectiveQuantity}
maxQuantity={max_quantity || 0}
minQuantity={min_quantity || 0}
referencePrice={referencePrice}
@ -129,7 +126,7 @@ export const App = () => {
liquidationPrice={liquidationPrice}
onQuantityChange={(valueString: string) => {
setUserHasEdited(true);
setQuantity(parse(valueString));
setQuantity(valueString);
}}
onLongSubmit={makeNewOrderRequest}
isLongSubmitting={isCreatingNewOrderRequest}

31
taker-frontend/src/components/Trade.tsx

@ -15,6 +15,8 @@ import {
Grid,
GridItem,
HStack,
InputGroup,
InputLeftAddon,
Modal,
ModalBody,
ModalCloseButton,
@ -281,19 +283,22 @@ function Quantity({ min, max, onChange, quantity }: QuantityProps) {
return (
<FormControl id="quantity">
<FormLabel>Quantity</FormLabel>
<NumberInput
min={min}
max={max}
default={min}
onChange={onChange}
value={quantity}
>
<NumberInputField />
<NumberInputStepper>
<NumberIncrementStepper />
<NumberDecrementStepper />
</NumberInputStepper>
</NumberInput>
<InputGroup>
<InputLeftAddon>$</InputLeftAddon>
<NumberInput
min={min}
max={max}
default={min}
onChange={onChange}
value={quantity}
>
<NumberInputField />
<NumberInputStepper>
<NumberIncrementStepper />
<NumberDecrementStepper />
</NumberInputStepper>
</NumberInput>
</InputGroup>
<FormHelperText>How much do you want to buy or sell?</FormHelperText>
</FormControl>
);

Loading…
Cancel
Save