From e6f71e521c437971b376b845b3bc6bac40b8396a Mon Sep 17 00:00:00 2001 From: Hassan Abouelela <47495861+HassanAbouelela@users.noreply.github.com> Date: Mon, 4 Jan 2021 02:27:36 +0300 Subject: Implements Form Fetching Fetches forms from the backend to be displayed. Signed-off-by: Hassan Abouelela <47495861+HassanAbouelela@users.noreply.github.com> --- src/api/forms.ts | 29 +++++++---------------------- 1 file changed, 7 insertions(+), 22 deletions(-) (limited to 'src/api/forms.ts') 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 { - 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
{ - 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 { + const fetch_response = await ApiClient.get(`forms/${id}`); + return fetch_response.data; +} -- cgit v1.2.3