Skip to content

Commit 5274bfe

Browse files
Merge pull request #924 from ProvableHQ/mwong/transfer-dropdown
Move transfer tab to main form layout
2 parents 2a7ebbf + 0004647 commit 5274bfe

File tree

1 file changed

+55
-36
lines changed

1 file changed

+55
-36
lines changed

website/src/tabs/develop/Transfer.jsx

Lines changed: 55 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,18 @@
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

@@ -16,7 +29,7 @@ export const Transfer = () => {
1629
const [transferError, setTransferError] = useState(null);
1730
const [status, setStatus] = useState("");
1831
const [transactionID, setTransactionID] = useState(null);
19-
const [visibility, setVisibility] = useState("private");
32+
const [visibility, setVisibility] = useState("public");
2033
const [worker, setWorker] = useState(null);
2134

2235
function spawnWorker() {
@@ -77,7 +90,10 @@ export const Transfer = () => {
7790
}
7891

7992
let amountRecord = amountRecordString();
80-
if (visibilityString() === "public" || visibilityString() === "publicToPrivate") {
93+
if (
94+
visibilityString() === "public" ||
95+
visibilityString() === "publicToPrivate"
96+
) {
8197
amountRecord = undefined;
8298
}
8399

@@ -171,36 +187,36 @@ export const Transfer = () => {
171187
return privateKey;
172188
};
173189

174-
const onClick = ({ key }) => {
190+
const onClick = ({ value }) => {
175191
setTransactionID(null);
176192
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") {
180196
setAmountRecord(null);
181197
}
182198
};
183199

184200
const items = [
185201
{
186-
label: 'private',
187-
key: 'private',
202+
label: "private",
203+
value: "private",
188204
},
189205
{
190-
label: 'privateToPublic',
191-
key: 'privateToPublic',
206+
label: "privateToPublic",
207+
value: "privateToPublic",
192208
},
193209
{
194-
label: 'public',
195-
key: 'public',
210+
label: "public",
211+
value: "public",
196212
},
197213
{
198-
label: 'publicToPrivate',
199-
key: 'publicToPrivate',
214+
label: "publicToPrivate",
215+
value: "publicToPrivate",
200216
},
201217
];
202218

203-
const layout = { labelCol: { span: 5}, wrapperCol: { span: 21 } };
219+
const layout = { labelCol: { span: 5 }, wrapperCol: { span: 21 } };
204220
const feeString = () => (transferFee !== null ? transferFee : "");
205221
const amountString = () => (transferAmount !== null ? transferAmount : "");
206222
const recipientString = () => (recipient !== null ? recipient : "");
@@ -214,20 +230,28 @@ export const Transfer = () => {
214230
const transferErrorString = () =>
215231
transferError !== null ? transferError : "";
216232
const peerUrl = () => (transferUrl !== null ? transferUrl : "");
217-
const visibilityString = () => (visibility !== null ? visibility : "private");
233+
const visibilityString = () =>
234+
visibility !== null ? visibility : "private";
218235

219236
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={<></>}>
230238
<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>
231255
<Form.Item
232256
label="Recipient Address"
233257
colon={false}
@@ -252,8 +276,8 @@ export const Transfer = () => {
252276
value={amountString()}
253277
/>
254278
</Form.Item>
255-
{
256-
(visibilityString() === "privateToPublic" || visibilityString() === "private") &&
279+
{(visibilityString() === "privateToPublic" ||
280+
visibilityString() === "private") && (
257281
<Form.Item
258282
label="Amount Record"
259283
colon={false}
@@ -268,7 +292,7 @@ export const Transfer = () => {
268292
value={amountRecordString()}
269293
/>
270294
</Form.Item>
271-
}
295+
)}
272296
<Form.Item label="Fee" colon={false} validateStatus={status}>
273297
<Input.TextArea
274298
name="Fee"
@@ -332,12 +356,7 @@ export const Transfer = () => {
332356
</Form.Item>
333357
<Row justify="center">
334358
<Col justify="center">
335-
<Button
336-
type="primary"
337-
338-
size="middle"
339-
onClick={transfer}
340-
>
359+
<Button type="primary" size="middle" onClick={transfer}>
341360
Transfer
342361
</Button>
343362
</Col>

0 commit comments

Comments
 (0)