From 0d8b3cc86a6600655c487b3a5cb999dafdab5a0b Mon Sep 17 00:00:00 2001 From: May <40745122+SomewhatMay@users.noreply.github.com> Date: Sun, 10 Mar 2024 21:28:11 -0400 Subject: [PATCH] Creating a form now opens it immediately - ref #23 --- src/lib/actions.ts | 9 +++++++-- src/lib/components/AddForm.svelte | 3 +++ src/lib/components/FormsList.svelte | 14 +++++++------- 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/src/lib/actions.ts b/src/lib/actions.ts index b1203c0..1f6b37a 100644 --- a/src/lib/actions.ts +++ b/src/lib/actions.ts @@ -1,5 +1,6 @@ import { get } from "svelte/store"; -import { activeResponses, response, responseQueue } from "$lib/store"; +import { activeResponses, response, responseQueue} from "$lib/store"; +import { goto } from "$app/navigation"; export const deleteResponse = (id: number) => { const responses = get(activeResponses); @@ -27,4 +28,8 @@ export const submitResponse = (id: number) => { responses[id] = response; activeResponses.set(responses); } - \ No newline at end of file + +export const setResponse = (id: number) => { + response.set(id); + goto("/form"); +}; \ No newline at end of file diff --git a/src/lib/components/AddForm.svelte b/src/lib/components/AddForm.svelte index 8083a21..2315c85 100644 --- a/src/lib/components/AddForm.svelte +++ b/src/lib/components/AddForm.svelte @@ -4,6 +4,7 @@ import Checkbox from "./FormFlow/Checkbox.svelte"; import { formTypes } from "$lib/formLayout"; import type { FormType } from "$lib/types"; + import { setResponse } from "$lib/actions"; let team = ""; let match = ""; @@ -39,6 +40,8 @@ $errors[id] = true; match = ""; team = ""; + + setResponse(id); } } diff --git a/src/lib/components/FormsList.svelte b/src/lib/components/FormsList.svelte index 0536d59..255ad19 100644 --- a/src/lib/components/FormsList.svelte +++ b/src/lib/components/FormsList.svelte @@ -1,15 +1,15 @@