mirror of
https://github.com/jcreek/SvelteKitSaasBoilerplate.git
synced 2026-07-12 18:43:50 +00:00
feat(#79): Handle loading state
This commit is contained in:
@@ -8,13 +8,17 @@
|
|||||||
let submitted = false;
|
let submitted = false;
|
||||||
let error = '';
|
let error = '';
|
||||||
|
|
||||||
const handleSubmit: SubmitFunction = ({}) => {
|
const handleSubmit: SubmitFunction = () => {
|
||||||
|
let loading = false;
|
||||||
return async ({ result, update }) => {
|
return async ({ result, update }) => {
|
||||||
|
loading = true;
|
||||||
if (result.data && result.data.success) {
|
if (result.data && result.data.success) {
|
||||||
submitted = true;
|
submitted = true;
|
||||||
} else {
|
} else {
|
||||||
error = result.error?.message || 'Form submission failed';
|
error = result.error?.message || 'Form submission failed';
|
||||||
}
|
}
|
||||||
|
loading = false;
|
||||||
|
await update();
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Reference in New Issue
Block a user