From 8346eb9e052d10abf4fb65b66838aaab47152e2a Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Fri, 30 Aug 2024 18:52:00 -0700 Subject: typescript --- src/lib/handler.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 src/lib/handler.ts (limited to 'src/lib/handler.ts') diff --git a/src/lib/handler.ts b/src/lib/handler.ts new file mode 100644 index 00000000..05e484ec --- /dev/null +++ b/src/lib/handler.ts @@ -0,0 +1,14 @@ +import { goto } from "$app/navigation"; +import { applyAction } from "$app/forms"; + +export default (submitting) => + ({ formElement, formData, action, cancel }) => { + submitting = true; + return async ({ result }) => { + if (result.type === "redirect") { + goto(result.location); + } else { + await applyAction(result); + } + }; + }; -- cgit v1.2.3