@functionalcms/svelte-components 5.24.3 → 5.24.5
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.
|
@@ -77,13 +77,13 @@
|
|
|
77
77
|
};
|
|
78
78
|
|
|
79
79
|
function hasErrors(field: any, errors: Map<string, string>) {
|
|
80
|
-
return errors.has(
|
|
80
|
+
return errors.has(field?.id) ? 'error' : '';
|
|
81
81
|
}
|
|
82
82
|
</script>
|
|
83
83
|
|
|
84
|
-
{#snippet showErrors(
|
|
85
|
-
{#if errors.has(
|
|
86
|
-
<
|
|
84
|
+
{#snippet showErrors(field: InputField, errors: Map<string, string>)}
|
|
85
|
+
{#if errors.has(field.id)}
|
|
86
|
+
<span>{errors.get(field.id)}</span>
|
|
87
87
|
{/if}
|
|
88
88
|
{/snippet}
|
|
89
89
|
{#snippet renderInput(field: InputField)}
|
package/package.json
CHANGED
|
@@ -2,6 +2,8 @@ import { DOMAIN } from '$env/static/private';
|
|
|
2
2
|
import { getUsersService } from '@functionalcms/svelte-components/index-server.js';
|
|
3
3
|
import { convertResponseToFields } from '@functionalcms/svelte-components';
|
|
4
4
|
import { fields } from './fields';
|
|
5
|
+
import * as m from "$lib/paraglide/messages.js";
|
|
6
|
+
|
|
5
7
|
/** @type {import('./$types').PageServerLoad} */
|
|
6
8
|
export async function load({ params, locals, url }) {
|
|
7
9
|
const username = params.email;
|
|
@@ -1,82 +1,71 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
SmartForm,
|
|
7
|
-
Spinner,
|
|
8
|
-
} from "@functionalcms/svelte-components";
|
|
9
|
-
import * as m from "$lib/paraglide/messages.js";
|
|
10
|
-
import { deserialize } from "$app/forms";
|
|
11
|
-
import { fields } from "./fields.js";
|
|
2
|
+
import { SmartForm } from '@functionalcms/svelte-components';
|
|
3
|
+
import * as m from '$lib/paraglide/messages.js';
|
|
4
|
+
import { deserialize } from '$app/forms';
|
|
5
|
+
import { fields } from './fields.js';
|
|
12
6
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
7
|
+
interface Props {
|
|
8
|
+
data: {
|
|
9
|
+
username: string | null;
|
|
10
|
+
errors: string;
|
|
11
|
+
};
|
|
12
|
+
form: any;
|
|
13
|
+
}
|
|
20
14
|
|
|
21
|
-
|
|
15
|
+
let { data, form = {} } = $props();
|
|
22
16
|
|
|
23
|
-
|
|
17
|
+
let submitError = $state(false);
|
|
24
18
|
|
|
25
|
-
|
|
26
|
-
|
|
19
|
+
let isProcesing = $state(false);
|
|
20
|
+
let resultMessage = $state('');
|
|
27
21
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
22
|
+
async function resetPassword() {
|
|
23
|
+
isProcesing = true;
|
|
24
|
+
submitError = false;
|
|
31
25
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
26
|
+
const response = await fetch('?/setup', {
|
|
27
|
+
method: 'POST',
|
|
28
|
+
body: ''
|
|
29
|
+
});
|
|
36
30
|
|
|
37
|
-
|
|
31
|
+
const result = deserialize(await response.text());
|
|
38
32
|
|
|
39
|
-
|
|
40
|
-
result.type === "success"
|
|
41
|
-
? m.auth_setup_success()
|
|
42
|
-
: m.auth_setup_failure();
|
|
33
|
+
resultMessage = result.type === 'success' ? m.auth_setup_success() : m.auth_setup_failure();
|
|
43
34
|
|
|
44
|
-
|
|
45
|
-
|
|
35
|
+
isProcesing = false;
|
|
36
|
+
}
|
|
46
37
|
</script>
|
|
47
38
|
|
|
48
39
|
<article class="w-full">
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
<p>{resultMessage}</p>
|
|
73
|
-
{/if}
|
|
40
|
+
<main class="flex flex-col justify-around items-center gap-4 w-full m-auto p-4">
|
|
41
|
+
<h1>{m.auth_setup_title()}</h1>
|
|
42
|
+
{#if !data.username}
|
|
43
|
+
<p>{m.auth_setup_missing_code()}</p>
|
|
44
|
+
{:else}
|
|
45
|
+
<div>
|
|
46
|
+
{@html m.auth_setup_into()}
|
|
47
|
+
</div>
|
|
48
|
+
<SmartForm
|
|
49
|
+
{fields}
|
|
50
|
+
errors={form?.errors}
|
|
51
|
+
action="?/setup"
|
|
52
|
+
buttons={[
|
|
53
|
+
{
|
|
54
|
+
type: 'submit',
|
|
55
|
+
label: m.auth_submit(),
|
|
56
|
+
color: 'primary'
|
|
57
|
+
}
|
|
58
|
+
]}
|
|
59
|
+
/>
|
|
60
|
+
{#if resultMessage != ''}
|
|
61
|
+
<p>{resultMessage}</p>
|
|
62
|
+
{/if}
|
|
74
63
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
64
|
+
{#if submitError}
|
|
65
|
+
<p class="text-red-600">{m.auth_setup_error()}</p>
|
|
66
|
+
{/if}
|
|
67
|
+
{/if}
|
|
68
|
+
</main>
|
|
80
69
|
</article>
|
|
81
70
|
|
|
82
71
|
<style>
|