@functionalcms/svelte-components 5.8.2 → 5.8.4
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.
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
type ButtonConfig,
|
|
12
12
|
type HiddenField,
|
|
13
13
|
type DatePickerField,
|
|
14
|
-
SubmitResult
|
|
14
|
+
SubmitResult
|
|
15
15
|
} from './form.js';
|
|
16
16
|
import {
|
|
17
17
|
Button,
|
|
@@ -58,11 +58,22 @@
|
|
|
58
58
|
let isSendingMessage = $state(false);
|
|
59
59
|
let loading = $state(false);
|
|
60
60
|
|
|
61
|
+
const isValid = (event: Event) => {
|
|
62
|
+
const button = event.target as HTMLButtonElement;
|
|
63
|
+
const form = button.closest('form') as HTMLFormElement;
|
|
64
|
+
const formData = new FormData(form);
|
|
65
|
+
|
|
66
|
+
const allValid = Array.from(formData.entries()).every(([, value]) => {
|
|
67
|
+
return value && value.toString().trim() !== '';
|
|
68
|
+
});
|
|
69
|
+
return allValid;
|
|
70
|
+
};
|
|
71
|
+
|
|
61
72
|
const handleSubmit = async (event: Event) => {
|
|
62
73
|
event.preventDefault();
|
|
63
74
|
loading = true;
|
|
64
75
|
try {
|
|
65
|
-
if (!isSendingMessage) {
|
|
76
|
+
if (isValid(event) && !isSendingMessage) {
|
|
66
77
|
isSendingMessage = true;
|
|
67
78
|
const formData = new FormData(form);
|
|
68
79
|
const response = await fetch(action, {
|
|
@@ -144,7 +155,7 @@
|
|
|
144
155
|
required={field.required}
|
|
145
156
|
disabled={field.disabled}
|
|
146
157
|
class={field.class}
|
|
147
|
-
items={field.options.map(option => ({ name: option.label, value: option.value }))}
|
|
158
|
+
items={field.options.map((option) => ({ name: option.label, value: option.value }))}
|
|
148
159
|
bind:value={field.value}
|
|
149
160
|
/>
|
|
150
161
|
{:else}
|
|
@@ -3,7 +3,7 @@ const authorizationHandle = () => {
|
|
|
3
3
|
const path = event.url.pathname;
|
|
4
4
|
if (path.startsWith('/auth/') === false) {
|
|
5
5
|
const route = event.route;
|
|
6
|
-
if (route
|
|
6
|
+
if (route?.id?.includes('/(protect)')) {
|
|
7
7
|
const user = event?.locals?.user;
|
|
8
8
|
if (!user) {
|
|
9
9
|
const cookieHeader = `retrunToAddress=${event.url.toString()}; HttpOnly; Secure; SameSite=Lax; Max-Age=3600; Path=/`;
|