This commit is contained in:
headlesdev
2025-05-17 19:33:52 +02:00
parent 9b4d2e9735
commit ec8c5ffc03
5 changed files with 201 additions and 4 deletions

View File

@@ -30,7 +30,7 @@ export async function POST(request: NextRequest) {
return NextResponse.json({ error: "User not found" }, { status: 404 });
}
return NextResponse.json({ message: "Valid" }, { status: 200 });
return NextResponse.json({ message: "Valid", username: user.username, name: user.name }, { status: 200 });
} catch (error: any) {
return NextResponse.json({ error: "Internal Server Error" }, { status: 500 });

View File

@@ -1,9 +1,20 @@
"use client";
import Sidebar from "@/components/Sidebar";
export default function DashboardPage() {
interface DashboardPageProps {
username: string;
name: string;
}
export default function DashboardPage({ username, name }: DashboardPageProps) {
return (
<div>
<h1>Dashboard</h1>
<Sidebar username={username} fullName={name}>
<main>
<h1>Dashboard</h1>
</main>
</Sidebar>
</div>
);
}

View File

@@ -11,6 +11,8 @@ import Cookies from "js-cookie";
export default function Dashboard() {
const router = useRouter();
const [loading, setLoading] = useState(true);
const [username, setUsername] = useState("");
const [name, setName] = useState("");
useEffect(() => {
const init = async () => {
@@ -23,6 +25,8 @@ export default function Dashboard() {
Cookies.remove("token");
router.push("/");
} else {
setUsername(response.data.username);
setName(response.data.name);
setLoading(false);
}
};
@@ -32,6 +36,6 @@ export default function Dashboard() {
if (loading) {
return <Loading />;
} else {
return <DashboardPage />;
return <DashboardPage username={username} name={name} />;
}
}