Skip to content

Commit

Permalink
Creating a form now opens it immediately - ref #23
Browse files Browse the repository at this point in the history
  • Loading branch information
SomewhatMay committed Mar 11, 2024
1 parent b8b25c8 commit 0d8b3cc
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 9 deletions.
9 changes: 7 additions & 2 deletions src/lib/actions.ts
Original file line number Diff line number Diff line change
@@ -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);
Expand Down Expand Up @@ -27,4 +28,8 @@ export const submitResponse = (id: number) => {
responses[id] = response;
activeResponses.set(responses);
}


export const setResponse = (id: number) => {
response.set(id);
goto("/form");
};
3 changes: 3 additions & 0 deletions src/lib/components/AddForm.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "";
Expand Down Expand Up @@ -39,6 +40,8 @@
$errors[id] = true;
match = "";
team = "";
setResponse(id);
}
}
Expand Down
14 changes: 7 additions & 7 deletions src/lib/components/FormsList.svelte
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<script lang="ts">
import { goto } from "$app/navigation";
import { submitResponse, deleteResponse } from "$lib/actions";
import { submitResponse, deleteResponse, setResponse } from "$lib/actions";
import { activeResponses, errors, response } from "$lib/store";
import { base } from "$app/paths";
const setResponse = (id: number) => {
$response = id;
//goto(`${base}/form`);
goto("form");
console.log($response)
};
// const setResponse = (id: number) => {
// $response = id;
// //goto(`${base}/form`);
// goto("/form");
// console.log($response)
// };
$: responses = Object.values($activeResponses);
</script>
Expand Down

0 comments on commit 0d8b3cc

Please sign in to comment.