diff options
author | 2021-01-17 16:19:18 +0000 | |
---|---|---|
committer | 2021-01-17 16:19:18 +0000 | |
commit | c1bee9cb0efba823740095380cfcca9bf47eb196 (patch) | |
tree | 18ed06bca3d17341e9eeabc5364023b9f3ee250b /src/api/forms.ts | |
parent | Merge pull request #82 from python-discord/renovate/typescript-eslint-monorepo (diff) | |
parent | Centers Title With No Description (diff) |
Merge pull request #74 from python-discord/form-rendering
Diffstat (limited to 'src/api/forms.ts')
-rw-r--r-- | src/api/forms.ts | 38 |
1 files changed, 15 insertions, 23 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; +} |