aboutsummaryrefslogtreecommitdiffstats
path: root/src/api/forms.ts
diff options
context:
space:
mode:
authorGravatar Hassan Abouelela <[email protected]>2021-01-04 02:27:36 +0300
committerGravatar Hassan Abouelela <[email protected]>2021-01-04 04:02:27 +0300
commite6f71e521c437971b376b845b3bc6bac40b8396a (patch)
tree2743240a4eb4f7b0db9c6e4ba23fccc8f452ca1c /src/api/forms.ts
parentUpdates Models (diff)
Implements Form Fetching
Fetches forms from the backend to be displayed. Signed-off-by: Hassan Abouelela <[email protected]>
Diffstat (limited to 'src/api/forms.ts')
-rw-r--r--src/api/forms.ts29
1 files changed, 7 insertions, 22 deletions
diff --git a/src/api/forms.ts b/src/api/forms.ts
index 3869838..8c31e5b 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 {
@@ -25,26 +25,11 @@ export interface WebHook {
}
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;
+}