|
| 1 | +import type { ReactNode } from 'react'; |
| 2 | +import Image from 'next/image'; |
| 3 | +import { Badge } from '@/components/ui/badge'; |
| 4 | +import { Button } from '@/components/ui/button'; |
| 5 | +import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card'; |
| 6 | +import { FetchUser } from '@/actions/fetchUser'; |
| 7 | + |
| 8 | +interface FeatureCardProps { |
| 9 | + icon: ReactNode; |
| 10 | + title: string; |
| 11 | + description: string; |
| 12 | +} |
| 13 | + |
| 14 | +function FeatureCard({ icon, title, description }: FeatureCardProps) { |
| 15 | + return ( |
| 16 | + <div className="flex flex-col items-center gap-2 bg-muted/40 rounded-lg p-4 w-full md:w-64"> |
| 17 | + <div className="text-2xl">{icon}</div> |
| 18 | + <div className="font-semibold text-center">{title}</div> |
| 19 | + <div className="text-sm text-muted-foreground text-center">{description}</div> |
| 20 | + </div> |
| 21 | + ); |
| 22 | +} |
| 23 | + |
| 24 | +const features = [ |
| 25 | + { |
| 26 | + icon: <span role="img" aria-label="rocket">🚀</span>, |
| 27 | + title: 'Access to All Models', |
| 28 | + description: 'Get access to our full suite of models including Claude, o3-mini-high, and more!' |
| 29 | + }, |
| 30 | + { |
| 31 | + icon: <span role="img" aria-label="gift">🎁</span>, |
| 32 | + title: 'Generous Limits', |
| 33 | + description: 'Receive 1500 standard credits per month, plus 100 premium credits* per month.' |
| 34 | + }, |
| 35 | + { |
| 36 | + icon: <span role="img" aria-label="support">🛟</span>, |
| 37 | + title: 'Priority Support', |
| 38 | + description: 'Get faster responses and dedicated assistance from the T3 team whenever you need help!' |
| 39 | + } |
| 40 | +]; |
| 41 | + |
| 42 | +const keyboardShortcuts = [ |
| 43 | + { label: 'Search', keys: ['⌘', 'K'] }, |
| 44 | + { label: 'New Chat', keys: ['⌘', 'Shift', 'O'] }, |
| 45 | + { label: 'Toggle Sidebar', keys: ['⌘', 'B'] }, |
| 46 | +]; |
| 47 | + |
| 48 | +export default async function SubscriptionPage() { |
| 49 | + const user = await FetchUser() |
| 50 | + console.log(user) |
| 51 | + return ( |
| 52 | + <div className="min-h-screen bg-background text-foreground flex flex-col items-center py-8 px-2 md:px-0"> |
| 53 | + <div className="w-full max-w-5xl flex flex-col md:flex-row gap-8"> |
| 54 | + {/* Left Column */} |
| 55 | + <div className="flex-1 flex flex-col gap-6 max-w-md mx-auto md:mx-0"> |
| 56 | + {/* Profile Card */} |
| 57 | + <Card className="bg-muted/40"> |
| 58 | + <CardHeader className="flex flex-col items-center gap-2 pb-2"> |
| 59 | + <div className="w-24 h-24 rounded-full overflow-hidden border-4 border-muted"> |
| 60 | + <Image |
| 61 | + src={user?.image || ""} |
| 62 | + alt="Profile" |
| 63 | + width={96} |
| 64 | + height={96} |
| 65 | + className="object-cover w-full h-full" |
| 66 | + priority |
| 67 | + /> |
| 68 | + </div> |
| 69 | + <CardTitle className="text-xl mt-2">{user?.name}</CardTitle> |
| 70 | + <div className="text-muted-foreground text-sm">{user?.email}</div> |
| 71 | + <Badge variant="secondary" className="mt-1">Free Plan</Badge> |
| 72 | + </CardHeader> |
| 73 | + <CardContent> |
| 74 | + <div className="bg-background rounded-lg p-4 flex flex-col gap-2 mt-2"> |
| 75 | + <div className="flex items-center justify-between text-sm"> |
| 76 | + <span className="text-muted-foreground">Message Usage</span> |
| 77 | + <span className="text-muted-foreground">Resets tomorrow at 5:30 AM</span> |
| 78 | + </div> |
| 79 | + <div className="flex items-center justify-between text-sm"> |
| 80 | + <span>Standard</span> |
| 81 | + <span>0/20</span> |
| 82 | + </div> |
| 83 | + <div className="w-full h-2 bg-muted rounded-full overflow-hidden"> |
| 84 | + <div className="h-full bg-primary" style={{ width: '0%' }} /> |
| 85 | + </div> |
| 86 | + <div className="text-xs text-muted-foreground mt-1">20 messages remaining</div> |
| 87 | + </div> |
| 88 | + </CardContent> |
| 89 | + </Card> |
| 90 | + |
| 91 | + {/* Keyboard Shortcuts */} |
| 92 | + <Card className="bg-muted/40"> |
| 93 | + <CardHeader> |
| 94 | + <CardTitle className="text-base">Keyboard Shortcuts</CardTitle> |
| 95 | + </CardHeader> |
| 96 | + <CardContent className="flex flex-col gap-3"> |
| 97 | + {keyboardShortcuts.map(shortcut => ( |
| 98 | + <div key={shortcut.label} className="flex items-center justify-between"> |
| 99 | + <span>{shortcut.label}</span> |
| 100 | + <span className="flex gap-1"> |
| 101 | + {shortcut.keys.map(key => ( |
| 102 | + <kbd key={key} className="bg-muted px-2 py-1 rounded text-xs font-mono border border-border">{key}</kbd> |
| 103 | + ))} |
| 104 | + </span> |
| 105 | + </div> |
| 106 | + ))} |
| 107 | + </CardContent> |
| 108 | + </Card> |
| 109 | + </div> |
| 110 | + |
| 111 | + {/* Right Column */} |
| 112 | + <div className="flex-1 flex flex-col gap-6"> |
| 113 | + {/* Upgrade to Pro */} |
| 114 | + <Card className="bg-muted/40"> |
| 115 | + <CardHeader> |
| 116 | + <CardTitle className="text-xl">Upgrade to Pro</CardTitle> |
| 117 | + </CardHeader> |
| 118 | + <CardContent> |
| 119 | + <div className="flex flex-col md:flex-row gap-4 mb-6"> |
| 120 | + {features.map(f => ( |
| 121 | + <FeatureCard key={f.title} {...f} /> |
| 122 | + ))} |
| 123 | + </div> |
| 124 | + <div className="flex items-center gap-4 mb-2"> |
| 125 | + <span className="text-2xl font-bold">$8</span> |
| 126 | + <span className="text-muted-foreground">/month</span> |
| 127 | + </div> |
| 128 | + <Button className="bg-pink-600 hover:bg-pink-700 text-white w-full max-w-xs">Upgrade Now</Button> |
| 129 | + <div className="text-xs text-muted-foreground mt-2"> |
| 130 | + * Premium credits are used for GPT Image Gen, Claude Sonnet, and Grok 3. Additional Premium credits can be purchased separately. |
| 131 | + </div> |
| 132 | + </CardContent> |
| 133 | + </Card> |
| 134 | + |
| 135 | + {/* Danger Zone */} |
| 136 | + <Card className="bg-muted/40"> |
| 137 | + <CardHeader> |
| 138 | + <CardTitle className="text-lg text-destructive">Danger Zone</CardTitle> |
| 139 | + </CardHeader> |
| 140 | + <CardContent> |
| 141 | + <div className="mb-2 text-sm">Permanently delete your account and all associated data.</div> |
| 142 | + <Button variant="destructive" className="w-full max-w-xs">Delete Account</Button> |
| 143 | + </CardContent> |
| 144 | + </Card> |
| 145 | + </div> |
| 146 | + </div> |
| 147 | + </div> |
| 148 | + ); |
| 149 | +} |
0 commit comments