Browse Source

Merge #545

545: Disable taker's "go long" button under the same conditions as older UI r=da-kami a=klochowicz

Disable the button when there's no order or there's an in-flight order request
already.

Co-authored-by: Mariusz Klochowicz <mariusz@klochowicz.com>
new-http-api
bors[bot] 3 years ago
committed by GitHub
parent
commit
fb60986a96
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      taker-frontend/src/App.tsx
  2. 10
      taker-frontend/src/components/Trade.tsx

1
taker-frontend/src/App.tsx

@ -167,6 +167,7 @@ export const App = () => {
}; };
calculateMargin(payload); calculateMargin(payload);
}} }}
canSubmit={order != null && !isCreatingNewOrderRequest}
onLongSubmit={makeNewOrderRequest} onLongSubmit={makeNewOrderRequest}
isSubmitting={isCreatingNewOrderRequest} isSubmitting={isCreatingNewOrderRequest}
/> />

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

@ -55,6 +55,7 @@ interface TradeProps {
leverage?: number; leverage?: number;
quantity: string; quantity: string;
liquidationPrice?: number; liquidationPrice?: number;
canSubmit: boolean;
isSubmitting: boolean; isSubmitting: boolean;
onQuantityChange: any; onQuantityChange: any;
onLongSubmit: (payload: CfdOrderRequestPayload) => void; onLongSubmit: (payload: CfdOrderRequestPayload) => void;
@ -71,6 +72,7 @@ const Trade = (
margin: marginAsNumber, margin: marginAsNumber,
leverage, leverage,
liquidationPrice: liquidationPriceAsNumber, liquidationPrice: liquidationPriceAsNumber,
canSubmit,
onLongSubmit, onLongSubmit,
order_id, order_id,
}: TradeProps, }: TradeProps,
@ -148,14 +150,18 @@ const Trade = (
</GridItem> </GridItem>
<GridItem colSpan={1}> <GridItem colSpan={1}>
<Center> <Center>
<ButtonGroup variant="solid" padding="3" spacing="6"> <ButtonGroup
variant="solid"
padding="3"
spacing="6"
>
<Button colorScheme="red" size="lg" disabled h={16}> <Button colorScheme="red" size="lg" disabled h={16}>
<VStack> <VStack>
<Text as="b">Short</Text> <Text as="b">Short</Text>
<Text fontSize={"sm"}>{quantity.replace("$", "")}@{askPrice}</Text> <Text fontSize={"sm"}>{quantity.replace("$", "")}@{askPrice}</Text>
</VStack> </VStack>
</Button> </Button>
<Button colorScheme="green" size="lg" onClick={onOpen} h={16}> <Button disabled={!canSubmit} colorScheme="green" size="lg" onClick={onOpen} h={16}>
<VStack> <VStack>
<Text as="b">Long</Text> <Text as="b">Long</Text>
<Text fontSize={"sm"}>{quantity.replace("$", "")}@{askPrice}</Text> <Text fontSize={"sm"}>{quantity.replace("$", "")}@{askPrice}</Text>

Loading…
Cancel
Save