2022-05-12 09:56:21 +00:00
|
|
|
import { FormGroup, Input } from '@vegaprotocol/ui-toolkit';
|
2022-08-17 10:37:43 +00:00
|
|
|
import { t, toDecimal } from '@vegaprotocol/react-helpers';
|
2022-07-13 14:23:46 +00:00
|
|
|
import { validateSize } from '@vegaprotocol/orders';
|
2022-05-31 22:20:01 +00:00
|
|
|
import type { DealTicketAmountProps } from './deal-ticket-amount';
|
2022-05-12 09:56:21 +00:00
|
|
|
|
2022-05-31 22:20:01 +00:00
|
|
|
export type DealTicketMarketAmountProps = Omit<
|
|
|
|
DealTicketAmountProps,
|
|
|
|
'orderType'
|
|
|
|
>;
|
2022-05-12 09:56:21 +00:00
|
|
|
|
2022-05-31 22:20:01 +00:00
|
|
|
export const DealTicketMarketAmount = ({
|
|
|
|
register,
|
2022-05-12 09:56:21 +00:00
|
|
|
price,
|
2022-08-17 10:37:43 +00:00
|
|
|
market,
|
2022-05-12 09:56:21 +00:00
|
|
|
quoteName,
|
2022-05-31 22:20:01 +00:00
|
|
|
}: DealTicketMarketAmountProps) => {
|
2022-08-17 10:37:43 +00:00
|
|
|
const sizeStep = toDecimal(market.positionDecimalPlaces);
|
2022-05-12 09:56:21 +00:00
|
|
|
return (
|
2022-08-31 04:35:46 +00:00
|
|
|
<div className="flex items-center gap-4">
|
2022-05-12 09:56:21 +00:00
|
|
|
<div className="flex-1">
|
2022-08-11 08:10:20 +00:00
|
|
|
<FormGroup label={t('Size')} labelFor="input-order-size-market">
|
2022-05-12 09:56:21 +00:00
|
|
|
<Input
|
2022-07-07 11:01:03 +00:00
|
|
|
id="input-order-size-market"
|
2022-05-12 09:56:21 +00:00
|
|
|
className="w-full"
|
|
|
|
type="number"
|
2022-08-17 10:37:43 +00:00
|
|
|
step={sizeStep}
|
|
|
|
min={sizeStep}
|
2022-05-12 09:56:21 +00:00
|
|
|
data-testid="order-size"
|
2022-05-31 22:20:01 +00:00
|
|
|
{...register('size', {
|
|
|
|
required: true,
|
2022-08-17 10:37:43 +00:00
|
|
|
min: sizeStep,
|
|
|
|
validate: validateSize(sizeStep),
|
2022-05-31 22:20:01 +00:00
|
|
|
})}
|
2022-05-12 09:56:21 +00:00
|
|
|
/>
|
|
|
|
</FormGroup>
|
|
|
|
</div>
|
2022-08-31 04:35:46 +00:00
|
|
|
<div>@</div>
|
|
|
|
<div className="flex-1" data-testid="last-price">
|
2022-05-12 09:56:21 +00:00
|
|
|
{price && quoteName ? (
|
|
|
|
<>
|
|
|
|
~{price} {quoteName}
|
|
|
|
</>
|
|
|
|
) : (
|
|
|
|
'-'
|
|
|
|
)}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|