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
|
# IDE - VSCode
|
||||||
.vscode/*
|
.vscode/*
|
||||||
!.vscode/settings.json
|
.vscode/settings.json
|
||||||
!.vscode/tasks.json
|
!.vscode/tasks.json
|
||||||
!.vscode/launch.json
|
!.vscode/launch.json
|
||||||
!.vscode/extensions.json
|
!.vscode/extensions.json
|
||||||
|
@ -163,7 +163,7 @@ describe('DealTicket', () => {
|
|||||||
// Change back to limit and check we are still on FOK
|
// Change back to limit and check we are still on FOK
|
||||||
fireEvent.click(screen.getByTestId('order-type-TYPE_LIMIT'));
|
fireEvent.click(screen.getByTestId('order-type-TYPE_LIMIT'));
|
||||||
expect(screen.getByTestId('order-tif')).toHaveValue(
|
expect(screen.getByTestId('order-tif')).toHaveValue(
|
||||||
VegaWalletOrderTimeInForce.FOK
|
VegaWalletOrderTimeInForce.GTC
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -39,6 +39,7 @@ export const DealTicket = ({
|
|||||||
handleSubmit,
|
handleSubmit,
|
||||||
watch,
|
watch,
|
||||||
formState: { errors },
|
formState: { errors },
|
||||||
|
setValue,
|
||||||
} = useForm<Order>({
|
} = useForm<Order>({
|
||||||
mode: 'onChange',
|
mode: 'onChange',
|
||||||
defaultValues: getDefaultOrder(market),
|
defaultValues: getDefaultOrder(market),
|
||||||
@ -71,7 +72,17 @@ export const DealTicket = ({
|
|||||||
name="type"
|
name="type"
|
||||||
control={control}
|
control={control}
|
||||||
render={({ field }) => (
|
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
|
<Controller
|
||||||
|
Loading…
Reference in New Issue
Block a user