@@ -2,7 +2,7 @@ import { useAccount, useOrderEntry, useSymbolsInfo, useWithdraw } from '@orderly
2
2
import { AlgoOrderRootType , OrderlyOrder , OrderSide , OrderType } from '@orderly.network/types' ;
3
3
import { Separator } from '@radix-ui/themes' ;
4
4
import { useNotifications } from '@web3-onboard/react' ;
5
- import { FC , useCallback , useState } from 'react' ;
5
+ import { FC , useCallback , useEffect , useState } from 'react' ;
6
6
import { match } from 'ts-pattern' ;
7
7
8
8
import { ConnectWalletButton , Spinner , TokenInput } from '.' ;
@@ -28,10 +28,10 @@ export const CreateOrder: FC<{
28
28
} = useOrderEntry ( symbol , {
29
29
initialOrder : {
30
30
side : OrderSide . BUY ,
31
- order_type : OrderType . MARKET ,
32
- trigger_price : undefined ,
33
- price : undefined ,
34
- order_quantity : undefined
31
+ order_type : OrderType . LIMIT ,
32
+ trigger_price : '' ,
33
+ order_price : '' ,
34
+ order_quantity : ''
35
35
}
36
36
} ) ;
37
37
const hasError = useCallback (
@@ -52,11 +52,19 @@ export const CreateOrder: FC<{
52
52
) ;
53
53
const [ _0 , customNotification ] = useNotifications ( ) ;
54
54
55
+ useEffect ( ( ) => {
56
+ reset ( ) ;
57
+ console . log ( '[reset]' ) ;
58
+ // eslint-disable-next-line react-hooks/exhaustive-deps
59
+ } , [ formattedOrder . order_type ] ) ;
60
+
55
61
if ( symbolsInfo . isNil ) {
56
62
return < Spinner /> ;
57
63
}
58
64
59
65
const submitForm = async ( ) => {
66
+ console . log ( '[errors]' , errors ) ;
67
+ console . log ( '[formattedOrder]' , formattedOrder ) ;
60
68
setLoading ( true ) ;
61
69
const { update } = customNotification ( {
62
70
eventCode : 'createOrder' ,
@@ -133,16 +141,22 @@ export const CreateOrder: FC<{
133
141
if ( event . target . value === 'BRACKET_MARKET' ) {
134
142
setValue ( 'order_type' , OrderType . MARKET ) ;
135
143
setValue ( 'algo_type' , AlgoOrderRootType . BRACKET ) ;
144
+ } else if ( event . target . value === 'BRACKET_LIMIT' ) {
145
+ setValue ( 'order_type' , OrderType . LIMIT ) ;
146
+ setValue ( 'algo_type' , AlgoOrderRootType . BRACKET ) ;
136
147
} else {
137
148
setValue ( 'order_type' , event . target . value ) ;
138
149
setValue ( 'algo_type' , undefined ) ;
139
150
}
140
151
} }
141
152
>
142
153
< option value = "MARKET" > Market</ option >
143
- < option value = "LIMIT" > Limit</ option >
154
+ < option value = "LIMIT" selected >
155
+ Limit
156
+ </ option >
144
157
< option value = "STOP_LIMIT" > Stop Limit</ option >
145
158
< option value = "BRACKET_MARKET" > Bracket Market</ option >
159
+ < option value = "BRACKET_LIMIT" > Bracket Limit</ option >
146
160
</ select >
147
161
148
162
< label
@@ -175,19 +189,19 @@ export const CreateOrder: FC<{
175
189
>
176
190
< span className = "font-bold font-size-4" > Price ({ quote } )</ span >
177
191
< TokenInput
178
- className = { `${ hasError ( 'price ' ) ? 'border-[var(--color-red)]' : '' } ` }
192
+ className = { `${ hasError ( 'order_price ' ) ? 'border-[var(--color-red)]' : '' } ` }
179
193
decimals = { quoteDecimals }
180
194
placeholder = "Price"
181
- name = "price "
182
- hasError = { ! ! hasError ( 'price ' ) }
195
+ name = "order_price "
196
+ hasError = { ! ! hasError ( 'order_price ' ) }
183
197
readonly = { match ( formattedOrder . order_type )
184
198
. with ( OrderType . MARKET , ( ) => true )
185
199
. otherwise ( ( ) => false ) }
186
200
onValueChange = { ( value ) => {
187
- setValue ( 'price ' , value . toString ( ) ) ;
201
+ setValue ( 'order_price ' , value . toString ( ) ) ;
188
202
} }
189
203
/>
190
- { renderFormError ( hasError ( 'price ' ) ) }
204
+ { renderFormError ( hasError ( 'order_price ' ) ) }
191
205
</ label >
192
206
193
207
< label
0 commit comments