diff --git a/src/pages/Settings.tsx b/src/pages/Settings.tsx index 5ad0382..36b56e2 100644 --- a/src/pages/Settings.tsx +++ b/src/pages/Settings.tsx @@ -1,3 +1,4 @@ +import { useState, useEffect } from 'react' import { Link, useNavigate } from 'react-router-dom' import { authClient } from '../lib/auth-client.ts' import { useAuthStore } from '../stores/auth.ts' @@ -9,6 +10,26 @@ export function Settings() { const setAuthenticated = useAuthStore((s) => s.setAuthenticated) const navigate = useNavigate() const { theme, setTheme } = useThemeStore() + const [emailInAddress, setEmailInAddress] = useState(null) + const [copied, setCopied] = useState(false) + + useEffect(() => { + if (!session?.user) return + fetch('/api/me/email-in-address', { + credentials: 'include', + }) + .then((res) => res.json()) + .then((data) => setEmailInAddress(data.email_address)) + .catch(() => setEmailInAddress(null)) + }, [session]) + + async function handleCopyEmail() { + if (emailInAddress) { + await navigator.clipboard.writeText(emailInAddress) + setCopied(true) + setTimeout(() => setCopied(false), 2000) + } + } const user = session?.user const connectedStores: string[] = [] @@ -113,6 +134,30 @@ export function Settings() { + + {/* Receipt Email section */} +
+

Receipt Email

+
+

+ Forward your digital receipt emails to this address: +

+
+ + {emailInAddress ?? 'Loading...'} + + +
+

+ Supports Meijer, Kroger, and Target receipt emails. +

+
+
) }