feat: account
This commit is contained in:
@@ -0,0 +1,87 @@
|
||||
import Footer from "@/components/footer";
|
||||
import Header from "@/components/header";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Separator } from "@/components/ui/separator";
|
||||
import { getCurrentUser } from "@/lib/user";
|
||||
import { formatDate } from "@/lib/utils";
|
||||
import { BookOpenTextIcon, SignatureIcon, UserIcon } from "lucide-react";
|
||||
import { redirect } from "next/navigation";
|
||||
import { DeleteDialog } from "./deleteDialog";
|
||||
import { LogoutButton } from "./logoutButton";
|
||||
|
||||
function ProfileField({ label, value }: { label: string; value: string }) {
|
||||
return (
|
||||
<div className="flex flex-col">
|
||||
<h4>{label}</h4>
|
||||
<p className="text-muted-foreground">{value}</p>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default async function Account() {
|
||||
const user = await getCurrentUser();
|
||||
if (!user) redirect("/");
|
||||
|
||||
return (
|
||||
<>
|
||||
<Header />
|
||||
<div className="flex flex-row py-16 gap-8">
|
||||
<div className="flex flex-col w-56 gap-2 mx-16 shrink-0">
|
||||
<div className="flex flex-row gap-2 items-center text-foreground underline underline-offset-8 decoration-2 mb-1.5">
|
||||
<UserIcon size={16} />
|
||||
<h4>Profile</h4>
|
||||
</div>
|
||||
<div className="flex flex-row gap-2 items-center text-muted-foreground hover:text-foreground hover:underline underline-offset-8 decoration-2 duration-200 cursor-pointer">
|
||||
<BookOpenTextIcon size={16} />
|
||||
<h4>Citizenship</h4>
|
||||
</div>
|
||||
<div className="flex flex-row gap-2 items-center text-muted-foreground hover:text-foreground hover:underline underline-offset-8 decoration-2 duration-200 cursor-pointer">
|
||||
<SignatureIcon size={16} />
|
||||
<h4>Signature</h4>
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex flex-col gap-8 max-w-lg">
|
||||
<div className="flex flex-col gap-6">
|
||||
<div className="flex flex-col gap-1">
|
||||
<h2>Personal details</h2>
|
||||
<p className="text-muted-foreground text-sm">
|
||||
Synced from your Kotosoft ID account. To correct any details, update them there first, then click Update below.
|
||||
</p>
|
||||
</div>
|
||||
<div className="flex flex-col gap-4">
|
||||
<ProfileField label="Name" value={`${user.firstName} ${user.secondName}`} />
|
||||
<ProfileField label="Email" value={user.email} />
|
||||
<ProfileField label="Birthday" value={formatDate(user.birthDate)} />
|
||||
<ProfileField label="Sex" value={user.sex === "MALE" ? "Male" : "Female"} />
|
||||
{user.isAdmin && <ProfileField label="Role" value="Administrator" />}
|
||||
</div>
|
||||
<Separator />
|
||||
<div className="flex flex-row items-center justify-between">
|
||||
<div className="flex flex-col">
|
||||
<h4>Update personal details</h4>
|
||||
<p className="text-muted-foreground">Syncs your name, email, and birthday from Kotosoft ID</p>
|
||||
</div>
|
||||
<Button variant="secondary">Update</Button>
|
||||
</div>
|
||||
<div className="flex flex-row items-center justify-between">
|
||||
<div className="flex flex-col">
|
||||
<h4>Log out</h4>
|
||||
<p className="text-muted-foreground">Log out from your account on this device</p>
|
||||
</div>
|
||||
<LogoutButton />
|
||||
</div>
|
||||
<Separator />
|
||||
<div className="flex flex-row items-center justify-between">
|
||||
<div className="flex flex-col">
|
||||
<h4>Delete account</h4>
|
||||
<p className="text-muted-foreground">Permanently delete your account and all associated data</p>
|
||||
</div>
|
||||
<DeleteDialog userId={user.id} />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<Footer />
|
||||
</>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user