Merge pull request #10 from rede5/codex/fix-admin-login-redirect-to-dashboard
Unify dashboard routing for all roles
This commit is contained in:
commit
79a59e44cd
3 changed files with 4 additions and 18 deletions
|
|
@ -69,14 +69,7 @@ export default function LoginPage() {
|
||||||
localStorage.setItem("rememberedEmail", data.email);
|
localStorage.setItem("rememberedEmail", data.email);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Redirect based on role
|
router.push("/dashboard");
|
||||||
if (user.role === "admin" || user.roles?.includes("admin")) {
|
|
||||||
router.push("/dashboard/admin");
|
|
||||||
} else if (user.role === "company" || user.roles?.includes("company")) {
|
|
||||||
router.push("/dashboard/empresa");
|
|
||||||
} else {
|
|
||||||
router.push("/dashboard/candidato");
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
setError("Usuário ou senha inválidos.");
|
setError("Usuário ou senha inválidos.");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -27,11 +27,7 @@ export function DashboardHeader() {
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleProfileClick = () => {
|
const handleProfileClick = () => {
|
||||||
if (user?.role === "admin") {
|
router.push("/profile");
|
||||||
router.push("/dashboard/admin/profile");
|
|
||||||
} else {
|
|
||||||
router.push("/dashboard/candidato/perfil");
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const getInitials = (name: string) => {
|
const getInitials = (name: string) => {
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,7 @@ export function Navbar() {
|
||||||
<div className="hidden md:flex items-center gap-4">
|
<div className="hidden md:flex items-center gap-4">
|
||||||
<LanguageSwitcher />
|
<LanguageSwitcher />
|
||||||
{user ? (
|
{user ? (
|
||||||
<Link href={user.role === "admin" ? "/dashboard/admin" : "/dashboard/candidato"}>
|
<Link href="/dashboard">
|
||||||
<Button variant="ghost" className="gap-2">
|
<Button variant="ghost" className="gap-2">
|
||||||
<User className="w-4 h-4" />
|
<User className="w-4 h-4" />
|
||||||
Dashboard
|
Dashboard
|
||||||
|
|
@ -100,10 +100,7 @@ export function Navbar() {
|
||||||
|
|
||||||
<div className="flex flex-col gap-2 mt-4 pt-4 border-t">
|
<div className="flex flex-col gap-2 mt-4 pt-4 border-t">
|
||||||
{user ? (
|
{user ? (
|
||||||
<Link
|
<Link href="/dashboard" onClick={() => setIsOpen(false)}>
|
||||||
href={user.role === "admin" ? "/dashboard/admin" : "/dashboard/candidato"}
|
|
||||||
onClick={() => setIsOpen(false)}
|
|
||||||
>
|
|
||||||
<Button variant="ghost" className="w-full justify-start gap-2">
|
<Button variant="ghost" className="w-full justify-start gap-2">
|
||||||
<User className="w-4 h-4" />
|
<User className="w-4 h-4" />
|
||||||
Dashboard
|
Dashboard
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue