ProfilePage.jsx 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. "use client";
  2. import React from "react";
  3. import { useAuth } from "@/components/auth/authContext";
  4. import ChangePasswordCard from "@/components/profile/ChangePasswordCard";
  5. import {
  6. Card,
  7. CardHeader,
  8. CardTitle,
  9. CardDescription,
  10. CardContent,
  11. } from "@/components/ui/card";
  12. function formatRole(role) {
  13. if (role === "branch") return "Niederlassung";
  14. if (role === "admin") return "Admin";
  15. if (role === "dev") return "Entwicklung";
  16. return role ? String(role) : "Unbekannt";
  17. }
  18. export default function ProfilePage() {
  19. const { status, user } = useAuth();
  20. const isAuthenticated = status === "authenticated" && user;
  21. const roleLabel = isAuthenticated ? formatRole(user.role) : "—";
  22. const branchLabel = isAuthenticated ? user.branchId || "—" : "—";
  23. const emailLabel = isAuthenticated ? user.email || "—" : "—";
  24. const userIdLabel = isAuthenticated ? user.userId || "—" : "—";
  25. return (
  26. <div className="space-y-4">
  27. <div className="space-y-1">
  28. <h1 className="text-2xl font-semibold tracking-tight">Profil</h1>
  29. <p className="text-sm text-muted-foreground">
  30. Konto- und Zugangseinstellungen.
  31. </p>
  32. </div>
  33. <Card>
  34. <CardHeader>
  35. <CardTitle>Konto</CardTitle>
  36. <CardDescription>Aktuelle Sitzungsinformationen.</CardDescription>
  37. </CardHeader>
  38. <CardContent className="grid gap-3 text-sm">
  39. <div className="flex items-center justify-between gap-4">
  40. <span className="text-muted-foreground">Rolle</span>
  41. <span>{roleLabel}</span>
  42. </div>
  43. <div className="flex items-center justify-between gap-4">
  44. <span className="text-muted-foreground">Niederlassung</span>
  45. <span>{branchLabel}</span>
  46. </div>
  47. <div className="flex items-center justify-between gap-4">
  48. <span className="text-muted-foreground">E-Mail</span>
  49. <span className="truncate">{emailLabel}</span>
  50. </div>
  51. <div className="flex items-center justify-between gap-4">
  52. <span className="text-muted-foreground">User ID</span>
  53. <span className="truncate">{userIdLabel}</span>
  54. </div>
  55. <p className="pt-1 text-xs text-muted-foreground">
  56. Die E-Mail wird zentral verwaltet. Für Änderungen wenden Sie sich an
  57. die IT.
  58. </p>
  59. </CardContent>
  60. </Card>
  61. <ChangePasswordCard />
  62. {!isAuthenticated ? (
  63. <p className="text-xs text-muted-foreground">
  64. Hinweis: Profilfunktionen sind nur verfügbar, wenn Sie angemeldet
  65. sind.
  66. </p>
  67. ) : null}
  68. </div>
  69. );
  70. }