svelte-firekit 0.0.10 → 0.0.12
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.
- package/dist/auth/reset-password.svelte +27 -15
- package/dist/auth/reset-password.svelte.d.ts +7 -17
- package/dist/auth/sign-in.svelte +51 -23
- package/dist/auth/sign-in.svelte.d.ts +11 -1
- package/dist/auth/sign-up.svelte +62 -23
- package/dist/auth/sign-up.svelte.d.ts +13 -0
- package/dist/components/app/nav/app-sidebar.svelte +35 -0
- package/dist/components/app/nav/app-sidebar.svelte.d.ts +8 -0
- package/dist/components/app/nav/breadcrumb.svelte +42 -0
- package/dist/components/app/nav/breadcrumb.svelte.d.ts +19 -0
- package/dist/components/auth/google-sign-in.svelte +55 -53
- package/dist/components/auth/reset-password-form.svelte +49 -47
- package/dist/components/auth/reset-password-form.svelte.d.ts +3 -17
- package/dist/components/auth/sign-in-form.svelte +21 -5
- package/dist/components/auth/sign-in-form.svelte.d.ts +7 -17
- package/dist/components/auth/sign-up-form.svelte +127 -110
- package/dist/components/auth/sign-up-form.svelte.d.ts +10 -17
- package/dist/components/auth/user-button/profile-section/avatar-user.svelte +107 -0
- package/dist/components/auth/user-button/profile-section/avatar-user.svelte.d.ts +2 -0
- package/dist/components/auth/user-button/profile-section/connect-user.svelte +45 -0
- package/dist/components/auth/user-button/profile-section/connect-user.svelte.d.ts +18 -0
- package/dist/components/auth/user-button/profile-section/email-user.svelte +81 -0
- package/dist/components/auth/user-button/profile-section/email-user.svelte.d.ts +2 -0
- package/dist/components/auth/user-button/profile-section/phone-user.svelte +122 -0
- package/dist/components/auth/user-button/profile-section/phone-user.svelte.d.ts +2 -0
- package/dist/components/auth/user-button/profile-section/profile-section.svelte +17 -0
- package/dist/components/auth/user-button/profile-section/profile-section.svelte.d.ts +18 -0
- package/dist/components/auth/user-button/settings-dialog.svelte +80 -87
- package/dist/components/auth/user-button/type-account.svelte +35 -0
- package/dist/components/auth/user-button/type-account.svelte.d.ts +4 -0
- package/dist/components/auth/user-button/user-button.svelte +122 -112
- package/dist/components/nav/nav-main.svelte +70 -0
- package/dist/components/nav/nav-main.svelte.d.ts +18 -0
- package/dist/components/ui/badge/badge.svelte +49 -0
- package/dist/components/ui/badge/badge.svelte.d.ts +59 -0
- package/dist/components/ui/badge/index.d.ts +2 -0
- package/dist/components/ui/badge/index.js +2 -0
- package/dist/components/ui/collapsible/index.d.ts +5 -0
- package/dist/components/ui/collapsible/index.js +7 -0
- package/dist/config.d.ts +2 -0
- package/dist/config.js +28 -0
- package/dist/firebase/auth/auth-guard.svelte.d.ts +0 -30
- package/dist/firebase/auth/auth-guard.svelte.js +119 -103
- package/dist/firebase/auth/auth-manager.svelte.d.ts +73 -0
- package/dist/firebase/auth/auth-manager.svelte.js +257 -0
- package/dist/firebase/auth/auth.js +2 -2
- package/dist/firebase/auth/user.svelte.d.ts +0 -53
- package/dist/firebase/auth/user.svelte.js +177 -134
- package/dist/firebase/firestore/document-mutations.svelte.d.ts +1 -1
- package/dist/firebase/firestore/document-mutations.svelte.js +18 -13
- package/dist/firebase/storage/upload-task.svelte.d.ts +1 -0
- package/dist/firebase/storage/upload-task.svelte.js +4 -2
- package/dist/index.d.ts +1 -3
- package/dist/index.js +3 -3
- package/dist/types/nav.d.ts +4 -0
- package/package.json +4 -2
|
@@ -6,6 +6,20 @@
|
|
|
6
6
|
import Button from "../ui/button/button.svelte";
|
|
7
7
|
import { valibot } from "sveltekit-superforms/adapters";
|
|
8
8
|
|
|
9
|
+
let {
|
|
10
|
+
labelEmail = "Email",
|
|
11
|
+
labelPassword = "Password",
|
|
12
|
+
labellLinkEmailForm = "I forgot my password",
|
|
13
|
+
linkForgetPassword = "/reset-password",
|
|
14
|
+
labelBtnFormEmail = "Sign",
|
|
15
|
+
}: {
|
|
16
|
+
labelEmail: string;
|
|
17
|
+
labelPassword: string;
|
|
18
|
+
labellLinkEmailForm: string;
|
|
19
|
+
linkForgetPassword: string;
|
|
20
|
+
labelBtnFormEmail: string;
|
|
21
|
+
} = $props();
|
|
22
|
+
|
|
9
23
|
const data = defaults(valibot(signInSchema));
|
|
10
24
|
|
|
11
25
|
import * as Form from "../ui/form/index.js";
|
|
@@ -35,13 +49,15 @@
|
|
|
35
49
|
});
|
|
36
50
|
|
|
37
51
|
const { form: formData, enhance } = form;
|
|
52
|
+
|
|
53
|
+
|
|
38
54
|
</script>
|
|
39
55
|
|
|
40
56
|
<form method="POST" use:enhance class="space-y-2">
|
|
41
57
|
<Form.Field {form} name="email">
|
|
42
58
|
<Form.Control>
|
|
43
59
|
{#snippet children({ props })}
|
|
44
|
-
<Form.Label>
|
|
60
|
+
<Form.Label>{labelEmail}</Form.Label>
|
|
45
61
|
<Input
|
|
46
62
|
{...props}
|
|
47
63
|
bind:value={$formData.email}
|
|
@@ -55,13 +71,13 @@
|
|
|
55
71
|
<Form.Control>
|
|
56
72
|
{#snippet children({ props })}
|
|
57
73
|
<div class="flex w-full items-center justify-between">
|
|
58
|
-
<Form.Label>
|
|
74
|
+
<Form.Label>{labelPassword}</Form.Label>
|
|
59
75
|
<Button
|
|
60
76
|
variant="link"
|
|
61
77
|
class="text-sm"
|
|
62
|
-
href=
|
|
78
|
+
href={linkForgetPassword}
|
|
63
79
|
>
|
|
64
|
-
|
|
80
|
+
{labellLinkEmailForm}
|
|
65
81
|
</Button>
|
|
66
82
|
</div>
|
|
67
83
|
<Input
|
|
@@ -74,5 +90,5 @@
|
|
|
74
90
|
</Form.Control>
|
|
75
91
|
<Form.FieldErrors />
|
|
76
92
|
</Form.Field>
|
|
77
|
-
<Form.Button class="w-full">
|
|
93
|
+
<Form.Button class="w-full">{labelBtnFormEmail}</Form.Button>
|
|
78
94
|
</form>
|
|
@@ -1,18 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}): Exports & {
|
|
9
|
-
$set?: any;
|
|
10
|
-
$on?: any;
|
|
11
|
-
};
|
|
12
|
-
z_$$bindings?: Bindings;
|
|
13
|
-
}
|
|
14
|
-
declare const SignInForm: $$__sveltets_2_IsomorphicComponent<Record<string, never>, {
|
|
15
|
-
[evt: string]: CustomEvent<any>;
|
|
16
|
-
}, {}, {}, string>;
|
|
17
|
-
type SignInForm = InstanceType<typeof SignInForm>;
|
|
1
|
+
declare const SignInForm: import("svelte").Component<{
|
|
2
|
+
labelEmail: string;
|
|
3
|
+
labelPassword: string;
|
|
4
|
+
labellLinkEmailForm: string;
|
|
5
|
+
linkForgetPassword: string;
|
|
6
|
+
labelBtnFormEmail: string;
|
|
7
|
+
}, {}, "">;
|
|
18
8
|
export default SignInForm;
|
|
@@ -1,119 +1,136 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
|
|
2
|
+
import { firekitAuth } from "../../firebase/auth/auth.js";
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const data = defaults(valibot(signUpSchema));
|
|
4
|
+
import * as Form from "../ui/form/index.js";
|
|
5
|
+
import { Input } from "../ui/input/index.js";
|
|
6
|
+
import { signUpSchema } from "../../schemas/sign-up.js";
|
|
7
|
+
import { toast } from "svelte-sonner";
|
|
8
|
+
import { superForm, defaults } from "sveltekit-superforms";
|
|
9
|
+
import { valibot } from "sveltekit-superforms/adapters";
|
|
10
|
+
import Button from "../ui/button/button.svelte";
|
|
11
|
+
import Checkbox from "../ui/checkbox/checkbox.svelte";
|
|
13
12
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
if (error instanceof Error) {
|
|
34
|
-
toast.error(error.message);
|
|
35
|
-
} else {
|
|
36
|
-
toast.error("An error occurred");
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
},
|
|
40
|
-
});
|
|
13
|
+
let {
|
|
14
|
+
labelFisrtName,
|
|
15
|
+
labelLastName,
|
|
16
|
+
labelEmail,
|
|
17
|
+
labelPassword,
|
|
18
|
+
linkTerms,
|
|
19
|
+
labelTerms,
|
|
20
|
+
labelLinkTerms,
|
|
21
|
+
labelBtnFormEmail,
|
|
22
|
+
}: {
|
|
23
|
+
labelFisrtName: string;
|
|
24
|
+
labelLastName: string;
|
|
25
|
+
labelEmail: string;
|
|
26
|
+
labelPassword: string;
|
|
27
|
+
linkTerms: string;
|
|
28
|
+
labelTerms: string;
|
|
29
|
+
labelLinkTerms: string;
|
|
30
|
+
labelBtnFormEmail: string;
|
|
31
|
+
} = $props();
|
|
41
32
|
|
|
42
|
-
|
|
33
|
+
const data = defaults(valibot(signUpSchema));
|
|
34
|
+
|
|
35
|
+
const form = superForm(data, {
|
|
36
|
+
validators: valibot(signUpSchema),
|
|
37
|
+
dataType: "json",
|
|
38
|
+
SPA: true,
|
|
39
|
+
resetForm: false,
|
|
40
|
+
clearOnSubmit: "errors-and-message",
|
|
41
|
+
async onUpdate({ form }) {
|
|
42
|
+
if (!form.valid) return;
|
|
43
|
+
try {
|
|
44
|
+
const { data } = form;
|
|
45
|
+
const { email, password, firstName, lastName } = data;
|
|
46
|
+
const displayName = `${firstName} ${lastName}`;
|
|
47
|
+
await firekitAuth.registerWithEmail(email, password, displayName);
|
|
48
|
+
toast.success("Account created successfully");
|
|
49
|
+
} catch (error) {
|
|
50
|
+
if (error instanceof Error) {
|
|
51
|
+
toast.error(error.message);
|
|
52
|
+
} else {
|
|
53
|
+
toast.error("An error occurred");
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
const { form: formData, enhance } = form;
|
|
60
|
+
|
|
61
|
+
|
|
43
62
|
</script>
|
|
44
63
|
|
|
45
64
|
<form method="POST" use:enhance class="space-y-2">
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
65
|
+
<div class="grid grid-cols-2 gap-4">
|
|
66
|
+
<Form.Field {form} name="firstName">
|
|
67
|
+
<Form.Control>
|
|
68
|
+
{#snippet children({ props })}
|
|
69
|
+
<Form.Label>{labelFisrtName}</Form.Label>
|
|
70
|
+
<Input
|
|
71
|
+
{...props}
|
|
72
|
+
bind:value={$formData.firstName}
|
|
73
|
+
placeholder="John"
|
|
74
|
+
/>
|
|
75
|
+
{/snippet}
|
|
76
|
+
</Form.Control>
|
|
77
|
+
<Form.FieldErrors />
|
|
78
|
+
</Form.Field>
|
|
79
|
+
<Form.Field {form} name="lastName">
|
|
80
|
+
<Form.Control>
|
|
81
|
+
{#snippet children({ props })}
|
|
82
|
+
<Form.Label>{labelLastName}</Form.Label>
|
|
83
|
+
<Input
|
|
84
|
+
{...props}
|
|
85
|
+
bind:value={$formData.lastName}
|
|
86
|
+
placeholder="Smith"
|
|
87
|
+
/>
|
|
88
|
+
{/snippet}
|
|
89
|
+
</Form.Control>
|
|
90
|
+
<Form.FieldErrors />
|
|
91
|
+
</Form.Field>
|
|
92
|
+
</div>
|
|
93
|
+
<Form.Field {form} name="email">
|
|
94
|
+
<Form.Control>
|
|
95
|
+
{#snippet children({ props })}
|
|
96
|
+
<Form.Label>{labelEmail}</Form.Label>
|
|
97
|
+
<Input
|
|
98
|
+
{...props}
|
|
99
|
+
bind:value={$formData.email}
|
|
100
|
+
placeholder="you@email.com"
|
|
101
|
+
/>
|
|
102
|
+
{/snippet}
|
|
103
|
+
</Form.Control>
|
|
104
|
+
<Form.FieldErrors />
|
|
105
|
+
</Form.Field>
|
|
106
|
+
<Form.Field {form} name="password">
|
|
107
|
+
<Form.Control>
|
|
108
|
+
{#snippet children({ props })}
|
|
109
|
+
<Form.Label>{labelPassword}</Form.Label>
|
|
110
|
+
<Input
|
|
111
|
+
{...props}
|
|
112
|
+
bind:value={$formData.password}
|
|
113
|
+
placeholder="*********"
|
|
114
|
+
type="password"
|
|
115
|
+
/>
|
|
116
|
+
{/snippet}
|
|
117
|
+
</Form.Control>
|
|
118
|
+
<Form.FieldErrors />
|
|
119
|
+
</Form.Field>
|
|
120
|
+
<Form.Field {form} name="agreeToTerms">
|
|
121
|
+
<Form.Control>
|
|
122
|
+
{#snippet children({ props })}
|
|
123
|
+
<Checkbox {...props} bind:checked={$formData.agreeToTerms} />
|
|
105
124
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
</Form.Field>
|
|
118
|
-
<Form.Button class="w-full">Sign Up</Form.Button>
|
|
125
|
+
<Form.Label>
|
|
126
|
+
{labelTerms}
|
|
127
|
+
<Button variant="link" href={linkTerms} class="p-0"
|
|
128
|
+
>{labelLinkTerms}</Button
|
|
129
|
+
>
|
|
130
|
+
</Form.Label>
|
|
131
|
+
{/snippet}
|
|
132
|
+
</Form.Control>
|
|
133
|
+
<Form.FieldErrors />
|
|
134
|
+
</Form.Field>
|
|
135
|
+
<Form.Button class="w-full">{labelBtnFormEmail}</Form.Button>
|
|
119
136
|
</form>
|
|
@@ -1,18 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
};
|
|
12
|
-
z_$$bindings?: Bindings;
|
|
13
|
-
}
|
|
14
|
-
declare const SignUpForm: $$__sveltets_2_IsomorphicComponent<Record<string, never>, {
|
|
15
|
-
[evt: string]: CustomEvent<any>;
|
|
16
|
-
}, {}, {}, string>;
|
|
17
|
-
type SignUpForm = InstanceType<typeof SignUpForm>;
|
|
1
|
+
declare const SignUpForm: import("svelte").Component<{
|
|
2
|
+
labelFisrtName: string;
|
|
3
|
+
labelLastName: string;
|
|
4
|
+
labelEmail: string;
|
|
5
|
+
labelPassword: string;
|
|
6
|
+
linkTerms: string;
|
|
7
|
+
labelTerms: string;
|
|
8
|
+
labelLinkTerms: string;
|
|
9
|
+
labelBtnFormEmail: string;
|
|
10
|
+
}, {}, "">;
|
|
18
11
|
export default SignUpForm;
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import * as Avatar from "../../../ui/avatar/index.js";
|
|
3
|
+
import { firekitAuthManager } from "../../../../firebase/auth/auth-manager.svelte.js";
|
|
4
|
+
|
|
5
|
+
import { firekitUploadTask } from "../../../../firebase/storage/upload-task.svelte.js";
|
|
6
|
+
import { getInitials } from "../../../../utils.js";
|
|
7
|
+
|
|
8
|
+
$effect(() => {
|
|
9
|
+
console.log(progress);
|
|
10
|
+
if (progress === 100 && uploadTask?.downloadURL) {
|
|
11
|
+
console.log("updated data");
|
|
12
|
+
firekitAuthManager.updateUserData({ photoURL: uploadTask?.downloadURL });
|
|
13
|
+
firekitAuthManager.updateProfileInfo({
|
|
14
|
+
displayName: firekitAuthManager.data?.displayName as string,
|
|
15
|
+
photoURL: uploadTask?.downloadURL,
|
|
16
|
+
});
|
|
17
|
+
progress = 0;
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
// $effect(()=>{
|
|
22
|
+
// console.log(uploadTask?.downloadURL)
|
|
23
|
+
// })
|
|
24
|
+
|
|
25
|
+
let uploadTask: any = $state(null);
|
|
26
|
+
let progress: number = $derived(uploadTask?.progress || 0 * 1);
|
|
27
|
+
let imageUrl: string = $state("");
|
|
28
|
+
let selectedImage: File | null = $state(null);
|
|
29
|
+
let inputfile: any;
|
|
30
|
+
|
|
31
|
+
async function handleImageUpload(event: Event) {
|
|
32
|
+
const target = event.target as HTMLInputElement;
|
|
33
|
+
const file: File = target.files?.[0] as File;
|
|
34
|
+
|
|
35
|
+
if (file) {
|
|
36
|
+
imageUrl = URL.createObjectURL(file);
|
|
37
|
+
selectedImage = file;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
uploadTask = firekitUploadTask(
|
|
41
|
+
`users-profile/${firekitAuthManager.uid}/profile`,
|
|
42
|
+
file
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
// firekitAuthManager.updateUserData({ photoURL: uploadTask?.downloadURL });
|
|
47
|
+
// firekitAuthManager.updateProfileInfo({
|
|
48
|
+
// displayName: firekitAuthManager.data?.displayName as string,
|
|
49
|
+
// photoURL: uploadTask?.downloadURL,
|
|
50
|
+
// });
|
|
51
|
+
}
|
|
52
|
+
</script>
|
|
53
|
+
|
|
54
|
+
<section class="space-y-5 border-t-slate-200 border-t-[2px] pt-4">
|
|
55
|
+
<div class="grid sm:grid-cols-12 gap-y-1.5 sm:gap-y-0 sm:gap-x-5">
|
|
56
|
+
<div class="sm:col-span-4 xl:col-span-3">
|
|
57
|
+
<p class="sm:mt-2.5 inline-block text-sm text-foreground-500">Profile</p>
|
|
58
|
+
</div>
|
|
59
|
+
|
|
60
|
+
<div class="sm:col-span-8 xl:col-span-9">
|
|
61
|
+
<div class="flex flex-wrap justify-around items-center gap-3 sm:gap-5">
|
|
62
|
+
<div class="flex gap-2 items-center">
|
|
63
|
+
<button onclick={() => inputfile.click()}>
|
|
64
|
+
<Avatar.Root class="size-[70px]">
|
|
65
|
+
<Avatar.Image
|
|
66
|
+
src={firekitAuthManager.data?.photoURL}
|
|
67
|
+
alt="Avatar"
|
|
68
|
+
/>
|
|
69
|
+
<Avatar.Fallback>
|
|
70
|
+
{getInitials(firekitAuthManager.data?.displayName)}
|
|
71
|
+
</Avatar.Fallback>
|
|
72
|
+
</Avatar.Root>
|
|
73
|
+
</button>
|
|
74
|
+
<input
|
|
75
|
+
bind:this={inputfile}
|
|
76
|
+
onchange={handleImageUpload}
|
|
77
|
+
type="file"
|
|
78
|
+
accept="image/*"
|
|
79
|
+
class="hidden"
|
|
80
|
+
/>
|
|
81
|
+
<div class="grid flex-1 text-left text-sm leading-tight">
|
|
82
|
+
<span class="truncate font-semibold"
|
|
83
|
+
>{firekitAuthManager.data?.displayName}</span
|
|
84
|
+
>
|
|
85
|
+
<span class="truncate text-sm text-slate-400"
|
|
86
|
+
>{firekitAuthManager.data?.email}</span
|
|
87
|
+
>
|
|
88
|
+
{#if progress > 0 && !uploadTask?.completed}
|
|
89
|
+
<div
|
|
90
|
+
class="w-full bg-gray-200 rounded-full h-2.5 dark:bg-gray-700"
|
|
91
|
+
>
|
|
92
|
+
<div
|
|
93
|
+
class="bg-blue-600 h-2.5 rounded-full"
|
|
94
|
+
style="width: {progress}%"
|
|
95
|
+
></div>
|
|
96
|
+
</div>
|
|
97
|
+
<p class="text-xs text-gray-500 mt-1">
|
|
98
|
+
Progress: {progress.toFixed(2)}%
|
|
99
|
+
</p>
|
|
100
|
+
{/if}
|
|
101
|
+
</div>
|
|
102
|
+
</div>
|
|
103
|
+
<div></div>
|
|
104
|
+
</div>
|
|
105
|
+
</div>
|
|
106
|
+
</div>
|
|
107
|
+
</section>
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import Button from "../../../ui/button/button.svelte";
|
|
3
|
+
import { firekitAuthManager } from "../../../../firebase/auth/auth-manager.svelte.js";
|
|
4
|
+
|
|
5
|
+
import { Badge } from "../../../ui/badge/index.js";
|
|
6
|
+
import { Plus } from "lucide-svelte";
|
|
7
|
+
import TypeAccount from "../type-account.svelte";
|
|
8
|
+
</script>
|
|
9
|
+
|
|
10
|
+
<section class="space-y-5 border-t-slate-200 border-t-[2px] pt-4">
|
|
11
|
+
<div class="grid sm:grid-cols-12 gap-y-1.5 sm:gap-y-0 sm:gap-x-5">
|
|
12
|
+
<div class="sm:col-span-4 xl:col-span-3 ">
|
|
13
|
+
<p class="sm:mt-2.5 inline-block text-sm text-foreground-500">
|
|
14
|
+
Connected accounts
|
|
15
|
+
</p>
|
|
16
|
+
</div>
|
|
17
|
+
|
|
18
|
+
<div class="sm:col-span-8 xl:col-span-9">
|
|
19
|
+
<div class="flex flex-wrap justify-around items-center gap-3 sm:gap-5">
|
|
20
|
+
<div class="flex flex-col gap-2 text-sm leading-tight items-start">
|
|
21
|
+
<div class="flex gap-2 items-center">
|
|
22
|
+
<TypeAccount
|
|
23
|
+
account={firekitAuthManager?.user?.providerData[0]?.providerId || "None"}
|
|
24
|
+
></TypeAccount>
|
|
25
|
+
|
|
26
|
+
<span class="truncate text-xs text-slate-600"
|
|
27
|
+
>{firekitAuthManager.email}</span
|
|
28
|
+
>
|
|
29
|
+
|
|
30
|
+
<Badge variant="outline">Primary</Badge>
|
|
31
|
+
</div>
|
|
32
|
+
<Button
|
|
33
|
+
variant="none"
|
|
34
|
+
class="flex justify-start px-0 hover:border-b-slate-500 hover:border-b-[2px] rounded-none"
|
|
35
|
+
>
|
|
36
|
+
<Plus class="size-4"></Plus>
|
|
37
|
+
Connect account
|
|
38
|
+
</Button>
|
|
39
|
+
</div>
|
|
40
|
+
<!-- <Button variant="ghost" size="sm">Edit Profile</Button> -->
|
|
41
|
+
<div></div>
|
|
42
|
+
</div>
|
|
43
|
+
</div>
|
|
44
|
+
</div>
|
|
45
|
+
</section>
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
|
|
2
|
+
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
3
|
+
$$bindings?: Bindings;
|
|
4
|
+
} & Exports;
|
|
5
|
+
(internal: unknown, props: {
|
|
6
|
+
$$events?: Events;
|
|
7
|
+
$$slots?: Slots;
|
|
8
|
+
}): Exports & {
|
|
9
|
+
$set?: any;
|
|
10
|
+
$on?: any;
|
|
11
|
+
};
|
|
12
|
+
z_$$bindings?: Bindings;
|
|
13
|
+
}
|
|
14
|
+
declare const ConnectUser: $$__sveltets_2_IsomorphicComponent<Record<string, never>, {
|
|
15
|
+
[evt: string]: CustomEvent<any>;
|
|
16
|
+
}, {}, {}, string>;
|
|
17
|
+
type ConnectUser = InstanceType<typeof ConnectUser>;
|
|
18
|
+
export default ConnectUser;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import Button from "../../../ui/button/button.svelte";
|
|
3
|
+
import { firekitAuthManager } from "../../../../firebase/auth/auth-manager.svelte.js";
|
|
4
|
+
|
|
5
|
+
import Input from "../../../ui/input/input.svelte";
|
|
6
|
+
import { toast } from "svelte-sonner";
|
|
7
|
+
|
|
8
|
+
let email: string = $state("");
|
|
9
|
+
let haserror = $state(false);
|
|
10
|
+
|
|
11
|
+
$effect(() => {
|
|
12
|
+
email = firekitAuthManager.data?.email as string;
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
async function handleChangeEmail() {
|
|
16
|
+
console.log(email);
|
|
17
|
+
haserror = false;
|
|
18
|
+
console.log(firekitAuthManager.data?.email);
|
|
19
|
+
if (email === firekitAuthManager.data?.email) {
|
|
20
|
+
toast.error("The email is the same as your current email.");
|
|
21
|
+
haserror = true;
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
if (!isValidEmail()) {
|
|
26
|
+
toast.error("Please enter a valid email address.");
|
|
27
|
+
haserror = true;
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
await firekitAuthManager.updateEmailUser(email);
|
|
32
|
+
// toast.success("Email updated successfully!");
|
|
33
|
+
// setTimeout(async () => {
|
|
34
|
+
// await firekitAuth.logOut();
|
|
35
|
+
// }, 4500);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function isValidEmail() {
|
|
39
|
+
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
40
|
+
return emailRegex.test(email);
|
|
41
|
+
}
|
|
42
|
+
</script>
|
|
43
|
+
|
|
44
|
+
<section class="space-y-5 border-t-slate-200 border-t-[2px] pt-4">
|
|
45
|
+
<div class="grid sm:grid-cols-12 gap-y-1.5 sm:gap-y-0 sm:gap-x-5">
|
|
46
|
+
<div class="sm:col-span-4 xl:col-span-3">
|
|
47
|
+
<p
|
|
48
|
+
class="sm:mt-2.5 inline-block text-sm {haserror
|
|
49
|
+
? 'text-red-500'
|
|
50
|
+
: 'text-foreground-500'}"
|
|
51
|
+
>
|
|
52
|
+
Email address
|
|
53
|
+
</p>
|
|
54
|
+
</div>
|
|
55
|
+
|
|
56
|
+
<div class="sm:col-span-8 xl:col-span-9">
|
|
57
|
+
<div class="flex flex-wrap items-center gap-3 sm:gap-5 ">
|
|
58
|
+
<div class="flex gap-2 items-center w-full ">
|
|
59
|
+
<div class="flex flex-col gap-2 text-sm leading-tight w-[250px]">
|
|
60
|
+
<div class=" space-y-1 my-2 w-auto ">
|
|
61
|
+
<!-- <Label class={haserror ? "text-red-500" : ""}>Email:</Label> -->
|
|
62
|
+
<Input
|
|
63
|
+
class=" w-full {haserror ? 'border border-red-500' : ''}"
|
|
64
|
+
bind:value={email}
|
|
65
|
+
placeholder="Introduce email"
|
|
66
|
+
/>
|
|
67
|
+
</div>
|
|
68
|
+
<Button
|
|
69
|
+
onclick={handleChangeEmail}
|
|
70
|
+
variant="default"
|
|
71
|
+
class="bg-blue-500 hover:bg-blue-600 text-white block ml-auto"
|
|
72
|
+
>
|
|
73
|
+
Save
|
|
74
|
+
</Button>
|
|
75
|
+
</div>
|
|
76
|
+
</div>
|
|
77
|
+
<div></div>
|
|
78
|
+
</div>
|
|
79
|
+
</div>
|
|
80
|
+
</div>
|
|
81
|
+
</section>
|