aboutsummaryrefslogtreecommitdiffstats
path: root/src/api/forms.ts
blob: aec4b996b8542ae86a8660e3701e94f2e5697b71 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import { Question, QuestionType } from "./question";
import ApiClient from "./client";

export enum FormFeatures {
    Discoverable = "DISCOVERABLE",
    RequiresLogin = "REQUIRES_LOGIN",
    Open = "OPEN",
    CollectEmail = "COLLECT_EMAIL",
    DisableAntispam = "DISABLE_ANTISPAM"
}

export interface Form {
    id: string,
    features: Array<FormFeatures>,
    questions: Array<Question>,
    name: string,
    description: string
}

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 = {
        name: "Ban Appeals",
        id: "ban-appeals",
        description: "Appealing bans from the Discord server",
        features: [FormFeatures.Discoverable, FormFeatures.Open],
        questions: [
            {
                id: "how-spanish-are-you",
                name: "How Spanish are you?",
                type: QuestionType.ShortText,
                data: {}
            }
        ]
    };
    return new Promise((resolve) => {
        setTimeout(() => resolve(data), 1500);
    });
}