@functionalcms/svelte-components 5.24.2 → 5.24.3
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.
|
@@ -59,6 +59,8 @@
|
|
|
59
59
|
]
|
|
60
60
|
}: Props = $props();
|
|
61
61
|
|
|
62
|
+
let formErrors = errors ?? new Map<string, string>();
|
|
63
|
+
|
|
62
64
|
let form: HTMLFormElement;
|
|
63
65
|
let showMessage = $state(false);
|
|
64
66
|
|
|
@@ -231,7 +233,7 @@
|
|
|
231
233
|
<form method="POST" {action} class={css} bind:this={form}>
|
|
232
234
|
<fieldset>
|
|
233
235
|
{#each fields as field}
|
|
234
|
-
<div class={hasErrors(field,
|
|
236
|
+
<div class={hasErrors(field, formErrors)}>
|
|
235
237
|
{#if field.typeOfField === 'input'}
|
|
236
238
|
{@render renderInput(field)}
|
|
237
239
|
{:else if field.typeOfField === 'textarea'}
|
|
@@ -255,7 +257,7 @@
|
|
|
255
257
|
{:else if field.typeOfField === 'html'}
|
|
256
258
|
{@render renderHtmlEditory(field)}
|
|
257
259
|
{/if}
|
|
258
|
-
{@render showErrors(field,
|
|
260
|
+
{@render showErrors(field, formErrors)}
|
|
259
261
|
</div>
|
|
260
262
|
{/each}
|
|
261
263
|
|
|
@@ -128,4 +128,4 @@ export type ButtonConfig = {
|
|
|
128
128
|
class?: string;
|
|
129
129
|
action?: (event: Event) => Promise<void>;
|
|
130
130
|
};
|
|
131
|
-
export declare function convertResponseToFields(fields: Array<Field>, request:
|
|
131
|
+
export declare function convertResponseToFields(fields: Array<Field>, request: Request): Promise<any>;
|
package/package.json
CHANGED
|
@@ -1,17 +1,25 @@
|
|
|
1
1
|
import { DOMAIN } from '$env/static/private';
|
|
2
2
|
import { getUsersService } from '@functionalcms/svelte-components/index-server.js';
|
|
3
|
-
import {
|
|
4
|
-
|
|
3
|
+
import { convertResponseToFields } from '@functionalcms/svelte-components';
|
|
4
|
+
import { fields } from './fields';
|
|
5
5
|
/** @type {import('./$types').PageServerLoad} */
|
|
6
|
-
export async function load({ params }) {
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
return { code };
|
|
6
|
+
export async function load({ params, locals, url }) {
|
|
7
|
+
const username = params.email;
|
|
8
|
+
return { username, success: false };
|
|
10
9
|
}
|
|
11
10
|
|
|
12
11
|
export const actions = {
|
|
13
|
-
setup: async ({ request, locals, params }) => {
|
|
12
|
+
setup: async ({ request, locals, params, url }) => {
|
|
14
13
|
const userService = getUsersService(locals);
|
|
14
|
+
const code = url.searchParams.get("code");
|
|
15
|
+
|
|
16
|
+
const data = await convertResponseToFields(fields, request);
|
|
17
|
+
|
|
18
|
+
if (data.password != data.confirm) {
|
|
19
|
+
return {
|
|
20
|
+
errors: new Map<string, string>([["confirm", m.auth_password_do_not_match()]])
|
|
21
|
+
}
|
|
22
|
+
}
|
|
15
23
|
|
|
16
24
|
const result = await userService.setup(DOMAIN, params.email);
|
|
17
25
|
|
|
@@ -1,25 +1,33 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import {
|
|
3
3
|
Button,
|
|
4
|
+
createInputField,
|
|
5
|
+
InputType,
|
|
6
|
+
SmartForm,
|
|
4
7
|
Spinner,
|
|
5
8
|
} from "@functionalcms/svelte-components";
|
|
6
9
|
import * as m from "$lib/paraglide/messages.js";
|
|
7
10
|
import { deserialize } from "$app/forms";
|
|
11
|
+
import { fields } from "./fields.js";
|
|
8
12
|
|
|
9
13
|
interface Props {
|
|
10
14
|
data: {
|
|
11
|
-
|
|
15
|
+
username: string | null;
|
|
16
|
+
errors: string
|
|
12
17
|
};
|
|
18
|
+
form: any
|
|
13
19
|
}
|
|
14
20
|
|
|
15
|
-
let { data } = $props();
|
|
21
|
+
let { data, form = {} } = $props();
|
|
16
22
|
|
|
23
|
+
let submitError = $state(false);
|
|
17
24
|
|
|
18
25
|
let isProcesing = $state(false);
|
|
19
26
|
let resultMessage = $state("");
|
|
20
27
|
|
|
21
28
|
async function resetPassword() {
|
|
22
29
|
isProcesing = true;
|
|
30
|
+
submitError = false;
|
|
23
31
|
|
|
24
32
|
const response = await fetch("?/setup", {
|
|
25
33
|
method: "POST",
|
|
@@ -42,21 +50,31 @@
|
|
|
42
50
|
class="flex flex-col justify-around items-center gap-4 w-full m-auto p-4"
|
|
43
51
|
>
|
|
44
52
|
<h1>{m.auth_setup_title()}</h1>
|
|
45
|
-
{#if !data.
|
|
53
|
+
{#if !data.username}
|
|
46
54
|
<p>{m.auth_setup_missing_code()}</p>
|
|
47
55
|
{:else}
|
|
48
56
|
<div>
|
|
49
57
|
{@html m.auth_setup_into()}
|
|
50
58
|
</div>
|
|
51
|
-
<
|
|
52
|
-
{
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
{
|
|
56
|
-
|
|
59
|
+
<SmartForm
|
|
60
|
+
{fields}
|
|
61
|
+
errors={form?.errors}
|
|
62
|
+
action="?/setup"
|
|
63
|
+
buttons={[
|
|
64
|
+
{
|
|
65
|
+
type: "submit",
|
|
66
|
+
label: m.auth_submit(),
|
|
67
|
+
color: "primary",
|
|
68
|
+
},
|
|
69
|
+
]}
|
|
70
|
+
/>
|
|
57
71
|
{#if resultMessage != ""}
|
|
58
72
|
<p>{resultMessage}</p>
|
|
59
73
|
{/if}
|
|
74
|
+
|
|
75
|
+
{#if submitError}
|
|
76
|
+
<p class="text-red-600">{m.auth_setup_error()}</p>
|
|
77
|
+
{/if}
|
|
60
78
|
{/if}
|
|
61
79
|
</main>
|
|
62
80
|
</article>
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { m } from "$lib/paraglide/messages";
|
|
2
|
+
import { createInputField, InputType } from "@functionalcms/svelte-components";
|
|
3
|
+
|
|
4
|
+
export const fields = [
|
|
5
|
+
createInputField(
|
|
6
|
+
"password",
|
|
7
|
+
m.auth_password(),
|
|
8
|
+
InputType.Password,
|
|
9
|
+
"",
|
|
10
|
+
{
|
|
11
|
+
required: true,
|
|
12
|
+
},
|
|
13
|
+
),
|
|
14
|
+
createInputField(
|
|
15
|
+
"confirm",
|
|
16
|
+
m.auth_comnfirm_password(),
|
|
17
|
+
InputType.Password,
|
|
18
|
+
"",
|
|
19
|
+
{
|
|
20
|
+
required: true,
|
|
21
|
+
},
|
|
22
|
+
),
|
|
23
|
+
];
|