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