"use client";

import { useEffect, useState } from "react";
import { useRouter } from "next/navigation";
import { useUser } from "../hooks/useUser";
import { useAuth } from "../hooks/useAuth";
export default function DashboardPage() {
  const router = useRouter();
  const { token } = useAuth();
  const user = useUser();

  useEffect(() => {
    if (!token) {
      router.push("/login");
    }
  }, [token, router]);

  if (!user) {
    return <div>Loading...</div>;
  }
  return (
    <div className="min-h-screen p-4">
      <div className="max-w-4xl mx-auto">
        <h1 className="text-2xl font-bold">Welcome, {user.firstName}!</h1>
        <p>Email: {user.email}</p>
        <p>Role: {user.role}</p>
      </div>
    </div>
  );
}
