blob: f125eee556df5a743ce24a37c3d7f319865f2b33 [file] [log] [blame]
pineafanfd93e6e2022-05-06 20:30:09 +01001import { Component } from 'react';
2import Styles from '../../../styles/nucleus/nucleus.module.css'
3import HCaptcha from 'react-hcaptcha';
4import Axios from 'axios';
5import Router from 'next/router';
6import React from 'react';
7import Header from '../../../Components/Header'
8import Link from 'next/link'
9
10import { AutoLayout, Panel, Title, Subtitle, Text, Divider } from '../../../Components/Panels';
11import { List, ListItem, Code } from '../../../Components/Texttools';
12
13class Verify extends Component {
14 constructor(props) {
15 super(props);
16 this.v = false;
17 this.state = {
18 captchaComplete: false,
19 clicked: false
20 }
21 }
22
23 async handleVerificationSuccess(cls, token) {
24 const chk = await Axios.put('/api/nucleus/verifyTkn', { tkn: token.toString() })
25 if(chk.data.success == true) {
26 this.setState({
27 captchaComplete: true
28 })
29 return cls.v = true;
30 } else {
31 return;
32 }
33 }
34
35 async submitForm(cls) {
36 if ( cls.state.clicked ) {
37 return
38 }
39 cls.setState({
40 clicked: true
41 })
42 if (!cls.v) {
43 return Router.push('/nucleus/verify/failure','/nucleus/verify/failure')
44 }
45 let code = await Axios.post('/api/nucleus/complete', {
46 uid:cls.props.uID,
47 rid:cls.props.rID,
48 gid:cls.props.gID,
49 code:cls.props.code
50 });
51 if (code.status === 200 ) return Router.push('/nucleus/verify/success','/nucleus/verify/success')
52 else return Router.push('/nucleus/verify/failure','/nucleus/verify/failure')
53 }
54
55 render() {
56 return <>
57 <Header
58 name={this.props.guild_name}
59 customImage={this.props.guild_icon_url}
60 roundImage={true}
61 subtext={`${this.props.memberCount} members`}
62 gradient={["F27878", "D96B6B"]}
63 wave="web/waves/header/nucleus"
64 buttons={[]}
65 />
66 <AutoLayout>
67 <Panel>
68 <Text>Complete the check below to join {this.props.guild_name}</Text>
69 <div style={{height: "125px"}}>
70 <HCaptcha
71 id="Captchas mitigate problems"
72 sitekey="85074411-fa13-4d9b-b901-53095c6d1fc6"
73 onVerify={token => this.handleVerificationSuccess(this, token)}
74 theme={this.theme ? "light" : "dark"}
75 />
76 </div>
77 <button type="button" className={Styles.button + " " + (this.state.captchaComplete ? Styles.buttonComplete : null)} onClick={(success) => this.submitForm(this)}>Proceed</button>
78 <List colour="F27878">
79 <ListItem>This is an automatic check performed by Nucleus.</ListItem>
80 <ListItem>By clicking Proceed, you will be given the <code>{this.props.role_name}</code> role in <code>{this.props.guild_name}</code>.</ListItem>
81 <ListItem>For the full list of data stored by Nucleus, please check <Link href="https://clicksminuteper.github.io/policies/nucleus#verification">here</Link></ListItem>
82 </List>
83 <Text>You can add Nucleus to your server by inviting it <Link href="https://discord.com/api/oauth2/authorize?client_id=715989276382462053&permissions=121295465718&scope=bot%20applications.commands">here</Link>.</Text>
84 <div id="confetti" />
85 </Panel>
86 </AutoLayout>
87 </>
88 }
89}
90
91export default Verify;
92export async function getServerSideProps(ctx) {
93}