blob: 4a271fab52b3d41b77ae883b80716772ac696c2b [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() })
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('/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 });
50 console.log(code.status)
51 if (code.status === 200 ) return Router.push('/rsmv/success','/rsmv')
52 else return Router.push('/rsmv/failure','/rsmv')
53 }
54
55 render() {
56 return <>
57 <Header
58 name={
59 <>
60 <img alt="Server icon" style={{borderRadius: "50%", height: "64px", width: "auto"}} src={"https://i1.sndcdn.com/artworks-000045941811-q634od-t500x500.jpg"} />
61 <br />
62 {"ERROR"}
63 </>
64 }
65 nameOverwrite="Verify"
66 subtext={`-5 members`}
67 gradient={["F27878", "D96B6B"]}
68 wave="web/waves/header/rsm"
69 buttons={[]}
70 />
71 <p id="start" />
72 <AutoLayout>
73 <Panel>
74 <Text>Complete the check below to join ERROR</Text>
75 <div style={{height: "125px"}}>
76 <HCaptcha
77 id="Captchas mitigate problems"
78 sitekey="85074411-fa13-4d9b-b901-53095c6d1fc6"
79 onVerify={token => this.handleVerificationSuccess(this, token)}
80 theme={this.theme ? "light" : "dark"}
81 />
82 </div>
83 <button type="button" className={Styles.button + " " + (this.state.captchaComplete ? Styles.buttonComplete : null)} onClick={(success) => this.submitForm(this)}>Proceed</button>
84 <List colour="F27878">
85 <ListItem>This is an automatic check performed by RSM.</ListItem>
86 <ListItem>By clicking Proceed, you will be given the <code>MISSING</code> role in <code>ERROR</code>.</ListItem>
87 <ListItem>For the full list of data stored by RSM, please check <a href="https://clicksminuteper.github.io/policies/rsm#verification">Here</a></ListItem>
88 </List>
89 <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>
90 </Panel>
91 </AutoLayout>
92 </>
93 }
94}
95
96export default RSMV;