blob: 036178d0547de6493eadf546590fbd3916775b61 [file] [log] [blame]
pineafanfd93e6e2022-05-06 20:30:09 +01001import HCaptcha from 'react-hcaptcha';
2import Axios from 'axios';
3import Router from 'next/router';
4import React from 'react';
5import Header from '../../../Components/Header'
6import { useReward } from 'react-rewards';
7import { Card, CardRow } from '../../../Components/Card'
8
9import { AutoLayout, Panel, Title, Text, Divider } from '../../../Components/Panels';
10import { List, ListItem } from '../../../Components/Texttools';
11import { useColorMode } from 'theme-ui';
12import Link from 'next/link'
13
14function Verify(props) {
15 const [clicked, setClicked] = React.useState(false);
16 const [theme, setTheme] = useColorMode()
17
18 const { reward: reward, isAnimating: isAnimating } = useReward('confetti', 'confetti', {
19 elementSize: 10,
20 elementCount: 150,
21 startVelocity: 35,
22 lifetime: 300,
23 decay: 0.94,
24 spread: 170,
25 position: "absolute",
26 colors: ["#68D49E"]
27 });
28
29 async function submitForm(tkn) {
30 if ( clicked ) {
31 return
32 }
33 setClicked(true);
34 reward();
35 let code = await Axios.post('/api/nucleus/verify/complete', {
36 code:"TEST",
37 tkn: tkn
38 });
39 setTimeout(() => {
40 if (code.data.success === true ) return Router.push('/nucleus/verify/success','/nucleus/verify')
41 else return Router.push('/nucleus/verify/failure','/nucleus/verify')
42 }, 2500);
43 }
44
45 return <>
46 <Header
47 name="Clocks finite state machine"
48 customImage={"https://i1.sndcdn.com/artworks-000045941811-q634od-t500x500.jpg"}
49 roundImage={true}
50 subtext={`-5 members`}
51 gradient={["F27878", "D96B6B"]}
52 wave="web/waves/header/nucleus"
53 buttons={[]}
54 />
55 <AutoLayout>
56 <Panel>
57 <Title>Verify</Title>
58 <Divider name="commands"/>
59 <Text>Complete the check below to join ERROR</Text>
60 <div style={{height: "125px"}}>
61 <HCaptcha
62 id="Captchas mitigate problems"
63 sitekey="85074411-fa13-4d9b-b901-53095c6d1fc6"
64 onVerify={tkn => submitForm(tkn)}
65 theme="dark"
66 />
67 </div>
68 <List colour="F27878">
69 <ListItem>This is an automatic check performed by Nucleus.</ListItem>
70 <ListItem>By completing the CAPTCHA, you will be given the <code>MISSING</code> role in <code>ERROR</code>.</ListItem>
71 <ListItem>For the full list of data stored by Nucleus, please check <Link href="https://clicksminuteper.github.io/policies/nucleus#verification">here</Link></ListItem>
72 </List>
73 <div id="confetti" />
74 </Panel>
75 <Panel halfSize={false} id="invite">
76 <Title>Invite</Title>
77 <Divider />
78 <CardRow>
79 <Card
80 wave="nucleus"
81 icon="bots/nucleus/circle"
82 buttonText={"FFFFFF"} gradient={["F27878", "D96B6B"]}
83 title="Nucleus"
84 subtext="Invite Nucleus to your server"
85 buttons={[
86 {color: "424242", link: "https://discord.com/api/oauth2/authorize?client_id=715989276382462053&permissions=121295465718&scope=bot%20applications.commands", text: "Invite"}
87 ]}
88 url="https://discord.com/api/oauth2/authorize?client_id=715989276382462053&permissions=121295465718&scope=bot%20applications.commands"
89 />
90 </CardRow>
91 </Panel>
92 </AutoLayout>
93 </>
94}
95
96export default Verify;