feat(#79): Handle loading state

This commit is contained in:
Josh Creek
2024-11-10 19:58:50 +00:00
parent 3b1ffb21a6
commit c3125a0db1
+5 -1
View File
@@ -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>