|
1 | 1 | import { Metadata } from "next"; |
2 | 2 | import UserProfile from "@/app/components/dashboard/Settings/Profile"; |
3 | 3 | import ResetPassword from "@/app/components/dashboard/Settings/ResetPassword"; |
| 4 | +import WakaTimeKey from "@/app/components/dashboard/Settings/WakaTimeKey"; |
4 | 5 | import { getUserWithProfile } from "@/app/lib/supabase/help/user"; |
5 | 6 | import { redirect } from "next/navigation"; |
6 | 7 |
|
7 | 8 | export const metadata: Metadata = { |
8 | 9 | title: "Settings - DevPulse", |
9 | 10 | }; |
10 | 11 |
|
11 | | -export default async function LeaderboardsPage() { |
12 | | - const { user } = await getUserWithProfile(); |
| 12 | +export default async function SettingsPage() { |
| 13 | + const { user, profile } = await getUserWithProfile(); |
13 | 14 | if (!user) return redirect("/login?from=/dashboard/settings"); |
14 | 15 |
|
| 16 | + const hasWakaKey = Boolean(profile?.wakatime_api_key); |
| 17 | + const maskedWakaKey = profile?.wakatime_api_key |
| 18 | + ? `${profile.wakatime_api_key.slice(0, 8)}...${profile.wakatime_api_key.slice(-4)}` |
| 19 | + : null; |
| 20 | + |
15 | 21 | return ( |
16 | | - <div className="p-6 md:p-8 space-y-6"> |
17 | | - <div> |
18 | | - <h1 className="text-2xl font-bold text-white">Settings</h1> |
19 | | - <p className="text-sm text-gray-600"> |
20 | | - Manage your account settings and including your WakaTime API key. |
21 | | - </p> |
| 22 | + <div className="p-4 md:p-6 space-y-4 max-w-7xl mx-auto"> |
| 23 | + <div className="glass-card p-4 md:p-5 border-t-4 border-indigo-500/50"> |
| 24 | + <div className="flex flex-col md:flex-row md:items-center justify-between gap-4"> |
| 25 | + <div> |
| 26 | + <h1 className="text-xl md:text-2xl font-bold text-white tracking-tight"> |
| 27 | + Account Settings |
| 28 | + </h1> |
| 29 | + <p className="text-xs md:text-sm text-gray-400 mt-1"> |
| 30 | + Manage profile details, WakaTime connection, and account security. |
| 31 | + </p> |
| 32 | + </div> |
| 33 | + |
| 34 | + <div className="flex items-center gap-2 text-[11px] uppercase tracking-wider"> |
| 35 | + <span |
| 36 | + className={`px-2 py-1 rounded-full border font-semibold ${ |
| 37 | + hasWakaKey |
| 38 | + ? "border-emerald-500/30 bg-emerald-500/10 text-emerald-300" |
| 39 | + : "border-amber-500/30 bg-amber-500/10 text-amber-300" |
| 40 | + }`} |
| 41 | + > |
| 42 | + {hasWakaKey ? "WakaTime Connected" : "WakaTime Not Connected"} |
| 43 | + </span> |
| 44 | + </div> |
| 45 | + </div> |
22 | 46 | </div> |
23 | 47 |
|
24 | 48 | {user && ( |
25 | | - <> |
26 | | - <UserProfile user={user} /> |
27 | | - <ResetPassword user={user} /> |
28 | | - </> |
| 49 | + <div className="grid grid-cols-1 xl:grid-cols-3 gap-4 items-start"> |
| 50 | + <div className="xl:col-span-2 space-y-4"> |
| 51 | + <UserProfile user={user} /> |
| 52 | + <WakaTimeKey hasKey={hasWakaKey} maskedKey={maskedWakaKey} /> |
| 53 | + </div> |
| 54 | + |
| 55 | + <div className="xl:col-span-1"> |
| 56 | + <ResetPassword user={user} /> |
| 57 | + </div> |
| 58 | + </div> |
29 | 59 | )} |
30 | 60 | </div> |
31 | 61 | ); |
|
0 commit comments