blob: f836d70355db75d477210355ecb1d950811299bf [file] [log] [blame]
pineafan46270162022-02-13 12:06:17 +00001import { Component } from 'react';
2import Styles from '../../styles/rsmv/rsmv.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'
8
9import { AutoLayout, Panel, Title, Subtitle, Text, Divider } from '../../Components/Panels';
10import { List, ListItem, Code } from '../../Components/Texttools';
11class RSMV extends Component {
12
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/rsmv/verifyTkn', { tkn: token.toString() })
pineafan9babd752022-10-21 21:47:52 +010024 if(chk.data.success === true) {
pineafan46270162022-02-13 12:06:17 +000025 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('/rsmv/failure','/rsmv')
43 }
44 let code = await Axios.post('/api/rsmv/complete', {
45 uid:cls.props.uID,
46 rid:cls.props.rID,
47 gid:cls.props.gID,
48 code:cls.props.code
49 });
pineafan46270162022-02-13 12:06:17 +000050 if (code.status === 200 ) return Router.push('/rsmv/success','/rsmv')
51 else return Router.push('/rsmv/failure','/rsmv')
52 }
53
54 render() {
55 return <>
56 <Header
57 name={
58 <>
59 <img alt="Server icon" style={{borderRadius: "50%", height: "64px", width: "auto"}} src={"https://i1.sndcdn.com/artworks-000045941811-q634od-t500x500.jpg"} />
60 <br />
61 {"ERROR"}
62 </>
63 }
64 nameOverwrite="Verify"
65 subtext={`-5 members`}
66 gradient={["F27878", "D96B6B"]}
67 wave="web/waves/header/rsm"
68 buttons={[]}
PineaFana465f352023-02-05 16:45:01 +000069 season={this.props.season}
pineafan46270162022-02-13 12:06:17 +000070 />
pineafan46270162022-02-13 12:06:17 +000071 <AutoLayout>
72 <Panel>
73 <Text>Complete the check below to join ERROR</Text>
74 <div style={{height: "125px"}}>
75 <HCaptcha
76 id="Captchas mitigate problems"
77 sitekey="85074411-fa13-4d9b-b901-53095c6d1fc6"
78 onVerify={token => this.handleVerificationSuccess(this, token)}
79 theme={this.theme ? "light" : "dark"}
80 />
81 </div>
82 <button type="button" className={Styles.button + " " + (this.state.captchaComplete ? Styles.buttonComplete : null)} onClick={(success) => this.submitForm(this)}>Proceed</button>
83 <List colour="F27878">
84 <ListItem>This is an automatic check performed by RSM.</ListItem>
85 <ListItem>By clicking Proceed, you will be given the <code>MISSING</code> role in <code>ERROR</code>.</ListItem>
PineaFan41418622023-10-14 21:36:48 +010086 <ListItem>For the full list of data stored by RSM, please check <a href="https://clickscodes.github.io/policies/rsm#verification">Here</a></ListItem>
pineafan46270162022-02-13 12:06:17 +000087 </List>
88 <Text>You can add RSM 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>
89 </Panel>
90 </AutoLayout>
91 </>
92 }
93}
94
95export default RSMV;