blob: 47b227507f9531bd4de50b775746babbb0f861cd [file] [log] [blame]
pineafana0e4b9b2021-11-02 21:10:49 +00001import Header from '../../Components/Header'
2import { Component } from 'react'
3import Styles from '../../styles/clicksforms/form.module.css';
pineafana0e4b9b2021-11-02 21:10:49 +00004import Question from '../../Components/ClicksForms/Question';
5
6export default class Form extends Component {
7 constructor(props) {
8 super(props);
pineafanf97734b2021-11-23 21:11:00 +00009}
pineafana0e4b9b2021-11-02 21:10:49 +000010
11 render() {
pineafanf97734b2021-11-23 21:11:00 +000012 console.log(this.props)
pineafana0e4b9b2021-11-02 21:10:49 +000013 return (
14 <>
15 <Header
pineafanf97734b2021-11-23 21:11:00 +000016 name={this.props.name}
17 subtext={this.props.description + (this.props.active ? '' : <><br />this.props is not accepting responses. Please check back later</>)}
pineafana0e4b9b2021-11-02 21:10:49 +000018 gradient={["71AFE5", "6576CC"]}
pineafana841c762021-11-14 21:21:04 +000019 wave="web/waves/header/clicksforms"
pineafana0e4b9b2021-11-02 21:10:49 +000020 buttons={[]}
21 />
22 <div id="start" />
23 <div className={Styles.form}>
24 <div className={Styles.header}>
pineafanf97734b2021-11-23 21:11:00 +000025 Once completing this.props, your response will be recorded
26 {this.props.anonymous ? " and your name will not be shown" : " and your username will be visible"}
pineafana0e4b9b2021-11-02 21:10:49 +000027 </div>
28 <div className={Styles.body}>
29 {
pineafanf97734b2021-11-23 21:11:00 +000030 this.props.questions.map((question, index) => {
pineafana0e4b9b2021-11-02 21:10:49 +000031 return (
32 <>
33 <Question
34 key={index}
35 title={question.title}
36 description={question.description}
37 colour={question.colour}
38 type={question.type}
39 options={question.options}
40 required={question.required}
41 />
42 </>
43 )
44 })
45 }
46 </div>
47 </div>
48 </>
49 )
50 }
51}
pineafanf97734b2021-11-23 21:11:00 +000052
53export async function getServerSideProps(ctx) {
54 console.log("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA")
55 if(!ctx.query.code) {
56 return {
57 redirect: {
58 destination: '/clicksforms/error/nocode',
59 permanent: true
60 }
61 }
62 }
63 const code = fetch(`https://cf.bots.clicksminuteper.net/code/${ctx.query.code}/token/BkjTUmNPk8S1aPVIYBt8rAUGQF692C8BEscJS9jGDwEtDJcy78uCVsHgRI1dspseGFoatakhWPHTAmYH42zhPpOjoaN1N9eLU7hB`, {
64 method: "GET",
65 mode: "cors"
66 })
67 console.log(code)
68 if ( (await code).status == 404 ) {
69 return {
70 redirect: {
71 destination: '/clicksforms/error/deleted',
72 permanent: true
73 }
74 }
75 } else if ( code.status != 200 ) {
76 return {
77 redirect: {
78 destination: '/clicksforms/error/unknown',
79 permanent: true
80 }
81 }
82 }
83
84 console.log(code.data)
85
86 return {
87 props: {
88 data: code.data
89 }
90 }
91}