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