pineafan | a0e4b9b | 2021-11-02 21:10:49 +0000 | [diff] [blame] | 1 | import Header from '../../Components/Header' |
| 2 | import { Component } from 'react' |
| 3 | import Styles from '../../styles/clicksforms/form.module.css'; |
pineafan | a0e4b9b | 2021-11-02 21:10:49 +0000 | [diff] [blame] | 4 | import Question from '../../Components/ClicksForms/Question'; |
| 5 | |
| 6 | export default class Form extends Component { |
| 7 | constructor(props) { |
| 8 | super(props); |
pineafan | f97734b | 2021-11-23 21:11:00 +0000 | [diff] [blame] | 9 | } |
pineafan | a0e4b9b | 2021-11-02 21:10:49 +0000 | [diff] [blame] | 10 | |
| 11 | render() { |
pineafan | f97734b | 2021-11-23 21:11:00 +0000 | [diff] [blame] | 12 | console.log(this.props) |
pineafan | a0e4b9b | 2021-11-02 21:10:49 +0000 | [diff] [blame] | 13 | return ( |
| 14 | <> |
| 15 | <Header |
pineafan | f97734b | 2021-11-23 21:11:00 +0000 | [diff] [blame] | 16 | name={this.props.name} |
| 17 | subtext={this.props.description + (this.props.active ? '' : <><br />this.props is not accepting responses. Please check back later</>)} |
pineafan | a0e4b9b | 2021-11-02 21:10:49 +0000 | [diff] [blame] | 18 | gradient={["71AFE5", "6576CC"]} |
pineafan | a841c76 | 2021-11-14 21:21:04 +0000 | [diff] [blame] | 19 | wave="web/waves/header/clicksforms" |
pineafan | a0e4b9b | 2021-11-02 21:10:49 +0000 | [diff] [blame] | 20 | buttons={[]} |
| 21 | /> |
| 22 | <div id="start" /> |
| 23 | <div className={Styles.form}> |
| 24 | <div className={Styles.header}> |
pineafan | f97734b | 2021-11-23 21:11:00 +0000 | [diff] [blame] | 25 | 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"} |
pineafan | a0e4b9b | 2021-11-02 21:10:49 +0000 | [diff] [blame] | 27 | </div> |
| 28 | <div className={Styles.body}> |
| 29 | { |
pineafan | f97734b | 2021-11-23 21:11:00 +0000 | [diff] [blame] | 30 | this.props.questions.map((question, index) => { |
pineafan | a0e4b9b | 2021-11-02 21:10:49 +0000 | [diff] [blame] | 31 | 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 | } |
pineafan | f97734b | 2021-11-23 21:11:00 +0000 | [diff] [blame] | 52 | |
| 53 | export 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 | } |