added user card. Not yet designed!
This commit is contained in:
@@ -12,6 +12,8 @@ import {
|
|||||||
IconButton,
|
IconButton,
|
||||||
Menu,
|
Menu,
|
||||||
Box,
|
Box,
|
||||||
|
Avatar,
|
||||||
|
Card,
|
||||||
} from "@chakra-ui/react";
|
} from "@chakra-ui/react";
|
||||||
import { PasswordInput } from "@/components/ui/password-input";
|
import { PasswordInput } from "@/components/ui/password-input";
|
||||||
import Cookies from "js-cookie";
|
import Cookies from "js-cookie";
|
||||||
@@ -55,6 +57,7 @@ export const Header = () => {
|
|||||||
|
|
||||||
// Dialog control
|
// Dialog control
|
||||||
const [isPwOpen, setPwOpen] = useState(false);
|
const [isPwOpen, setPwOpen] = useState(false);
|
||||||
|
const [userDialog, setUserDialog] = useState(false);
|
||||||
|
|
||||||
const changePassword = async () => {
|
const changePassword = async () => {
|
||||||
if (newPassword !== confirmPassword) {
|
if (newPassword !== confirmPassword) {
|
||||||
@@ -93,6 +96,7 @@ export const Header = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const username = userData.first_name ? userData.first_name : "N/A";
|
const username = userData.first_name ? userData.first_name : "N/A";
|
||||||
|
const fullname = userData.first_name + " " + userData.last_name;
|
||||||
|
|
||||||
const logout = () => {
|
const logout = () => {
|
||||||
Cookies.remove("token");
|
Cookies.remove("token");
|
||||||
@@ -255,6 +259,17 @@ export const Header = () => {
|
|||||||
</HStack>
|
</HStack>
|
||||||
</Stack>
|
</Stack>
|
||||||
|
|
||||||
|
<HStack>
|
||||||
|
<Avatar.Root>
|
||||||
|
<button
|
||||||
|
onClick={() => setUserDialog(true)}
|
||||||
|
style={{ cursor: "pointer" }}
|
||||||
|
>
|
||||||
|
<Avatar.Fallback name={fullname} />
|
||||||
|
</button>
|
||||||
|
</Avatar.Root>
|
||||||
|
</HStack>
|
||||||
|
|
||||||
{/* Right: Actions */}
|
{/* Right: Actions */}
|
||||||
{/* Desktop actions */}
|
{/* Desktop actions */}
|
||||||
<HStack
|
<HStack
|
||||||
@@ -336,6 +351,50 @@ export const Header = () => {
|
|||||||
</HStack>
|
</HStack>
|
||||||
</Flex>
|
</Flex>
|
||||||
|
|
||||||
|
{userDialog && (
|
||||||
|
<Card.Root maxW="sm">
|
||||||
|
<Card.Header>
|
||||||
|
<Card.Title>
|
||||||
|
{" "}
|
||||||
|
<Avatar.Root>
|
||||||
|
<button
|
||||||
|
onClick={() => setUserDialog(true)}
|
||||||
|
style={{ cursor: "pointer" }}
|
||||||
|
>
|
||||||
|
<Avatar.Fallback name={fullname} />
|
||||||
|
</button>
|
||||||
|
</Avatar.Root>
|
||||||
|
</Card.Title>
|
||||||
|
<Card.Description>{t("user-info-desc")}</Card.Description>
|
||||||
|
</Card.Header>
|
||||||
|
<Card.Body>
|
||||||
|
<Stack gap="4" w="full">
|
||||||
|
<Text>
|
||||||
|
<strong>{t("first-name")}:</strong> {userData.first_name}
|
||||||
|
</Text>
|
||||||
|
<Text>
|
||||||
|
<strong>{t("last-name")}:</strong> {userData.last_name}
|
||||||
|
</Text>
|
||||||
|
<Text>
|
||||||
|
<strong>{t("username")}:</strong> {userData.username}
|
||||||
|
</Text>
|
||||||
|
<Text>
|
||||||
|
<strong>{t("role")}:</strong> {userData.role}
|
||||||
|
</Text>
|
||||||
|
<Text>
|
||||||
|
<strong>{t("admin-status")}:</strong>{" "}
|
||||||
|
{userData.is_admin ? t("yes") : t("no")}
|
||||||
|
</Text>
|
||||||
|
</Stack>
|
||||||
|
</Card.Body>
|
||||||
|
<Card.Footer justifyContent="flex-end">
|
||||||
|
<Button variant="outline" onClick={() => setUserDialog(false)}>
|
||||||
|
{t("cancel")}
|
||||||
|
</Button>
|
||||||
|
</Card.Footer>
|
||||||
|
</Card.Root>
|
||||||
|
)}
|
||||||
|
|
||||||
{/* Passwort-Dialog (kontrolliert) */}
|
{/* Passwort-Dialog (kontrolliert) */}
|
||||||
<Dialog.Root open={isPwOpen} onOpenChange={(e: any) => setPwOpen(e.open)}>
|
<Dialog.Root open={isPwOpen} onOpenChange={(e: any) => setPwOpen(e.open)}>
|
||||||
<Portal>
|
<Portal>
|
||||||
|
|||||||
Reference in New Issue
Block a user