diff options
author | 2020-12-14 19:18:19 +0000 | |
---|---|---|
committer | 2020-12-14 19:18:19 +0000 | |
commit | a1963eb56f9682a6315a06a075d09314822dbfd9 (patch) | |
tree | d0856e1326516447a33951de623770787f6ef996 /src/api/forms.ts | |
parent | Merge pull request #29 from python-discord/dependabot/npm_and_yarn/ini-1.3.8 (diff) | |
parent | Simplify Axios client baseURL definition (diff) |
Merge pull request #30 from python-discord/ks123/discovery
Diffstat (limited to 'src/api/forms.ts')
-rw-r--r-- | src/api/forms.ts | 52 |
1 files changed, 21 insertions, 31 deletions
diff --git a/src/api/forms.ts b/src/api/forms.ts index a4a4981..724d6b7 100644 --- a/src/api/forms.ts +++ b/src/api/forms.ts @@ -1,49 +1,39 @@ import { Question, QuestionType } from "./question" +import ApiClient from "./client"; -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<Question> +export interface Form { + id: string, + features: Array<FormFeatures>, + questions: Array<Question>, + name: string, + description: string } -export function getForms(): AllFormsForm[] { - 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<Form[]> { + const resp = await ApiClient.get("forms/discoverable"); + return resp.data; } export function getForm(id: string): Promise<Form> { 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: {} } ] } |