From 576777c4734229b126057131b70fdcf755df8e90 Mon Sep 17 00:00:00 2001 From: TheAbubakrAbu Date: Mon, 26 Oct 2026 17:12:51 -0700 Subject: [PATCH 1/4] =?UTF-8?q?feat(auth):=20=E2=9C=A8=20add=20in-app=20ac?= =?UTF-8?q?count=20deletion?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/next/src/app/delete-account/page.tsx | 139 ++++++++++++++++++ .../components/ui/sidebar/sidebar-content.tsx | 18 ++- apps/next/src/lib/auth-constants.ts | 3 + apps/next/src/lib/auth.ts | 9 +- 4 files changed, 167 insertions(+), 2 deletions(-) create mode 100644 apps/next/src/app/delete-account/page.tsx diff --git a/apps/next/src/app/delete-account/page.tsx b/apps/next/src/app/delete-account/page.tsx new file mode 100644 index 00000000..3b8a85a5 --- /dev/null +++ b/apps/next/src/app/delete-account/page.tsx @@ -0,0 +1,139 @@ +"use client"; + +import Link from "next/link"; +import { useRouter, useSearchParams } from "next/navigation"; +import posthog from "posthog-js"; +import { type ReactNode, Suspense, useEffect, useState } from "react"; +import { Button } from "@/components/ui/shadcn/button"; +import { useSnackbarStore } from "@/context/useSnackbar"; +import { getSignInUrl } from "@/lib/auth-actions"; +import { SESSION_FRESH_AGE } from "@/lib/auth-constants"; +import { Provider } from "@/lib/auth-types"; +import { authClient, signOut, useSession } from "@/utils/auth-client"; + +export default function DeleteAccountPage() { + return ( + + + + ); +} + +function DeleteAccount() { + const router = useRouter(); + const searchParams = useSearchParams(); + const { data: session, isPending } = useSession(); + const { showSnackbar } = useSnackbarStore(); + const [isWorking, setIsWorking] = useState(false); + const [isDeleted, setIsDeleted] = useState(false); + const [error, setError] = useState(null); + + useEffect(() => { + if (isPending || isWorking) return; + + if (!session) { + showSnackbar("Login to delete your account!", "error"); + router.push("/"); + } + }, [session, isPending, isWorking, router, showSnackbar]); + + const handleSignInAgain = async () => { + setError(null); + setIsWorking(true); + try { + const { data: accounts } = await authClient.listAccounts(); + const provider = accounts?.[0]?.accountId.startsWith("apple_") + ? Provider.Apple + : Provider.Google; + window.location.href = await getSignInUrl(provider, { + returnUrl: "/delete-account?step=confirm", + // Skips auth.icssc.club's saved session so the user really signs in. + authorizationUrlParams: { prompt: "consent" }, + }); + } catch (signInError) { + console.error("Error signing in again", signInError); + posthog.captureException(signInError); + setError("Couldn't start sign-in. Please try again."); + setIsWorking(false); + } + }; + + const handleDelete = async () => { + setError(null); + setIsWorking(true); + const { error: deleteError } = await authClient.deleteUser(); + if (deleteError) { + console.error("Error deleting account", deleteError); + setError("Couldn't delete your account. Please try again."); + setIsWorking(false); + return; + } + + setIsDeleted(true); + window.alert("Your account has been deleted."); + await signOut(); + }; + + if (isPending || (!session && !isDeleted)) return null; + + // Only offer deletion right after signing in again from this page. + const isConfirmStep = + searchParams.get("step") === "confirm" && + !!session && + Date.now() - new Date(session.session.createdAt).getTime() < + SESSION_FRESH_AGE * 1000; + + let content: ReactNode; + if (isDeleted) { + content =

Your account has been deleted.

; + } else if (!isConfirmStep) { + content = ( + <> +

To delete your account, sign in again to confirm it's you.

+ + + + ); + } else { + content = ( + <> +

+ This permanently deletes the PeterPlate account for{" "} + {session?.user.email}, + including your ratings, favorites, logged meals, and preferences. This + can't be undone. +

+ + + + ); + } + + return ( +
+
+

+ Delete Account +

+ {content} + {error && ( +

+ {error} +

+ )} +
+
+ ); +} diff --git a/apps/next/src/components/ui/sidebar/sidebar-content.tsx b/apps/next/src/components/ui/sidebar/sidebar-content.tsx index b990f771..4f1e2b4d 100644 --- a/apps/next/src/components/ui/sidebar/sidebar-content.tsx +++ b/apps/next/src/components/ui/sidebar/sidebar-content.tsx @@ -3,6 +3,7 @@ import { Close as CloseIcon, DarkMode as DarkModeIcon, + DeleteOutline as DeleteIcon, DesktopWindows as DesktopWindowsIcon, Edit as EditIcon, ContentPaste as FeedbackIcon, @@ -232,6 +233,19 @@ export default function SidebarContent({ > About PeterPlate + + {user && ( + + } + color="error.main" + > + Delete Account + + )} @@ -289,11 +303,13 @@ function MenuLink({ href, onClick, icon, + color = "text.primary", children, }: { href: string; onClick: () => void; icon: ReactNode; + color?: string; children: ReactNode; }) { return ( @@ -304,7 +320,7 @@ function MenuLink({ dark:hover:bg-gray-700`} > {icon} - + {children} diff --git a/apps/next/src/lib/auth-constants.ts b/apps/next/src/lib/auth-constants.ts index 346df8bb..9eba1daa 100644 --- a/apps/next/src/lib/auth-constants.ts +++ b/apps/next/src/lib/auth-constants.ts @@ -1 +1,4 @@ export const AUTH_PROVIDER_ID = "icssc"; + +/** Seconds since sign-in during which a session can delete its account. */ +export const SESSION_FRESH_AGE = 5 * 60; diff --git a/apps/next/src/lib/auth.ts b/apps/next/src/lib/auth.ts index 825f7c09..469f75de 100644 --- a/apps/next/src/lib/auth.ts +++ b/apps/next/src/lib/auth.ts @@ -7,7 +7,7 @@ import { betterAuth } from "better-auth/minimal"; import { nextCookies } from "better-auth/next-js"; import { genericOAuth } from "better-auth/plugins"; -import { AUTH_PROVIDER_ID } from "@/lib/auth-constants"; +import { AUTH_PROVIDER_ID, SESSION_FRESH_AGE } from "@/lib/auth-constants"; import type { AuthAdditionalData } from "@/lib/auth-types"; import { getSafeAuthRedirectPath } from "@/lib/auth-utils"; @@ -41,8 +41,15 @@ export const auth = betterAuth({ enabled: true, maxAge: 5 * 60, }, + // Account deletion requires a sign-in this recent. + freshAge: SESSION_FRESH_AGE, }, user: { + deleteUser: { + enabled: true, + // TODO: When auth.icssc.club adds account deletion, call it from a + // beforeDelete hook to revoke Sign in with Apple tokens and end ICSSC sessions. + }, additionalFields: { hasOnboarded: { type: "boolean", From a0653f4e92cd81b3b7761b6d308864fff2cef97a Mon Sep 17 00:00:00 2001 From: TheAbubakrAbu Date: Mon, 26 Oct 2026 19:57:51 -0700 Subject: [PATCH 2/4] =?UTF-8?q?fix(ui):=20=F0=9F=90=9B=20keep=20header=20v?= =?UTF-8?q?isible=20on=20dining=20halls=20and=20add=20tracker=20spinner?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/next/src/app/about/page.tsx | 1 + apps/next/src/app/nutrition/page.tsx | 15 ++++- .../next/src/components/ui/card/food-card.tsx | 23 +++---- .../ui/restaurant/restaurant-controls.tsx | 2 +- .../ui/restaurant/restaurant-page.tsx | 2 +- apps/next/src/components/ui/toolbar.tsx | 67 ++++++++++++++----- apps/next/src/hooks/useHeroFade.ts | 27 ++++++++ apps/next/src/utils/funcs.ts | 11 +-- 8 files changed, 112 insertions(+), 36 deletions(-) create mode 100644 apps/next/src/hooks/useHeroFade.ts diff --git a/apps/next/src/app/about/page.tsx b/apps/next/src/app/about/page.tsx index d1eaecde..69fb7aa9 100644 --- a/apps/next/src/app/about/page.tsx +++ b/apps/next/src/app/about/page.tsx @@ -17,6 +17,7 @@ export default function About() { return (
An Image of UCI's signage.Loading meals...
; + if (isLoading) + return ( +
+ +
+ ); if (error) return
Error loading meals
; return ( diff --git a/apps/next/src/components/ui/card/food-card.tsx b/apps/next/src/components/ui/card/food-card.tsx index d57bc852..0082d8bc 100644 --- a/apps/next/src/components/ui/card/food-card.tsx +++ b/apps/next/src/components/ui/card/food-card.tsx @@ -212,20 +212,19 @@ const FoodCardContent = React.forwardRef( : "No description available."}
- {/* Nudges the heart up so it looks visually centered */} -
- -
+
+ +
diff --git a/apps/next/src/components/ui/restaurant/restaurant-controls.tsx b/apps/next/src/components/ui/restaurant/restaurant-controls.tsx index 4250ce2d..c94e6e7f 100644 --- a/apps/next/src/components/ui/restaurant/restaurant-controls.tsx +++ b/apps/next/src/components/ui/restaurant/restaurant-controls.tsx @@ -45,7 +45,7 @@ export function RestaurantControls({ // Sticky while scrolling
{/* Desktop title & status. Its large grow factor soaks up spare space diff --git a/apps/next/src/components/ui/restaurant/restaurant-page.tsx b/apps/next/src/components/ui/restaurant/restaurant-page.tsx index 1fb0ca4a..1ac7f140 100644 --- a/apps/next/src/components/ui/restaurant/restaurant-page.tsx +++ b/apps/next/src/components/ui/restaurant/restaurant-page.tsx @@ -55,7 +55,7 @@ export function RestaurantPage({ return ( {/* Hero image & mobile header */} -
+
{hero.alt}(null); @@ -225,17 +230,33 @@ export function DesktopToolbar(): React.JSX.Element { return ( <> + {/* Fades from the gradient to solid as the hero scrolls under it */} + {isTransparentPage && ( + <> +
+
+ + )}
@@ -254,6 +275,7 @@ export function DesktopToolbar(): React.JSX.Element { isTransparent && resolvedTheme === "light" ? "white" : "primary.main", + transition: "color 300ms", }} > PeterPlate @@ -467,7 +489,13 @@ export function DesktopToolbar(): React.JSX.Element { function MobileToolbar(): React.JSX.Element { const pathname = usePathname(); - const isTransparent = TRANSPARENT_PAGES.includes(pathname); + const isTransparentPage = TRANSPARENT_PAGES.includes(pathname); + const isScrolled = useScrollTrigger({ + disableHysteresis: true, + threshold: 0, + }); + const heroFade = useHeroFade(isTransparentPage); + const isTransparent = isTransparentPage && heroFade < 0.5; const [profileAnchor, setProfileAnchor] = useState(null); const profileOpen = Boolean(profileAnchor); const [welcomeOpen, setWelcomeOpen] = useState(false); @@ -534,17 +562,24 @@ function MobileToolbar(): React.JSX.Element { {/* Sticky top header bar */}
+ {/* Fades to solid as the hero scrolls under it */} + {isTransparentPage && ( +
+ )} + {/* Hidden until the bar is solid, so the hall name on the hero image + never shows through behind it */} {greeting} @@ -598,11 +633,11 @@ function MobileToolbar(): React.JSX.Element { > diff --git a/apps/next/src/hooks/useHeroFade.ts b/apps/next/src/hooks/useHeroFade.ts new file mode 100644 index 00000000..e0fc443e --- /dev/null +++ b/apps/next/src/hooks/useHeroFade.ts @@ -0,0 +1,27 @@ +"use client"; + +import { useEffect, useState } from "react"; + +/** + * Returns how solid the 64px toolbar should be, from 0 to 1, as the page's + * `#hero` image scrolls under it. It fades in over the image's last 64px. + */ +export function useHeroFade(enabled: boolean): number { + const [fade, setFade] = useState(0); + + useEffect(() => { + if (!enabled) return; + + const update = () => { + const heroBottom = + document.getElementById("hero")?.getBoundingClientRect().bottom ?? 0; + setFade(Math.min(Math.max((128 - heroBottom) / 64, 0), 1)); + }; + + update(); + window.addEventListener("scroll", update, { passive: true }); + return () => window.removeEventListener("scroll", update); + }, [enabled]); + + return fade; +} diff --git a/apps/next/src/utils/funcs.ts b/apps/next/src/utils/funcs.ts index 0f9dc056..4c819708 100644 --- a/apps/next/src/utils/funcs.ts +++ b/apps/next/src/utils/funcs.ts @@ -537,18 +537,21 @@ export function getEventType(title: string): string { } /** - * Scrolls to a station section while leaving room for the sticky restaurant controls. + * Scrolls to a station section while leaving room for the toolbar and sticky + * restaurant controls. */ export function scrollToStation(stationId: string) { const section = document.getElementById(stationId); if (!section) return; - const controlsHeight = - document.getElementById("restaurant-controls")?.offsetHeight ?? 0; + const controls = document.getElementById("restaurant-controls"); + const controlsBottom = controls + ? Number.parseFloat(getComputedStyle(controls).top) + controls.offsetHeight + : 0; window.scrollTo({ top: section.getBoundingClientRect().top + window.scrollY - - controlsHeight - + controlsBottom - 16, behavior: "smooth", }); From eebc9efa40ea07f5eb417a45b6b84eba12e7449f Mon Sep 17 00:00:00 2001 From: TheAbubakrAbu Date: Sat, 7 Nov 2026 19:34:24 -0800 Subject: [PATCH 3/4] =?UTF-8?q?feat(auth):=20=E2=9C=A8=20move=20account=20?= =?UTF-8?q?deletion=20from=20a=20page=20into=20a=20dialog/drawer?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/next/src/app/delete-account/page.tsx | 139 --------------- .../components/ui/delete-account-content.tsx | 167 ++++++++++++++++++ .../components/ui/sidebar/sidebar-content.tsx | 28 +-- apps/next/src/components/ui/toolbar.tsx | 60 +++++++ 4 files changed, 243 insertions(+), 151 deletions(-) delete mode 100644 apps/next/src/app/delete-account/page.tsx create mode 100644 apps/next/src/components/ui/delete-account-content.tsx diff --git a/apps/next/src/app/delete-account/page.tsx b/apps/next/src/app/delete-account/page.tsx deleted file mode 100644 index 3b8a85a5..00000000 --- a/apps/next/src/app/delete-account/page.tsx +++ /dev/null @@ -1,139 +0,0 @@ -"use client"; - -import Link from "next/link"; -import { useRouter, useSearchParams } from "next/navigation"; -import posthog from "posthog-js"; -import { type ReactNode, Suspense, useEffect, useState } from "react"; -import { Button } from "@/components/ui/shadcn/button"; -import { useSnackbarStore } from "@/context/useSnackbar"; -import { getSignInUrl } from "@/lib/auth-actions"; -import { SESSION_FRESH_AGE } from "@/lib/auth-constants"; -import { Provider } from "@/lib/auth-types"; -import { authClient, signOut, useSession } from "@/utils/auth-client"; - -export default function DeleteAccountPage() { - return ( - - - - ); -} - -function DeleteAccount() { - const router = useRouter(); - const searchParams = useSearchParams(); - const { data: session, isPending } = useSession(); - const { showSnackbar } = useSnackbarStore(); - const [isWorking, setIsWorking] = useState(false); - const [isDeleted, setIsDeleted] = useState(false); - const [error, setError] = useState(null); - - useEffect(() => { - if (isPending || isWorking) return; - - if (!session) { - showSnackbar("Login to delete your account!", "error"); - router.push("/"); - } - }, [session, isPending, isWorking, router, showSnackbar]); - - const handleSignInAgain = async () => { - setError(null); - setIsWorking(true); - try { - const { data: accounts } = await authClient.listAccounts(); - const provider = accounts?.[0]?.accountId.startsWith("apple_") - ? Provider.Apple - : Provider.Google; - window.location.href = await getSignInUrl(provider, { - returnUrl: "/delete-account?step=confirm", - // Skips auth.icssc.club's saved session so the user really signs in. - authorizationUrlParams: { prompt: "consent" }, - }); - } catch (signInError) { - console.error("Error signing in again", signInError); - posthog.captureException(signInError); - setError("Couldn't start sign-in. Please try again."); - setIsWorking(false); - } - }; - - const handleDelete = async () => { - setError(null); - setIsWorking(true); - const { error: deleteError } = await authClient.deleteUser(); - if (deleteError) { - console.error("Error deleting account", deleteError); - setError("Couldn't delete your account. Please try again."); - setIsWorking(false); - return; - } - - setIsDeleted(true); - window.alert("Your account has been deleted."); - await signOut(); - }; - - if (isPending || (!session && !isDeleted)) return null; - - // Only offer deletion right after signing in again from this page. - const isConfirmStep = - searchParams.get("step") === "confirm" && - !!session && - Date.now() - new Date(session.session.createdAt).getTime() < - SESSION_FRESH_AGE * 1000; - - let content: ReactNode; - if (isDeleted) { - content =

Your account has been deleted.

; - } else if (!isConfirmStep) { - content = ( - <> -

To delete your account, sign in again to confirm it's you.

- - - - ); - } else { - content = ( - <> -

- This permanently deletes the PeterPlate account for{" "} - {session?.user.email}, - including your ratings, favorites, logged meals, and preferences. This - can't be undone. -

- - - - ); - } - - return ( -
-
-

- Delete Account -

- {content} - {error && ( -

- {error} -

- )} -
-
- ); -} diff --git a/apps/next/src/components/ui/delete-account-content.tsx b/apps/next/src/components/ui/delete-account-content.tsx new file mode 100644 index 00000000..74ae0205 --- /dev/null +++ b/apps/next/src/components/ui/delete-account-content.tsx @@ -0,0 +1,167 @@ +"use client"; + +import DeleteIcon from "@mui/icons-material/DeleteOutline"; +import { Button } from "@mui/material"; +import posthog from "posthog-js"; +import { useEffect, useState } from "react"; +import { getSignInUrl } from "@/lib/auth-actions"; +import { SESSION_FRESH_AGE } from "@/lib/auth-constants"; +import { Provider } from "@/lib/auth-types"; +import { authClient, signOut, useSession } from "@/utils/auth-client"; + +// Added to the return URL so the dialog reopens at the confirm step after signing in again. +export const DELETE_ACCOUNT_CONFIRM_PARAM = "deleteAccount"; + +type DeleteAccountContentProps = { + onClose: () => void; +}; + +export default function DeleteAccountContent({ + onClose, +}: DeleteAccountContentProps) { + const { data: session } = useSession(); + const [confirmRequested, setConfirmRequested] = useState(false); + const [isWorking, setIsWorking] = useState(false); + const [error, setError] = useState(null); + + useEffect(() => { + const url = new URL(window.location.href); + if (!url.searchParams.has(DELETE_ACCOUNT_CONFIRM_PARAM)) return; + url.searchParams.delete(DELETE_ACCOUNT_CONFIRM_PARAM); + window.history.replaceState(null, "", url); + setConfirmRequested(true); + }, []); + + const handleSignInAgain = async () => { + setError(null); + setIsWorking(true); + try { + const { data: accounts } = await authClient.listAccounts(); + const provider = accounts?.[0]?.accountId.startsWith("apple_") + ? Provider.Apple + : Provider.Google; + const returnUrl = new URL(window.location.href); + returnUrl.searchParams.set(DELETE_ACCOUNT_CONFIRM_PARAM, "confirm"); + window.location.href = await getSignInUrl(provider, { + returnUrl: returnUrl.pathname + returnUrl.search, + authorizationUrlParams: { prompt: "consent" }, + }); + } catch (signInError) { + console.error("Error signing in again", signInError); + posthog.captureException(signInError); + setError("Couldn't start sign-in. Please try again."); + setIsWorking(false); + } + }; + + const handleDelete = async () => { + setError(null); + setIsWorking(true); + const { error: deleteError } = await authClient.deleteUser(); + if (deleteError) { + console.error("Error deleting account", deleteError); + setError("Couldn't delete your account. Please try again."); + setIsWorking(false); + return; + } + + window.alert("Your account has been deleted."); + await signOut(); + }; + + // Only offer deletion right after signing in again from this dialog. + const isConfirmStep = + confirmRequested && + !!session && + Date.now() - new Date(session.session.createdAt).getTime() < + SESSION_FRESH_AGE * 1000; + + const sectionHeading = + "font-poppins text-[24px] font-bold leading-[36px] text-[var(--primary-accent-hex)] dark:text-[var(--primary-accent-light)]"; + const sectionDescription = + "font-poppins text-[14px] font-normal leading-[21px] text-[var(--text-muted-soft)] dark:text-white"; + const buttonBase = + "font-poppins text-[14px] font-medium leading-[26px] tracking-[0.46px] !flex !items-center !justify-center !rounded-[8px] !h-[49px] !w-full !min-w-0 md:!w-auto md:!min-w-[81.4px] md:!px-4"; + + return ( +
+
+
+ +
+
+

+ Delete your account +

+

+ This can't be undone +

+
+
+ +
+

+ {isConfirmStep ? "Are you sure?" : "Delete Account"} +

+

+ This permanently deletes the PeterPlate account for{" "} + {session?.user.email}, + including your ratings, favorites, logged meals, and preferences. +

+ {!isConfirmStep && ( +

+ To continue, sign in again to confirm it's you. +

+ )} + {error && ( +

+ {error} +

+ )} +
+ +
+ + {isConfirmStep ? ( + + ) : ( + + )} +
+
+ ); +} diff --git a/apps/next/src/components/ui/sidebar/sidebar-content.tsx b/apps/next/src/components/ui/sidebar/sidebar-content.tsx index 4f1e2b4d..469a44a7 100644 --- a/apps/next/src/components/ui/sidebar/sidebar-content.tsx +++ b/apps/next/src/components/ui/sidebar/sidebar-content.tsx @@ -28,11 +28,13 @@ import { cn } from "@/utils/tw"; interface ProfileMenuContentProps { onClose: () => void; onEditPreferencesClick: () => void; + onDeleteAccountClick: () => void; } export default function SidebarContent({ onClose, onEditPreferencesClick, + onDeleteAccountClick, }: ProfileMenuContentProps): React.JSX.Element | null { const { data: session } = useSession(); const user = session?.user; @@ -235,16 +237,20 @@ export default function SidebarContent({ {user && ( - - } - color="error.main" + )}
@@ -303,13 +309,11 @@ function MenuLink({ href, onClick, icon, - color = "text.primary", children, }: { href: string; onClick: () => void; icon: ReactNode; - color?: string; children: ReactNode; }) { return ( @@ -320,7 +324,7 @@ function MenuLink({ dark:hover:bg-gray-700`} > {icon} - + {children} diff --git a/apps/next/src/components/ui/toolbar.tsx b/apps/next/src/components/ui/toolbar.tsx index 42935550..1b54133e 100644 --- a/apps/next/src/components/ui/toolbar.tsx +++ b/apps/next/src/components/ui/toolbar.tsx @@ -34,6 +34,9 @@ import { useTourStore } from "@/context/useTourStore"; import { useHeroFade } from "@/hooks/useHeroFade"; import { useMediaQuery } from "@/hooks/useMediaQuery"; import { useSession } from "@/utils/auth-client"; +import DeleteAccountContent, { + DELETE_ACCOUNT_CONFIRM_PARAM, +} from "./delete-account-content"; import EditPreferencesContent from "./edit-preferences-content"; import { WelcomeView } from "./onboarding"; import SidebarContent from "./sidebar/sidebar-content"; @@ -204,6 +207,7 @@ export function DesktopToolbar(): React.JSX.Element { const [editPreferencesSnackbarOpen, setEditPreferencesSnackbarOpen] = useState(false); const [editPreferencesExpanded, setEditPreferencesExpanded] = useState(false); + const [deleteAccountOpen, setDeleteAccountOpen] = useState(false); const handleProfileOpen = (event: MouseEvent) => { setProfileAnchor(event.currentTarget); @@ -223,10 +227,22 @@ export function DesktopToolbar(): React.JSX.Element { setEditPreferencesOpen(false); setEditPreferencesSnackbarOpen(true); }; + const handleDeleteAccountOpen = () => { + setDeleteAccountOpen(true); + }; + const handleDeleteAccountClose = () => { + setDeleteAccountOpen(false); + }; const { data: session, isPending } = useSession(); const user = session?.user; const start = useTourStore((state) => state.start); + // Reopens at the confirm step after signing in again. + useEffect(() => { + const params = new URLSearchParams(window.location.search); + if (params.has(DELETE_ACCOUNT_CONFIRM_PARAM)) setDeleteAccountOpen(true); + }, []); + return ( <> @@ -473,6 +490,18 @@ export function DesktopToolbar(): React.JSX.Element { )} + + + + state.start); useEffect(() => { setIsMounted(true); }, []); + // Reopens at the confirm step after signing in again. + useEffect(() => { + const params = new URLSearchParams(window.location.search); + if (params.has(DELETE_ACCOUNT_CONFIRM_PARAM)) setDeleteAccountOpen(true); + }, []); + const handleProfileOpen = (event: React.MouseEvent) => { setProfileAnchor(event.currentTarget); }; @@ -536,6 +572,15 @@ function MobileToolbar(): React.JSX.Element { setEditPreferencesSnackbarOpen(true); }; + const handleDeleteAccountOpen = () => { + setProfileAnchor(null); + setDeleteAccountOpen(true); + }; + + const handleDeleteAccountClose = () => { + setDeleteAccountOpen(false); + }; + const diningHref = pathname === "/brandywine" ? "/anteatery" @@ -730,6 +775,7 @@ function MobileToolbar(): React.JSX.Element { @@ -764,6 +810,20 @@ function MobileToolbar(): React.JSX.Element { /> + + + + Date: Fri, 13 Nov 2026 13:42:08 -0800 Subject: [PATCH 4/4] =?UTF-8?q?fix(auth):=20=F0=9F=90=9B=20show=20snackbar?= =?UTF-8?q?=20instead=20of=20alert=20after=20account=20deletion?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/next/src/app/layout-client.tsx | 10 +++++++++- apps/next/src/components/ui/delete-account-content.tsx | 4 +++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/apps/next/src/app/layout-client.tsx b/apps/next/src/app/layout-client.tsx index 199453a7..762380e7 100644 --- a/apps/next/src/app/layout-client.tsx +++ b/apps/next/src/app/layout-client.tsx @@ -7,6 +7,7 @@ import posthog from "posthog-js"; import { useEffect, useState } from "react"; import superjson from "superjson"; import { ThemeProvider } from "@/components/theme-provider"; +import { ACCOUNT_DELETED_KEY } from "@/components/ui/delete-account-content"; import Toolbar from "@/components/ui/toolbar"; import { DateProvider } from "@/context/date-context"; import { useSnackbarStore } from "@/context/useSnackbar"; @@ -79,7 +80,14 @@ export function RootClient({ children }: { children: React.ReactNode }) { } function GlobalSnackbar() { - const { open, message, severity, closeSnackbar } = useSnackbarStore(); + const { open, message, severity, showSnackbar, closeSnackbar } = + useSnackbarStore(); + + useEffect(() => { + if (!sessionStorage.getItem(ACCOUNT_DELETED_KEY)) return; + sessionStorage.removeItem(ACCOUNT_DELETED_KEY); + showSnackbar("Your account has been deleted.", "success"); + }, [showSnackbar]); return ( diff --git a/apps/next/src/components/ui/delete-account-content.tsx b/apps/next/src/components/ui/delete-account-content.tsx index 74ae0205..ff38d850 100644 --- a/apps/next/src/components/ui/delete-account-content.tsx +++ b/apps/next/src/components/ui/delete-account-content.tsx @@ -12,6 +12,8 @@ import { authClient, signOut, useSession } from "@/utils/auth-client"; // Added to the return URL so the dialog reopens at the confirm step after signing in again. export const DELETE_ACCOUNT_CONFIRM_PARAM = "deleteAccount"; +export const ACCOUNT_DELETED_KEY = "accountDeleted"; + type DeleteAccountContentProps = { onClose: () => void; }; @@ -65,7 +67,7 @@ export default function DeleteAccountContent({ return; } - window.alert("Your account has been deleted."); + sessionStorage.setItem(ACCOUNT_DELETED_KEY, "1"); await signOut(); };