PineaFan | e69bd22 | 2022-12-04 22:18:20 +0000 | [diff] [blame^] | 1 | import HCaptcha from 'react-hcaptcha'; |
| 2 | import Axios from 'axios'; |
| 3 | import Router from 'next/router'; |
| 4 | import React from 'react'; |
| 5 | import Header from '../../../Components/Header' |
| 6 | import { useReward } from 'react-rewards'; |
| 7 | import { Card, CardRow } from '../../../Components/Card'; |
| 8 | |
| 9 | import { AutoLayout, Panel, Title, Text, Divider } from '../../../Components/Panels'; |
| 10 | import { List, ListItem } from '../../../Components/Texttools'; |
| 11 | import { useColorMode } from 'theme-ui'; |
| 12 | import Styles from '../../../styles/nucleus/embed.module.css'; |
| 13 | |
| 14 | |
| 15 | function Embed(props) { |
| 16 | const [clicked, setClicked] = React.useState(false); |
| 17 | const [theme, setTheme] = useColorMode() |
| 18 | |
| 19 | const { reward: reward, isAnimating: isAnimating } = useReward('confetti', 'confetti', { |
| 20 | elementSize: 10, |
| 21 | elementCount: 150, |
| 22 | startVelocity: 35, |
| 23 | lifetime: 300, |
| 24 | decay: 0.94, |
| 25 | spread: 170, |
| 26 | position: "absolute", |
| 27 | colors: ["#68D49E"] |
| 28 | }); |
| 29 | |
| 30 | async function submitForm(tkn) { |
| 31 | if ( clicked ) { |
| 32 | Router.push('/nucleus/verify/alreadyVerified', '/nucleus/verify/success'); |
| 33 | } |
| 34 | setClicked(true); |
| 35 | reward(); |
| 36 | let code = await Axios.post('/api/nucleus/verify/complete', { |
| 37 | code: props.code, |
| 38 | tkn: tkn |
| 39 | }); |
| 40 | setTimeout(() => { |
| 41 | if (code.data.success === true ) return Router.push('/nucleus/verify/success','/nucleus/verify') |
| 42 | else return Router.push('/nucleus/verify/failure','/nucleus/verify') |
| 43 | }, 2500); |
| 44 | } |
| 45 | |
| 46 | return <> |
| 47 | <Header |
| 48 | name="Embed Editor" |
| 49 | subtext={`Editing embed in ${props.gName}`} |
| 50 | gradient={["F27878", "D96B6B"]} |
| 51 | wave="web/waves/header/nucleus" |
| 52 | buttons={[]} |
| 53 | /> |
| 54 | <AutoLayout> |
| 55 | <Panel> |
| 56 | <Title>Preview</Title> |
| 57 | <Divider name="preview"/> |
| 58 | <div className={Styles.previewEmbed}> |
| 59 | <div className={Styles.left}></div> |
| 60 | <div className={Styles.title}><input ></input></div> |
| 61 | <div className={Styles.description}><input ></input></div> |
| 62 | </div> |
| 63 | <div className={Styles.right}> |
| 64 | <div className={Styles.uploadImage} /> |
| 65 | </div> |
| 66 | <> |
| 67 | |
| 68 | </> |
| 69 | <div className={Styles.footer}> |
| 70 | <ImageUpload size={64} /> |
| 71 | </div> |
| 72 | </Panel> |
| 73 | <Panel halfSize={false} id="invite"> |
| 74 | <Title>Invite</Title> |
| 75 | <Divider /> |
| 76 | <CardRow> |
| 77 | <Card |
| 78 | wave="nucleus" |
| 79 | icon="bots/nucleus/circle" |
| 80 | buttonText={"FFFFFF"} gradient={["F27878", "D96B6B"]} |
| 81 | title="Nucleus" |
| 82 | subtext="Invite Nucleus to your server" |
| 83 | buttons={[ |
| 84 | {color: "424242", link: "https://discord.com/api/oauth2/authorize?client_id=715989276382462053&permissions=121295465718&scope=bot%20applications.commands", text: "Invite"} |
| 85 | ]} |
| 86 | url="https://discord.com/api/oauth2/authorize?client_id=715989276382462053&permissions=121295465718&scope=bot%20applications.commands" |
| 87 | /> |
| 88 | </CardRow> |
| 89 | </Panel> |
| 90 | </AutoLayout> |
| 91 | </> |
| 92 | } |
| 93 | |
| 94 | export default Embed; |
| 95 | export async function getServerSideProps(ctx) { |
| 96 | return { |
| 97 | props: { |
| 98 | gID: code.data.gID, |
| 99 | gName: code.data.gName, |
| 100 | mID: code.data.mID, |
| 101 | cID: code.data.cID, |
| 102 | headers: headers, |
| 103 | code: ctx.query.code |
| 104 | } |
| 105 | } |
| 106 | } |