feat(customers): add initial admin bootstrap and csv import
This commit is contained in:
parent
c816e9869d
commit
ecab0fe6b6
27 changed files with 1197 additions and 34 deletions
|
|
@ -1,31 +1,51 @@
|
|||
"use client";
|
||||
|
||||
import { useEffect, useMemo, useState } from "react";
|
||||
|
||||
import LogoutButton from "@/components/LogoutButton";
|
||||
import { api } from "@/lib/api";
|
||||
import type { CurrentUser } from "@/types/rbac";
|
||||
|
||||
export default function Header() {
|
||||
const [currentUser, setCurrentUser] = useState<CurrentUser | null>(null);
|
||||
|
||||
return (
|
||||
useEffect(() => {
|
||||
let active = true;
|
||||
|
||||
<header className="h-20 bg-white border-b flex items-center justify-between px-8">
|
||||
api.get<CurrentUser>("/me")
|
||||
.then((response) => {
|
||||
if (active) {
|
||||
setCurrentUser(response.data);
|
||||
}
|
||||
})
|
||||
.catch(() => {
|
||||
if (active) {
|
||||
setCurrentUser(null);
|
||||
}
|
||||
});
|
||||
|
||||
<h1 className="text-3xl font-bold">
|
||||
return () => {
|
||||
active = false;
|
||||
};
|
||||
}, []);
|
||||
|
||||
Dashboard
|
||||
const displayName = useMemo(() => {
|
||||
if (!currentUser) {
|
||||
return "Benutzer";
|
||||
}
|
||||
|
||||
</h1>
|
||||
const fullName = `${currentUser.first_name} ${currentUser.last_name}`.trim();
|
||||
return fullName || currentUser.username || "Benutzer";
|
||||
}, [currentUser]);
|
||||
|
||||
<div className="flex items-center gap-4">
|
||||
|
||||
<span className="font-semibold">
|
||||
|
||||
admin.schubert
|
||||
|
||||
</span>
|
||||
|
||||
<LogoutButton />
|
||||
|
||||
</div>
|
||||
|
||||
</header>
|
||||
|
||||
);
|
||||
return (
|
||||
<header className="flex h-20 items-center justify-between border-b bg-white px-8">
|
||||
<h1 className="text-3xl font-bold">Dashboard</h1>
|
||||
|
||||
<div className="flex items-center gap-4">
|
||||
<span className="font-semibold">{displayName}</span>
|
||||
<LogoutButton />
|
||||
</div>
|
||||
</header>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue