pineafan | 4627016 | 2022-02-13 12:06:17 +0000 | [diff] [blame] | 1 | import { Component } from 'react'; |
| 2 | import Styles from '../../styles/rsmv/rsmv.module.css' |
| 3 | import HCaptcha from 'react-hcaptcha'; |
| 4 | import Axios from 'axios'; |
| 5 | import Router from 'next/router'; |
| 6 | import React from 'react'; |
| 7 | import Header from '../../Components/Header' |
| 8 | |
| 9 | import { AutoLayout, Panel, Title, Subtitle, Text, Divider } from '../../Components/Panels'; |
| 10 | import { List, ListItem, Code } from '../../Components/Texttools'; |
| 11 | class 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() }) |
pineafan | 9babd75 | 2022-10-21 21:47:52 +0100 | [diff] [blame] | 24 | if(chk.data.success === true) { |
pineafan | 4627016 | 2022-02-13 12:06:17 +0000 | [diff] [blame] | 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 | }); |
pineafan | 4627016 | 2022-02-13 12:06:17 +0000 | [diff] [blame] | 50 | 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={[]} |
| 69 | /> |
pineafan | 4627016 | 2022-02-13 12:06:17 +0000 | [diff] [blame] | 70 | <AutoLayout> |
| 71 | <Panel> |
| 72 | <Text>Complete the check below to join ERROR</Text> |
| 73 | <div style={{height: "125px"}}> |
| 74 | <HCaptcha |
| 75 | id="Captchas mitigate problems" |
| 76 | sitekey="85074411-fa13-4d9b-b901-53095c6d1fc6" |
| 77 | onVerify={token => this.handleVerificationSuccess(this, token)} |
| 78 | theme={this.theme ? "light" : "dark"} |
| 79 | /> |
| 80 | </div> |
| 81 | <button type="button" className={Styles.button + " " + (this.state.captchaComplete ? Styles.buttonComplete : null)} onClick={(success) => this.submitForm(this)}>Proceed</button> |
| 82 | <List colour="F27878"> |
| 83 | <ListItem>This is an automatic check performed by RSM.</ListItem> |
| 84 | <ListItem>By clicking Proceed, you will be given the <code>MISSING</code> role in <code>ERROR</code>.</ListItem> |
| 85 | <ListItem>For the full list of data stored by RSM, please check <a href="https://clicksminuteper.github.io/policies/rsm#verification">Here</a></ListItem> |
| 86 | </List> |
| 87 | <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> |
| 88 | </Panel> |
| 89 | </AutoLayout> |
| 90 | </> |
| 91 | } |
| 92 | } |
| 93 | |
| 94 | export default RSMV; |