ProfilePage.jsx 2.5 KB

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