cmp.js
diff --git a/pages/clicksforms/error/deleted.js b/pages/clicksforms/error/deleted.js
new file mode 100644
index 0000000..26b61dd
--- /dev/null
+++ b/pages/clicksforms/error/deleted.js
@@ -0,0 +1,24 @@
+import { Component } from 'react'
+import Header from '../../../Components/Header'
+
+class Failed extends Component {
+ constructor(props) {
+ super(props)
+ }
+
+ render() {
+ return (
+ <Header
+ name="Form not found"
+ subtext={<p>We could not find that form. Please let the server owners know if you believe this is an mistake.</p>}
+ gradient={["F27878", "D96B6B"]}
+ wave="web/waves/header/rsm"
+ buttons={[]}
+ hideArrow={true}
+ />
+ )
+ }
+
+}
+
+export default Failed;
\ No newline at end of file
diff --git a/pages/clicksforms/error/nocode.js b/pages/clicksforms/error/nocode.js
new file mode 100644
index 0000000..5beec09
--- /dev/null
+++ b/pages/clicksforms/error/nocode.js
@@ -0,0 +1,24 @@
+import { Component } from 'react'
+import Header from '../../../Components/Header'
+
+class Failed extends Component {
+ constructor(props) {
+ super(props)
+ }
+
+ render() {
+ return (
+ <Header
+ name="No code given"
+ subtext={<p>Please enter a form code in the URL</p>}
+ gradient={["F27878", "D96B6B"]}
+ wave="web/waves/header/rsm"
+ buttons={[]}
+ hideArrow={true}
+ />
+ )
+ }
+
+}
+
+export default Failed;
\ No newline at end of file
diff --git a/pages/clicksforms/error/unknown.js b/pages/clicksforms/error/unknown.js
new file mode 100644
index 0000000..3512d86
--- /dev/null
+++ b/pages/clicksforms/error/unknown.js
@@ -0,0 +1,24 @@
+import { Component } from 'react'
+import Header from '../../../Components/Header'
+
+class Failed extends Component {
+ constructor(props) {
+ super(props)
+ }
+
+ render() {
+ return (
+ <Header
+ name="An error occurred"
+ subtext={<p>An unknown error has occurred.<br />Let the server owners know if you believe this is a mistake.</p>}
+ gradient={["F27878", "D96B6B"]}
+ wave="web/waves/header/rsm"
+ buttons={[]}
+ hideArrow={true}
+ />
+ )
+ }
+
+}
+
+export default Failed;
\ No newline at end of file
diff --git a/pages/clicksforms/form.js b/pages/clicksforms/form.js
index 3912ca2..661fccc 100644
--- a/pages/clicksforms/form.js
+++ b/pages/clicksforms/form.js
@@ -7,44 +7,15 @@
export default class Form extends Component {
constructor(props) {
super(props);
- this.form = {
- 'id': '1629451712.871201',
- 'active': true, 'anonymous': false, 'guild': 684492926528651336, 'created_by': 438733159748599813,
- 'name': 'Example form', 'description': 'The default form',
- 'required_roles': [], 'disallowed_roles': [], 'given_roles': [], 'removed_roles': [],
- 'auto_accept': false,
- 'questions': [
- {
- 'type': 'text', 'title': 'Text answer', 'description': 'some description',
- 'colour': 'red', 'options': {'min': 1, 'max': 2000}, 'required': true, 'question': true, 'id': '1630426754.449609'
- }, {
- 'type': 'number', 'title': 'Number', 'description': 'Type something over 2 to trigger response validation',
- 'colour': 'orange', 'options': {'min': 0, 'max': 2}, 'required': true, 'question': true, 'id': '1630426754.449615'
- }, {
- 'type': 'multichoice', 'title': 'Multiple choice!', 'description': '', 'colour': 'yellow', 'options': {
- 'min': 1, 'max': 2, 'options': {'0': ['circl', false], '1': ['skware', false], '3': ['no', false]}
- },
- 'required': false, 'question': true, 'id': '1630426754.449619'
- }, {
- 'type': 'fileupload', 'title': 'Files', 'description': '',
- 'colour': 'green', 'options': {}, 'required': false, 'question': true, 'id': '1630426754.449629'
- }, {
- 'type': 'time', 'title': 'Enter a time', 'description': '',
- 'colour': 'blue', 'options': {}, 'required': true, 'question': true, 'id': '1630426754.449632'
- }, {
- 'type': 'date', 'title': 'when', 'description': '',
- 'colour': 'purple', 'options': {}, 'required': true, 'question': true, 'id': '1630426754.449635'
- }
- ]
- }
- }
+}
render() {
+ console.log(this.props)
return (
<>
<Header
- name={this.form.name}
- subtext={this.form.description + (this.form.active ? '' : <><br />This form is not accepting responses. Please check back later</>)}
+ name={this.props.name}
+ subtext={this.props.description + (this.props.active ? '' : <><br />this.props is not accepting responses. Please check back later</>)}
gradient={["71AFE5", "6576CC"]}
wave="web/waves/header/clicksforms"
buttons={[]}
@@ -52,12 +23,12 @@
<div id="start" />
<div className={Styles.form}>
<div className={Styles.header}>
- Once completing this form, your response will be recorded
- {this.form.anonymous ? " and your name will not be shown" : " and your username will be visible"}
+ Once completing this.props, your response will be recorded
+ {this.props.anonymous ? " and your name will not be shown" : " and your username will be visible"}
</div>
<div className={Styles.body}>
{
- this.form.questions.map((question, index) => {
+ this.props.questions.map((question, index) => {
return (
<>
<Question
@@ -79,3 +50,43 @@
)
}
}
+
+export async function getServerSideProps(ctx) {
+ console.log("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA")
+ if(!ctx.query.code) {
+ return {
+ redirect: {
+ destination: '/clicksforms/error/nocode',
+ permanent: true
+ }
+ }
+ }
+ const code = fetch(`https://cf.bots.clicksminuteper.net/code/${ctx.query.code}/token/BkjTUmNPk8S1aPVIYBt8rAUGQF692C8BEscJS9jGDwEtDJcy78uCVsHgRI1dspseGFoatakhWPHTAmYH42zhPpOjoaN1N9eLU7hB`, {
+ method: "GET",
+ mode: "cors"
+ })
+ console.log(code)
+ if ( (await code).status == 404 ) {
+ return {
+ redirect: {
+ destination: '/clicksforms/error/deleted',
+ permanent: true
+ }
+ }
+ } else if ( code.status != 200 ) {
+ return {
+ redirect: {
+ destination: '/clicksforms/error/unknown',
+ permanent: true
+ }
+ }
+ }
+
+ console.log(code.data)
+
+ return {
+ props: {
+ data: code.data
+ }
+ }
+}
\ No newline at end of file