From ce316baf3c5615122e3ab41ceedbc78137e86b48 Mon Sep 17 00:00:00 2001 From: Hassan Abouelela <47495861+HassanAbouelela@users.noreply.github.com> Date: Mon, 4 Jan 2021 02:25:55 +0300 Subject: Updates Models Changes the models to match the backend. Signed-off-by: Hassan Abouelela <47495861+HassanAbouelela@users.noreply.github.com> --- src/api/forms.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src/api/forms.ts') diff --git a/src/api/forms.ts b/src/api/forms.ts index aec4b99..3869838 100644 --- a/src/api/forms.ts +++ b/src/api/forms.ts @@ -6,17 +6,24 @@ export enum FormFeatures { RequiresLogin = "REQUIRES_LOGIN", Open = "OPEN", CollectEmail = "COLLECT_EMAIL", - DisableAntispam = "DISABLE_ANTISPAM" + DisableAntispam = "DISABLE_ANTISPAM", + WEBHOOK_ENABLED = "WEBHOOK_ENABLED" } export interface Form { id: string, features: Array, + webhook: WebHook | null, questions: Array, name: string, description: string } +export interface WebHook { + url: string, + message: string | null +} + export async function getForms(): Promise { const resp = await ApiClient.get("forms/discoverable"); return resp.data; -- cgit v1.2.3 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 From b23420b6870c42843608fa2c26c70510009f3560 Mon Sep 17 00:00:00 2001 From: Hassan Abouelela <47495861+HassanAbouelela@users.noreply.github.com> Date: Mon, 4 Jan 2021 19:21:02 +0300 Subject: Fixes Model Casing Changes the casing of the webhook enabled enum to fit with the other enums. Co-authored-by: ks129 <45097959+ks129@users.noreply.github.com> --- src/api/forms.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/api/forms.ts') diff --git a/src/api/forms.ts b/src/api/forms.ts index 8c31e5b..12b9abf 100644 --- a/src/api/forms.ts +++ b/src/api/forms.ts @@ -7,7 +7,7 @@ export enum FormFeatures { Open = "OPEN", CollectEmail = "COLLECT_EMAIL", DisableAntispam = "DISABLE_ANTISPAM", - WEBHOOK_ENABLED = "WEBHOOK_ENABLED" + WebhookEnabled = "WEBHOOK_ENABLED" } export interface Form { -- cgit v1.2.3