initial commit
This commit is contained in:
@@ -0,0 +1,67 @@
|
||||
"use client"
|
||||
|
||||
import Header from "@/components/header";
|
||||
import { Skeleton } from "@/components/ui/skeleton";
|
||||
import { useTranslations } from "next-intl";
|
||||
import type { Consent, User } from "@/types";
|
||||
import { AppWindowMacIcon, BriefcaseBusinessIcon, LogOutIcon, UserIcon } from "lucide-react";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { useState } from "react";
|
||||
import { Logout } from "@/actions/auth";
|
||||
import Profile from "./items/profile";
|
||||
import Applications from "./items/applications";
|
||||
|
||||
interface Props {
|
||||
userData: User | null;
|
||||
consentsData: Consent[] | [];
|
||||
}
|
||||
|
||||
export default function MeClient({ userData, consentsData }: Props) {
|
||||
const t = useTranslations("MePage");
|
||||
|
||||
const [user, setUser] = useState(userData);
|
||||
const [consents, setConsents] = useState(consentsData)
|
||||
const [selectedItem, setSelectedItem] = useState(0);
|
||||
|
||||
const items = [
|
||||
{"name": t("items.profile.title"), "icon": <UserIcon />, "component": <Profile user={user} setUser={setUser} />},
|
||||
{"name": t("items.applications.title"), "icon": <AppWindowMacIcon />, "component": <Applications consents={consents} setConsents={setConsents} />},
|
||||
{"name": t("items.positions.title"), "icon": <BriefcaseBusinessIcon />},
|
||||
]
|
||||
|
||||
return (
|
||||
<>
|
||||
<Header />
|
||||
<div className="bg-background flex min-h-svh flex-col gap-6">
|
||||
<div className="px-8 lg:px-16 pt-30 pb-16">
|
||||
{!user ? (
|
||||
<div className="flex flex-col gap-2">
|
||||
<Skeleton className="w-64 h-5" />
|
||||
<Skeleton className="w-52 h-4" />
|
||||
</div>
|
||||
) : (
|
||||
<div className="flex flex-col lg:flex-row gap-12">
|
||||
<div className="flex flex-col gap-8">
|
||||
<div className="flex flex-col">
|
||||
<h2 className="text-lg">
|
||||
{user.first_name} {user.second_name}
|
||||
</h2>
|
||||
<p className="text-muted-foreground text-base">{user.email}</p>
|
||||
</div>
|
||||
<div className="flex flex-col gap-0.5 lg:w-64">
|
||||
{
|
||||
items.map((item, index) => (
|
||||
<Button variant="ghost" className={`justify-start -mx-4 ${selectedItem == index && "bg-muted"}`} key={index} onClick={() => setSelectedItem(index)}>{item.icon}<h3 className="text-sm">{item.name}</h3></Button>
|
||||
))
|
||||
}
|
||||
<Button variant="ghost" className="justify-start -mx-4" onClick={async () => Logout()}><LogOutIcon /><h3 className="text-sm">{t("items.logout")}</h3></Button>
|
||||
</div>
|
||||
</div>
|
||||
{items[selectedItem].component}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user