1
1
import { useState , useEffect } from "react" ;
2
- import { Button , Card , Col , Dropdown , Form , Input , Row , Result , Space , Spin , Switch } from "antd" ;
2
+ import {
3
+ Button ,
4
+ Card ,
5
+ Col ,
6
+ Select ,
7
+ Dropdown ,
8
+ Form ,
9
+ Input ,
10
+ Row ,
11
+ Result ,
12
+ Space ,
13
+ Spin ,
14
+ Switch ,
15
+ } from "antd" ;
3
16
import { DownOutlined } from "@ant-design/icons" ;
4
17
import axios from "axios" ;
5
18
@@ -16,7 +29,7 @@ export const Transfer = () => {
16
29
const [ transferError , setTransferError ] = useState ( null ) ;
17
30
const [ status , setStatus ] = useState ( "" ) ;
18
31
const [ transactionID , setTransactionID ] = useState ( null ) ;
19
- const [ visibility , setVisibility ] = useState ( "private " ) ;
32
+ const [ visibility , setVisibility ] = useState ( "public " ) ;
20
33
const [ worker , setWorker ] = useState ( null ) ;
21
34
22
35
function spawnWorker ( ) {
@@ -77,7 +90,10 @@ export const Transfer = () => {
77
90
}
78
91
79
92
let amountRecord = amountRecordString ( ) ;
80
- if ( visibilityString ( ) === "public" || visibilityString ( ) === "publicToPrivate" ) {
93
+ if (
94
+ visibilityString ( ) === "public" ||
95
+ visibilityString ( ) === "publicToPrivate"
96
+ ) {
81
97
amountRecord = undefined ;
82
98
}
83
99
@@ -171,36 +187,36 @@ export const Transfer = () => {
171
187
return privateKey ;
172
188
} ;
173
189
174
- const onClick = ( { key } ) => {
190
+ const onClick = ( { value } ) => {
175
191
setTransactionID ( null ) ;
176
192
setTransferError ( null ) ;
177
- console . log ( "Visibility changed to: " , key ) ;
178
- setVisibility ( key ) ;
179
- if ( key === "public" || key === "publicToPrivate" ) {
193
+ setVisibility ( value ) ;
194
+ console . log ( "Visibility changed to: " , value ) ;
195
+ if ( value === "public" || value === "publicToPrivate" ) {
180
196
setAmountRecord ( null ) ;
181
197
}
182
198
} ;
183
199
184
200
const items = [
185
201
{
186
- label : ' private' ,
187
- key : ' private' ,
202
+ label : " private" ,
203
+ value : " private" ,
188
204
} ,
189
205
{
190
- label : ' privateToPublic' ,
191
- key : ' privateToPublic' ,
206
+ label : " privateToPublic" ,
207
+ value : " privateToPublic" ,
192
208
} ,
193
209
{
194
- label : ' public' ,
195
- key : ' public' ,
210
+ label : " public" ,
211
+ value : " public" ,
196
212
} ,
197
213
{
198
- label : ' publicToPrivate' ,
199
- key : ' publicToPrivate' ,
214
+ label : " publicToPrivate" ,
215
+ value : " publicToPrivate" ,
200
216
} ,
201
217
] ;
202
218
203
- const layout = { labelCol : { span : 5 } , wrapperCol : { span : 21 } } ;
219
+ const layout = { labelCol : { span : 5 } , wrapperCol : { span : 21 } } ;
204
220
const feeString = ( ) => ( transferFee !== null ? transferFee : "" ) ;
205
221
const amountString = ( ) => ( transferAmount !== null ? transferAmount : "" ) ;
206
222
const recipientString = ( ) => ( recipient !== null ? recipient : "" ) ;
@@ -214,20 +230,28 @@ export const Transfer = () => {
214
230
const transferErrorString = ( ) =>
215
231
transferError !== null ? transferError : "" ;
216
232
const peerUrl = ( ) => ( transferUrl !== null ? transferUrl : "" ) ;
217
- const visibilityString = ( ) => ( visibility !== null ? visibility : "private" ) ;
233
+ const visibilityString = ( ) =>
234
+ visibility !== null ? visibility : "private" ;
218
235
219
236
return (
220
- < Card
221
- title = "Transfer"
222
- style = { { width : "100%" } }
223
- extra = {
224
- < Dropdown menu = { { items, onClick } } >
225
- < a onClick = { ( e ) => e . preventDefault ( ) } >
226
- < Button > { visibilityString ( ) } </ Button >
227
- </ a >
228
- </ Dropdown > }
229
- >
237
+ < Card title = "Transfer" style = { { width : "100%" } } extra = { < > </ > } >
230
238
< Form { ...layout } >
239
+ < div
240
+ style = { {
241
+ display : "flex" ,
242
+ gap : "13px" ,
243
+ alignItems : "center" ,
244
+ marginBottom : "10px" ,
245
+ } }
246
+ >
247
+ < p > Transaction Visibility </ p >
248
+ < Select
249
+ style = { { width : "9rem" } }
250
+ placeholder = { visibilityString ( ) }
251
+ options = { items }
252
+ onChange = { ( item ) => { setVisibility ( item ) } }
253
+ > </ Select >
254
+ </ div >
231
255
< Form . Item
232
256
label = "Recipient Address"
233
257
colon = { false }
@@ -252,8 +276,8 @@ export const Transfer = () => {
252
276
value = { amountString ( ) }
253
277
/>
254
278
</ Form . Item >
255
- {
256
- ( visibilityString ( ) === "privateToPublic" || visibilityString ( ) === " private") &&
279
+ { ( visibilityString ( ) === "privateToPublic" ||
280
+ visibilityString ( ) === "private" ) && (
257
281
< Form . Item
258
282
label = "Amount Record"
259
283
colon = { false }
@@ -268,7 +292,7 @@ export const Transfer = () => {
268
292
value = { amountRecordString ( ) }
269
293
/>
270
294
</ Form . Item >
271
- }
295
+ ) }
272
296
< Form . Item label = "Fee" colon = { false } validateStatus = { status } >
273
297
< Input . TextArea
274
298
name = "Fee"
@@ -332,12 +356,7 @@ export const Transfer = () => {
332
356
</ Form . Item >
333
357
< Row justify = "center" >
334
358
< Col justify = "center" >
335
- < Button
336
- type = "primary"
337
-
338
- size = "middle"
339
- onClick = { transfer }
340
- >
359
+ < Button type = "primary" size = "middle" onClick = { transfer } >
341
360
Transfer
342
361
</ Button >
343
362
</ Col >
0 commit comments