Skip to content

Commit 8a77dad

Browse files
transfer tab change to form
1 parent 5b4f27d commit 8a77dad

File tree

1 file changed

+58
-37
lines changed

1 file changed

+58
-37
lines changed

website/src/tabs/develop/Transfer.jsx

Lines changed: 58 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,27 @@
11
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";
316
import { DownOutlined } from "@ant-design/icons";
417
import axios from "axios";
518

619
export const Transfer = () => {
720
const [transferFeeRecord, setTransferFeeRecord] = useState(null);
821
const [amountRecord, setAmountRecord] = useState(null);
9-
const [transferUrl, setTransferUrl] = useState("https://api.explorer.aleo.org/v1");
22+
const [transferUrl, setTransferUrl] = useState(
23+
"https://api.explorer.aleo.org/v1",
24+
);
1025
const [transferAmount, setTransferAmount] = useState("1.0");
1126
const [transferFee, setTransferFee] = useState("1.0");
1227
const [privateFee, setPrivateFee] = useState(true);
@@ -16,7 +31,7 @@ export const Transfer = () => {
1631
const [transferError, setTransferError] = useState(null);
1732
const [status, setStatus] = useState("");
1833
const [transactionID, setTransactionID] = useState(null);
19-
const [visibility, setVisibility] = useState("private");
34+
const [visibility, setVisibility] = useState("public");
2035
const [worker, setWorker] = useState(null);
2136

2237
function spawnWorker() {
@@ -77,7 +92,10 @@ export const Transfer = () => {
7792
}
7893

7994
let amountRecord = amountRecordString();
80-
if (visibilityString() === "public" || visibilityString() === "publicToPrivate") {
95+
if (
96+
visibilityString() === "public" ||
97+
visibilityString() === "publicToPrivate"
98+
) {
8199
amountRecord = undefined;
82100
}
83101

@@ -171,36 +189,36 @@ export const Transfer = () => {
171189
return privateKey;
172190
};
173191

174-
const onClick = ({ key }) => {
192+
const onClick = ({ value }) => {
175193
setTransactionID(null);
176194
setTransferError(null);
177-
console.log("Visibility changed to: ", key);
178-
setVisibility(key);
179-
if (key === "public" || key === "publicToPrivate") {
195+
setVisibility(value);
196+
console.log("Visibility changed to: ", value);
197+
if (value === "public" || value === "publicToPrivate") {
180198
setAmountRecord(null);
181199
}
182200
};
183201

184202
const items = [
185203
{
186-
label: 'private',
187-
key: 'private',
204+
label: "private",
205+
value: "private",
188206
},
189207
{
190-
label: 'privateToPublic',
191-
key: 'privateToPublic',
208+
label: "privateToPublic",
209+
value: "privateToPublic",
192210
},
193211
{
194-
label: 'public',
195-
key: 'public',
212+
label: "public",
213+
value: "public",
196214
},
197215
{
198-
label: 'publicToPrivate',
199-
key: 'publicToPrivate',
216+
label: "publicToPrivate",
217+
value: "publicToPrivate",
200218
},
201219
];
202220

203-
const layout = { labelCol: { span: 5}, wrapperCol: { span: 21 } };
221+
const layout = { labelCol: { span: 5 }, wrapperCol: { span: 21 } };
204222
const feeString = () => (transferFee !== null ? transferFee : "");
205223
const amountString = () => (transferAmount !== null ? transferAmount : "");
206224
const recipientString = () => (recipient !== null ? recipient : "");
@@ -214,20 +232,28 @@ export const Transfer = () => {
214232
const transferErrorString = () =>
215233
transferError !== null ? transferError : "";
216234
const peerUrl = () => (transferUrl !== null ? transferUrl : "");
217-
const visibilityString = () => (visibility !== null ? visibility : "private");
235+
const visibilityString = () =>
236+
visibility !== null ? visibility : "private";
218237

219238
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-
>
239+
<Card title="Transfer" style={{ width: "100%" }} extra={<></>}>
230240
<Form {...layout}>
241+
<div
242+
style={{
243+
display: "flex",
244+
gap: "13px",
245+
alignItems: "center",
246+
marginBottom: "10px",
247+
}}
248+
>
249+
<p> Transaction Visibility </p>
250+
<Select
251+
style={{ width: "9rem" }}
252+
placeholder={visibilityString()}
253+
options={items}
254+
onChange={(item) => {setVisibility(item)}}
255+
></Select>
256+
</div>
231257
<Form.Item
232258
label="Recipient Address"
233259
colon={false}
@@ -252,8 +278,8 @@ export const Transfer = () => {
252278
value={amountString()}
253279
/>
254280
</Form.Item>
255-
{
256-
(visibilityString() === "privateToPublic" || visibilityString() === "private") &&
281+
{(visibilityString() === "privateToPublic" ||
282+
visibilityString() === "private") && (
257283
<Form.Item
258284
label="Amount Record"
259285
colon={false}
@@ -268,7 +294,7 @@ export const Transfer = () => {
268294
value={amountRecordString()}
269295
/>
270296
</Form.Item>
271-
}
297+
)}
272298
<Form.Item label="Fee" colon={false} validateStatus={status}>
273299
<Input.TextArea
274300
name="Fee"
@@ -332,12 +358,7 @@ export const Transfer = () => {
332358
</Form.Item>
333359
<Row justify="center">
334360
<Col justify="center">
335-
<Button
336-
type="primary"
337-
338-
size="middle"
339-
onClick={transfer}
340-
>
361+
<Button type="primary" size="middle" onClick={transfer}>
341362
Transfer
342363
</Button>
343364
</Col>

0 commit comments

Comments
 (0)