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