Spaces:
Paused
Paused
Download src/app/(dashboard)/profile/page.tsx from veltrixcode/retest: direct link, hf CLI and curl.
- Browser
- Download file 3.6 kB
-
https://huggingface.co/spaces/veltrixcode/retest/resolve/main/src/app/(dashboard)/profile/page.tsx
- Command line
-
hf download 'hf://spaces/veltrixcode/retest/src/app/(dashboard)/profile/page.tsx'
-
curl -L -o page.tsx 'https://huggingface.co/spaces/veltrixcode/retest/resolve/main/src/app/(dashboard)/profile/page.tsx'
3.6 kB
| import { auth } from "@/auth" | |
| import { redirect } from "next/navigation" | |
| import { checkAndResetDailyCredits } from "@/lib/credits" | |
| import { Button } from "@/components/ui/button" | |
| import { | |
| Card, | |
| CardContent, | |
| CardDescription, | |
| CardHeader, | |
| CardTitle, | |
| CardFooter, | |
| } from "@/components/ui/card" | |
| import { Input } from "@/components/ui/input" | |
| import { Label } from "@/components/ui/label" | |
| import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar" | |
| import { EditProfileDialog } from "@/components/edit-profile-dialog" | |
| export default async function ProfilePage() { | |
| const session = await auth() | |
| if (!session?.user?.id) redirect("/login") | |
| const credits = await checkAndResetDailyCredits(session.user.id) | |
| return ( | |
| <div className="container py-8 max-w-2xl"> | |
| <h1 className="text-3xl font-black tracking-tight mb-8 uppercase">Profile</h1> | |
| <Card> | |
| <CardHeader> | |
| <CardTitle>Your Account</CardTitle> | |
| <CardDescription> | |
| Manage your account settings and view your credits. | |
| </CardDescription> | |
| </CardHeader> | |
| <CardContent className="space-y-6"> | |
| <div className="flex items-center gap-4"> | |
| <Avatar className="h-20 w-20 border-2 border-border shadow-[4px_4px_0px_0px_rgba(0,0,0,1)] dark:shadow-[4px_4px_0px_0px_rgba(255,255,255,1)] rounded-none"> | |
| <AvatarImage src={session.user.image || ""} /> | |
| <AvatarFallback className="text-2xl bg-primary text-white font-black"> | |
| {session.user.name?.[0]?.toUpperCase()} | |
| </AvatarFallback> | |
| </Avatar> | |
| <div> | |
| <h3 className="font-semibold text-xl">{session.user.name}</h3> | |
| <p className="text-muted-foreground">{session.user.email}</p> | |
| </div> | |
| </div> | |
| <div className="grid gap-2"> | |
| <Label>Email</Label> | |
| <Input value={session.user.email || ""} disabled readOnly /> | |
| </div> | |
| <div className="rounded-none border-2 border-border bg-primary/10 p-4 flex justify-between items-center shadow-[4px_4px_0px_0px_rgba(0,0,0,1)] dark:shadow-[4px_4px_0px_0px_rgba(255,255,255,1)]"> | |
| <div> | |
| <p className="font-bold">Available Credits</p> | |
| <p className="text-sm text-muted-foreground"> | |
| Resets to 100 every 24 hours. | |
| </p> | |
| </div> | |
| <div className="text-3xl font-black text-primary">{credits} ⚡</div> | |
| </div> | |
| </CardContent> | |
| <CardFooter className="flex justify-between"> | |
| <EditProfileDialog user={session.user} /> | |
| <form | |
| action={async () => { | |
| "use server" | |
| const { signOut } = await import("@/auth") | |
| await signOut() | |
| }} | |
| > | |
| <Button variant="destructive" type="submit"> | |
| Sign Out | |
| </Button> | |
| </form> | |
| </CardFooter> | |
| </Card> | |
| </div> | |
| ) | |
| } | |