|
3 | 3 | import { useSubscription } from "@/hooks/useSubscription"; |
4 | 4 | import Link from "next/link"; |
5 | 5 | import { ArrowLeft } from "lucide-react"; |
| 6 | +import { memo, useMemo } from "react"; |
| 7 | +import { ActiveTag } from "@/components/ui/ActiveTag"; |
| 8 | + |
| 9 | +const AccountPageContent = memo(function AccountPageContent({ |
| 10 | + isPaidUser, |
| 11 | +}: { |
| 12 | + isPaidUser: boolean; |
| 13 | +}) { |
| 14 | + const plan = useMemo(() => (isPaidUser ? "Pro" : "Free"), [isPaidUser]); |
| 15 | + |
| 16 | + return ( |
| 17 | + <> |
| 18 | + <div className="mb-6"> |
| 19 | + <Link |
| 20 | + href="/dashboard/home" |
| 21 | + className="inline-flex items-center gap-2 text-ox-purple hover:text-ox-purple-2 transition-colors mb-4" |
| 22 | + > |
| 23 | + <ArrowLeft className="h-4 w-4" /> |
| 24 | + <span>Back to Dashboard</span> |
| 25 | + </Link> |
| 26 | + <h1 className="text-2xl md:text-3xl font-semibold text-white"> |
| 27 | + Account Settings |
| 28 | + </h1> |
| 29 | + </div> |
| 30 | + |
| 31 | + <div className="bg-ox-sidebar border border-ox-header rounded-lg p-6 max-w-2xl"> |
| 32 | + <div className="space-y-4"> |
| 33 | + <div> |
| 34 | + <label className="text-sm text-zinc-400 mb-2 block">Plan</label> |
| 35 | + <div className="flex items-center gap-2"> |
| 36 | + <span className="text-lg font-semibold text-white">{plan}</span> |
| 37 | + {isPaidUser && <ActiveTag />} |
| 38 | + </div> |
| 39 | + </div> |
| 40 | + {!isPaidUser && ( |
| 41 | + <div> |
| 42 | + <Link |
| 43 | + href="/pricing" |
| 44 | + className="inline-flex items-center justify-center px-3 py-1.5 bg-ox-purple hover:bg-ox-purple-2 text-white rounded-md transition-colors text-xs font-medium" |
| 45 | + > |
| 46 | + be a pro |
| 47 | + </Link> |
| 48 | + </div> |
| 49 | + )} |
| 50 | + </div> |
| 51 | + </div> |
| 52 | + </> |
| 53 | + ); |
| 54 | +}); |
6 | 55 |
|
7 | 56 | export default function AccountPage() { |
8 | 57 | const { isPaidUser, isLoading } = useSubscription(); |
9 | 58 |
|
10 | | - const plan = isPaidUser ? "Pro" : "Free"; |
11 | | - |
12 | 59 | return ( |
13 | 60 | <div className="w-full h-full flex flex-col p-6 bg-ox-content"> |
14 | 61 | {isLoading ? ( |
15 | 62 | <div className="flex items-center justify-center h-full"> |
16 | 63 | <span className="text-zinc-400">Loading...</span> |
17 | 64 | </div> |
18 | 65 | ) : ( |
19 | | - <> |
20 | | - <div className="mb-6"> |
21 | | - <Link |
22 | | - href="/dashboard/home" |
23 | | - className="inline-flex items-center gap-2 text-ox-purple hover:text-ox-purple-2 transition-colors mb-4" |
24 | | - > |
25 | | - <ArrowLeft className="h-4 w-4" /> |
26 | | - <span>Back to Dashboard</span> |
27 | | - </Link> |
28 | | - <h1 className="text-2xl md:text-3xl font-semibold text-white"> |
29 | | - Account Settings |
30 | | - </h1> |
31 | | - </div> |
32 | | - |
33 | | - <div className="bg-ox-sidebar border border-ox-header rounded-lg p-6 max-w-2xl"> |
34 | | - <div className="space-y-4"> |
35 | | - <div> |
36 | | - <label className="text-sm text-zinc-400 mb-2 block">Plan</label> |
37 | | - <div className="flex items-center gap-2"> |
38 | | - <span className="text-lg font-semibold text-white"> |
39 | | - {plan} |
40 | | - </span> |
41 | | - {isPaidUser && ( |
42 | | - <span className="px-2 py-0.5 rounded-full bg-ox-purple/20 border border-ox-purple text-ox-purple text-xs font-medium"> |
43 | | - Active |
44 | | - </span> |
45 | | - )} |
46 | | - </div> |
47 | | - </div> |
48 | | - {!isPaidUser && ( |
49 | | - <div> |
50 | | - <Link |
51 | | - href="/pricing" |
52 | | - className="inline-flex items-center justify-center px-3 py-1.5 bg-ox-purple hover:bg-ox-purple-2 text-white rounded-md transition-colors text-xs font-medium" |
53 | | - > |
54 | | - be a pro |
55 | | - </Link> |
56 | | - </div> |
57 | | - )} |
58 | | - </div> |
59 | | - </div> |
60 | | - </> |
| 66 | + <AccountPageContent isPaidUser={isPaidUser} /> |
61 | 67 | )} |
62 | 68 | </div> |
63 | 69 | ); |
|
0 commit comments