vega-frontend-monorepo/libs/deal-ticket/src/deal-ticket-limit.tsx
Elmar 7266ac9b37
Feature/vega core (#376)
* Initial commit after nx create

* Add .env files

* Add working commit for poc

* Make deal-ticket-manager.tsx accept children as props and export more components to be consumed by external apps

* Add stepper component to simple trading app

* Add basic prototype for simple trading app with stepper component

* Remove unnecessary flags and env variables

* Change simple trading app port

* Refactor deal ticket container to be more dry

* Refactor deal ticket to be more dry

* Refactor app loader, remove tendermint socket and change providers for App.tsx in simple trading app

* Remove example cypress files and change config

* Fix linting issues
2022-05-12 10:56:21 +01:00

58 lines
1.8 KiB
TypeScript

import { OrderTimeInForce } from '@vegaprotocol/wallet';
import type { TransactionStatus } from './deal-ticket';
import { ExpirySelector } from './expiry-selector';
import { SideSelector } from './side-selector';
import { SubmitButton } from './submit-button';
import { DealTicketLimitForm } from './deal-ticket-limit-form';
import { TimeInForceSelector } from './time-in-force-selector';
import { TypeSelector } from './type-selector';
import type { Order } from './use-order-state';
import type { DealTicketQuery_market } from './__generated__/DealTicketQuery';
interface DealTicketLimitProps {
order: Order;
updateOrder: (order: Partial<Order>) => void;
transactionStatus: TransactionStatus;
market: DealTicketQuery_market;
}
export const DealTicketLimit = ({
order,
updateOrder,
transactionStatus,
market,
}: DealTicketLimitProps) => {
return (
<>
<TypeSelector order={order} onSelect={(type) => updateOrder({ type })} />
<SideSelector order={order} onSelect={(side) => updateOrder({ side })} />
<DealTicketLimitForm
price={order.price}
size={order.size}
quoteName={market.tradableInstrument.instrument.product.quoteName}
onSizeChange={(size) => updateOrder({ size })}
onPriceChange={(price) => updateOrder({ price })}
/>
<TimeInForceSelector
order={order}
onSelect={(timeInForce) => updateOrder({ timeInForce })}
/>
{order.timeInForce === OrderTimeInForce.GTT && (
<ExpirySelector
order={order}
onSelect={(date) => {
if (date) {
updateOrder({ expiration: date });
}
}}
/>
)}
<SubmitButton
transactionStatus={transactionStatus}
market={market}
order={order}
/>
</>
);
};