aboutsummaryrefslogtreecommitdiffstats
path: root/src/api
diff options
context:
space:
mode:
Diffstat (limited to 'src/api')
-rw-r--r--src/api/forms.ts38
-rw-r--r--src/api/question.ts2
2 files changed, 16 insertions, 24 deletions
diff --git a/src/api/forms.ts b/src/api/forms.ts
index aec4b99..12b9abf 100644
--- a/src/api/forms.ts
+++ b/src/api/forms.ts
@@ -1,4 +1,4 @@
-import { Question, QuestionType } from "./question";
+import { Question } from "./question";
import ApiClient from "./client";
export enum FormFeatures {
@@ -6,38 +6,30 @@ export enum FormFeatures {
RequiresLogin = "REQUIRES_LOGIN",
Open = "OPEN",
CollectEmail = "COLLECT_EMAIL",
- DisableAntispam = "DISABLE_ANTISPAM"
+ DisableAntispam = "DISABLE_ANTISPAM",
+ WebhookEnabled = "WEBHOOK_ENABLED"
}
export interface Form {
id: string,
features: Array<FormFeatures>,
+ webhook: WebHook | null,
questions: Array<Question>,
name: string,
description: string
}
+export interface WebHook {
+ url: string,
+ message: string | null
+}
+
export async function getForms(): Promise<Form[]> {
- const resp = await ApiClient.get("forms/discoverable");
- return resp.data;
+ const fetch_response = await ApiClient.get("forms/discoverable");
+ return fetch_response.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);
- });
-}
+export async function getForm(id: string): Promise<Form> {
+ const fetch_response = await ApiClient.get(`forms/${id}`);
+ return fetch_response.data;
+}
diff --git a/src/api/question.ts b/src/api/question.ts
index 18951b9..9824b60 100644
--- a/src/api/question.ts
+++ b/src/api/question.ts
@@ -13,6 +13,6 @@ export interface Question {
id: string,
name: string,
type: QuestionType,
- data: { [key: string]: any },
+ data: { [key: string]: string | string[] },
required: boolean
}