Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 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 | import { AuthContext } from '@common/contexts/AuthContext'; import { useEmailAlias } from '@common/hooks/useEmailAlias'; import { Button } from '@web/components/ui/button'; import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@web/components/ui/card'; import { Input } from '@web/components/ui/input'; import { Label } from '@web/components/ui/label'; import { Check, Copy, RefreshCw } from 'lucide-react'; import { useContext, useState } from 'react'; export default function ProfilePage() { const auth = useContext(AuthContext); const user = auth?.user; const { emailAlias, loading, error, copyToClipboard } = useEmailAlias(); const [copied, setCopied] = useState(false); const handleCopy = async () => { const success = await copyToClipboard(); if (success) { setCopied(true); setTimeout(() => setCopied(false), 2000); } }; return ( <div className="container mx-auto px-4 py-8"> <div className="max-w-3xl mx-auto"> <h1 className="text-3xl font-bold mb-8">Profile Settings</h1> <Card className="mb-8"> <CardHeader> <CardTitle>Your Information</CardTitle> <CardDescription> Manage your account details and newsletter email address </CardDescription> </CardHeader> <CardContent className="space-y-6"> <div className="space-y-2"> <Label htmlFor="email">Login Email</Label> <Input id="email" type="email" value={user?.email || ''} disabled className="max-w-md" /> <p className="text-sm text-muted-foreground"> This is the email you use to log in to your account. </p> </div> <div className="space-y-2"> <Label htmlFor="newsletter-email">Newsletter Email</Label> {loading ? ( <div className="flex items-center gap-2 text-muted-foreground"> <RefreshCw className="h-4 w-4 animate-spin" /> <span>Loading your email address...</span> </div> ) : error ? ( <div className="text-destructive text-sm"> Error: {error}. Please try again later. </div> ) : emailAlias ? ( <div className="flex items-center gap-2 max-w-md"> <div className="relative flex-1"> <Input id="newsletter-email" value={emailAlias} readOnly className="font-mono text-sm bg-slate-50" /> <Button type="button" variant="ghost" size="sm" className="absolute right-1 top-1/2 -translate-y-1/2 h-8 w-8 p-0" onClick={handleCopy} disabled={copied} > {copied ? ( <Check className="h-4 w-4 text-green-500" /> ) : ( <Copy className="h-4 w-4" /> )} <span className="sr-only">Copy email</span> </Button> </div> </div> ) : null} <p className="text-sm text-muted-foreground"> Use this email to subscribe to newsletters. They'll appear in your inbox. </p> </div> </CardContent> </Card> </div> </div> ); } |