feat: reselct field so that GTC is default on limit (#995)
* feat: reselct field so that GTC is default on limit * feat: set value when switching order type * fix: deal ticket test * fix: revert TIF selector file
This commit is contained in:
parent
24a20f48e1
commit
1a1ab4db65
2
.gitignore
vendored
2
.gitignore
vendored
@ -21,7 +21,7 @@
|
||||
|
||||
# IDE - VSCode
|
||||
.vscode/*
|
||||
!.vscode/settings.json
|
||||
.vscode/settings.json
|
||||
!.vscode/tasks.json
|
||||
!.vscode/launch.json
|
||||
!.vscode/extensions.json
|
||||
|
@ -163,7 +163,7 @@ describe('DealTicket', () => {
|
||||
// Change back to limit and check we are still on FOK
|
||||
fireEvent.click(screen.getByTestId('order-type-TYPE_LIMIT'));
|
||||
expect(screen.getByTestId('order-tif')).toHaveValue(
|
||||
VegaWalletOrderTimeInForce.FOK
|
||||
VegaWalletOrderTimeInForce.GTC
|
||||
);
|
||||
});
|
||||
});
|
||||
|
@ -39,6 +39,7 @@ export const DealTicket = ({
|
||||
handleSubmit,
|
||||
watch,
|
||||
formState: { errors },
|
||||
setValue,
|
||||
} = useForm<Order>({
|
||||
mode: 'onChange',
|
||||
defaultValues: getDefaultOrder(market),
|
||||
@ -71,7 +72,17 @@ export const DealTicket = ({
|
||||
name="type"
|
||||
control={control}
|
||||
render={({ field }) => (
|
||||
<TypeSelector value={field.value} onSelect={field.onChange} />
|
||||
<TypeSelector
|
||||
value={field.value}
|
||||
onSelect={(type) => {
|
||||
if (type === VegaWalletOrderType.Limit) {
|
||||
setValue('timeInForce', VegaWalletOrderTimeInForce.GTC);
|
||||
} else {
|
||||
setValue('timeInForce', VegaWalletOrderTimeInForce.IOC);
|
||||
}
|
||||
field.onChange(type);
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
<Controller
|
||||
|
Loading…
Reference in New Issue
Block a user