pineafan | fd93e6e | 2022-05-06 20:30:09 +0100 | [diff] [blame] | 1 | import { Component } from 'react'; |
| 2 | import Styles from '../../../styles/nucleus/nucleus.module.css' |
| 3 | import HCaptcha from 'react-hcaptcha'; |
| 4 | import Axios from 'axios'; |
| 5 | import Router from 'next/router'; |
| 6 | import React from 'react'; |
pineafan | 3b0852d | 2022-05-06 20:39:59 +0100 | [diff] [blame] | 7 | import Header from '../../../Components/Header'; |
pineafan | fd93e6e | 2022-05-06 20:30:09 +0100 | [diff] [blame] | 8 | |
| 9 | import { AutoLayout, Panel, Title, Subtitle, Text, Divider } from '../../../Components/Panels'; |
| 10 | import { List, ListItem, Code } from '../../../Components/Texttools'; |
| 11 | |
| 12 | class 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> |
pineafan | 3b0852d | 2022-05-06 20:39:59 +0100 | [diff] [blame] | 80 | <ListItem>For the full list of data stored by Nucleus, please check <a href="https://clicksminuteper.github.io/policies/nucleus#verification">here</a></ListItem> |
pineafan | fd93e6e | 2022-05-06 20:30:09 +0100 | [diff] [blame] | 81 | </List> |
pineafan | 3b0852d | 2022-05-06 20:39:59 +0100 | [diff] [blame] | 82 | <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> |
pineafan | fd93e6e | 2022-05-06 20:30:09 +0100 | [diff] [blame] | 83 | <div id="confetti" /> |
| 84 | </Panel> |
| 85 | </AutoLayout> |
| 86 | </> |
| 87 | } |
| 88 | } |
| 89 | |
| 90 | export default Verify; |
| 91 | export async function getServerSideProps(ctx) { |
| 92 | } |