@webamoki/web-svelte 0.5.25 → 0.5.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/utils/form.js +11 -1
- package/package.json +1 -1
package/dist/utils/form.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { toast } from 'svelte-sonner';
|
|
2
1
|
import { dateTransport } from './index.js';
|
|
3
2
|
import { type } from 'arktype';
|
|
3
|
+
import { toast } from 'svelte-sonner';
|
|
4
4
|
import { defaults, superForm, superValidate } from 'sveltekit-superforms';
|
|
5
5
|
import { arktype, arktypeClient } from 'sveltekit-superforms/adapters';
|
|
6
6
|
export function prepareForm(validated, schema, options) {
|
|
@@ -23,6 +23,11 @@ export function prepareForm(validated, schema, options) {
|
|
|
23
23
|
else {
|
|
24
24
|
toast.error(text);
|
|
25
25
|
}
|
|
26
|
+
},
|
|
27
|
+
onError({ result }) {
|
|
28
|
+
const message = result.error.message ?? 'There was an error submitting the form';
|
|
29
|
+
const status = result.status ?? 500;
|
|
30
|
+
toast.error(`${status} - ${message}`);
|
|
26
31
|
}
|
|
27
32
|
});
|
|
28
33
|
const delayed = form.delayed;
|
|
@@ -49,6 +54,11 @@ export function prepareEmptyForm(schema, options) {
|
|
|
49
54
|
else {
|
|
50
55
|
toast.error(text);
|
|
51
56
|
}
|
|
57
|
+
},
|
|
58
|
+
onError({ result }) {
|
|
59
|
+
const message = result.error.message ?? 'There was an error submitting the form';
|
|
60
|
+
const status = result.status ?? 500;
|
|
61
|
+
toast.error(`${status} - ${message}`);
|
|
52
62
|
}
|
|
53
63
|
});
|
|
54
64
|
const delayed = form.delayed;
|