aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/handler.ts
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2024-08-30 18:52:00 -0700
committerAdam Soltys <[email protected]>2024-08-30 18:52:00 -0700
commit8346eb9e052d10abf4fb65b66838aaab47152e2a (patch)
tree0f5efabd144b720598441d9a638fd27d849628ff /src/lib/handler.ts
parentcb2edf24e48a49417ed6ec4a386e566470ff046c (diff)
downloadcoinos-ui-8346eb9e052d10abf4fb65b66838aaab47152e2a.tar.gz
coinos-ui-8346eb9e052d10abf4fb65b66838aaab47152e2a.zip
typescript
Diffstat (limited to 'src/lib/handler.ts')
-rw-r--r--src/lib/handler.ts14
1 files changed, 14 insertions, 0 deletions
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);
+ }
+ };
+ };