-
Notifications
You must be signed in to change notification settings - Fork 39
/
submit-profile-card.js
79 lines (78 loc) · 2.06 KB
/
submit-profile-card.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
import {
Button,
Card,
Field,
FileUpload,
Form,
Textarea,
useContract,
useWeb3,
} from "@kleros/components";
const createValidationSchema = ({ string, file }) => ({
name: string().max(50, "Must be 50 characters or less.").required("Required"),
firstName: string()
.max(20, "Must be 20 characters or less.")
.required("Required"),
lastName: string()
.max(20, "Must be 20 characters or less.")
.required("Required"),
bio: string().max(70, "Must be 70 characters or less.").required("Required"),
photo: file().required("Required"),
video: file().required("Required"),
});
export default function SubmitProfileCard() {
const [accounts] = useWeb3("eth", "getAccounts");
const { connect } = useWeb3();
const { loading, send } = useContract(
"proofOfHumanity",
"changeRequiredNumberOfVouches"
);
return (
<Card
header="Submit Profile"
headerSx={{
backgroundColor: "accent",
color: "background",
fontWeight: "bold",
}}
>
<Form createValidationSchema={createValidationSchema}>
<Field name="name" label="Name" placeholder="The name you go by." />
<Field
name="firstName"
label="First Name"
placeholder="(In basic Latin.)"
/>
<Field
name="lastName"
label="Last Name"
placeholder="(In basic Latin.)"
/>
<Field as={Textarea} name="bio" label="Short Bio" />
<Field
as={FileUpload}
name="photo"
label="Face Photo"
accept="image/png, image/jpeg"
maxSize={2}
photo
/>
<Field
as={FileUpload}
name="video"
label="Video (See Instructions)"
accept="video/webm, video/mp4"
maxSize={2}
video
/>
{!accounts?.[0] ? (
<Button onClick={connect}>Connect Account</Button>
) : (
<Button type="submit" loading={loading} onClick={() => send(1)}>
Submit
</Button>
)}
</Form>
</Card>
);
}