From bfdbc38f78ed251efa076a24846bf3046a898133 Mon Sep 17 00:00:00 2001 From: Harsh Mahajan <127186841+HarshMN2345@users.noreply.github.com> Date: Fri, 26 Sep 2025 12:45:38 +0530 Subject: [PATCH] use page from app/state and removed div added notifs --- .../account/sendVerificationEmailModal.svelte | 25 +++++++++++++---- .../(console)/verify-email/+page.svelte | 27 +++++++------------ src/routes/(console)/verify-email/+page.ts | 9 ------- 3 files changed, 29 insertions(+), 32 deletions(-) delete mode 100644 src/routes/(console)/verify-email/+page.ts diff --git a/src/lib/components/account/sendVerificationEmailModal.svelte b/src/lib/components/account/sendVerificationEmailModal.svelte index b48be7540..e58c9ec85 100644 --- a/src/lib/components/account/sendVerificationEmailModal.svelte +++ b/src/lib/components/account/sendVerificationEmailModal.svelte @@ -5,15 +5,16 @@ import { sdk } from '$lib/stores/sdk'; import { user } from '$lib/stores/user'; import { get } from 'svelte/store'; - import { page } from '$app/stores'; + import { page } from '$app/state'; import Link from '$lib/elements/link.svelte'; import { Card, Layout, Typography } from '@appwrite.io/pink-svelte'; import { Dependencies } from '$lib/constants'; import { onMount, onDestroy } from 'svelte'; import { base } from '$app/paths'; import { browser } from '$app/environment'; + import { addNotification } from '$lib/stores/notifications'; - let { show = $bindable(false), email } = $props(); + let { show = $bindable(false), email }: { show?: boolean; email?: string } = $props(); let creating = $state(false); let emailSent = $state(false); let resendTimer = $state(0); @@ -27,11 +28,15 @@ goto(`${base}/login`); } } catch (error) { - console.error('Logout error:', error); + addNotification({ + type: 'error', + title: 'Logout failed', + message: 'Unable to log out. Please try again or refresh the page.' + }); } } - const cleanUrl = $derived($page.url.origin + $page.url.pathname); + const cleanUrl = $derived(page.url.origin + page.url.pathname); // Manage resend timer in localStorage const TIMER_END_KEY = 'email_verification_timer_end'; @@ -94,6 +99,11 @@ emailSent = true; startResendTimer(); } catch (error) { + addNotification({ + type: 'error', + title: 'Failed to send verification email', + message: 'Unable to send verification email. Please try again.' + }); console.error('Failed to send verification email:', error); } finally { creating = false; @@ -101,7 +111,7 @@ } async function updateEmailVerification() { - const searchParams = $page.url.searchParams; + const searchParams = page.url.searchParams; const userId = searchParams.get('userId'); const secret = searchParams.get('secret'); @@ -115,6 +125,11 @@ goto(`${base}/`); } catch (error) { + addNotification({ + type: 'error', + title: 'Email verification failed', + message: 'Unable to verify your email. Please try again.' + }); console.error('Failed to verify email:', error); } } diff --git a/src/routes/(console)/verify-email/+page.svelte b/src/routes/(console)/verify-email/+page.svelte index 729cbf908..462743262 100644 --- a/src/routes/(console)/verify-email/+page.svelte +++ b/src/routes/(console)/verify-email/+page.svelte @@ -8,9 +8,7 @@ import { onMount } from 'svelte'; import { base } from '$app/paths'; import { Dependencies } from '$lib/constants'; - import type { PageData } from './$types'; - - let { data }: { data: PageData } = $props(); + import { page } from '$app/state'; let sideBarIsOpen = writable(false); let showAccountMenu = writable(false); @@ -36,28 +34,28 @@ currentProject: project }; - let showVerificationModal = $state(!data.user?.emailVerification); + let showVerificationModal = $state(!page.data.account?.emailVerification); $effect(() => { - if (data.user?.emailVerification) { + if (page.data.account?.emailVerification) { checkEmailVerification(); } }); async function checkEmailVerification() { - if (data.user?.emailVerification) { + if (page.data.account?.emailVerification) { await goto(`${base}/`); } } onMount(() => { - if (!data.user) { + if (!page.data.account) { goto(`${base}/login`); return; } // If email is already verified, redirect immediately - if (data.user?.emailVerification) { + if (page.data.account?.emailVerification) { checkEmailVerification(); return; } @@ -89,12 +87,10 @@ {progressCard} state="open" /> -