From 296ee9774e53d990f73bf7f56edc5ec351f0609f Mon Sep 17 00:00:00 2001 From: ks129 <45097959+ks129@users.noreply.github.com> Date: Sun, 13 Dec 2020 20:44:28 +0200 Subject: Update form interface and add features --- src/api/forms.ts | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) (limited to 'src/api/forms.ts') diff --git a/src/api/forms.ts b/src/api/forms.ts index a4a4981..c20a587 100644 --- a/src/api/forms.ts +++ b/src/api/forms.ts @@ -1,17 +1,22 @@ import { Question, QuestionType } from "./question" -export interface AllFormsForm { - title: string, - id: string, - description: string, - open: boolean +export enum FormFeatures { + Discoverable = "DISCOVERABLE", + RequiresLogin = "REQUIRES_LOGIN", + Open = "OPEN", + CollectEmail = "COLLECT_EMAIL", + DisableAntispam = "DISABLE_ANTISPAM" } -export interface Form extends AllFormsForm { - questions: Array +export interface Form { + id: string, + features: Array, + questions: Array, + name: string, + description: string } -export function getForms(): AllFormsForm[] { +export function getForms(): Form[] { return [ { title: "Ban Appeals", @@ -36,14 +41,16 @@ export function getForms(): AllFormsForm[] { export function getForm(id: string): Promise
{ const data: Form = { - title: "Ban Appeals", + name: "Ban Appeals", id: "ban-appeals", description: "Appealing bans from the Discord server", - open: true, + features: [FormFeatures.Discoverable, FormFeatures.Open], questions: [ { + id: "how-spanish-are-you", name: "How Spanish are you?", - type: QuestionType.Text + type: QuestionType.ShortText, + data: {} } ] } -- cgit v1.2.3 From 8e2b2764b136b9e742f75f7b4a3621cb56238bc6 Mon Sep 17 00:00:00 2001 From: ks129 <45097959+ks129@users.noreply.github.com> Date: Mon, 14 Dec 2020 10:50:43 +0200 Subject: Update getForms function to fetch data from API --- src/api/forms.ts | 25 ++++--------------------- 1 file changed, 4 insertions(+), 21 deletions(-) (limited to 'src/api/forms.ts') diff --git a/src/api/forms.ts b/src/api/forms.ts index c20a587..724d6b7 100644 --- a/src/api/forms.ts +++ b/src/api/forms.ts @@ -1,4 +1,5 @@ import { Question, QuestionType } from "./question" +import ApiClient from "./client"; export enum FormFeatures { Discoverable = "DISCOVERABLE", @@ -16,27 +17,9 @@ export interface Form { description: string } -export function getForms(): Form[] { - return [ - { - title: "Ban Appeals", - id: "ban-appeals", - description: "Appealing bans from the Discord server", - open: true - }, - { - title: "Insights 2020", - id: "insights-2020", - description: "Insights about the Python Discord community", - open: false - }, - { - title: "Code Jam 2099 Sign Ups", - id: "code-jam-2099-sign-up", - description: "Signing up for Python Discord's millionth code jam!", - open: false - } - ] +export async function getForms(): Promise { + const resp = await ApiClient.get("forms/discoverable"); + return resp.data; } export function getForm(id: string): Promise { -- cgit v1.2.3