ProfilePage.jsx 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. "use client";
  2. import React from "react";
  3. import { useAuth } from "@/components/auth/authContext";
  4. import ChangePasswordCard from "@/components/profile/ChangePasswordCard";
  5. import { Button } from "@/components/ui/button";
  6. import { Input } from "@/components/ui/input";
  7. import { Label } from "@/components/ui/label";
  8. import {
  9. Card,
  10. CardHeader,
  11. CardTitle,
  12. CardDescription,
  13. CardContent,
  14. CardFooter,
  15. } from "@/components/ui/card";
  16. function formatRole(role) {
  17. if (role === "branch") return "Niederlassung";
  18. if (role === "admin") return "Admin";
  19. if (role === "dev") return "Entwicklung";
  20. return role ? String(role) : "Unbekannt";
  21. }
  22. export default function ProfilePage() {
  23. const { status, user } = useAuth();
  24. const isAuthenticated = status === "authenticated" && user;
  25. const roleLabel = isAuthenticated ? formatRole(user.role) : "—";
  26. const branchLabel = isAuthenticated ? user.branchId || "—" : "—";
  27. const userIdLabel = isAuthenticated ? user.userId || "—" : "—";
  28. return (
  29. <div className="space-y-4">
  30. <div className="space-y-1">
  31. <h1 className="text-2xl font-semibold tracking-tight">Profil</h1>
  32. <p className="text-sm text-muted-foreground">
  33. Konto- und Zugangseinstellungen.
  34. </p>
  35. </div>
  36. <Card>
  37. <CardHeader>
  38. <CardTitle>Konto</CardTitle>
  39. <CardDescription>Aktuelle Sitzungsinformationen.</CardDescription>
  40. </CardHeader>
  41. <CardContent className="grid gap-3 text-sm">
  42. <div className="flex items-center justify-between gap-4">
  43. <span className="text-muted-foreground">Rolle</span>
  44. <span>{roleLabel}</span>
  45. </div>
  46. <div className="flex items-center justify-between gap-4">
  47. <span className="text-muted-foreground">Niederlassung</span>
  48. <span>{branchLabel}</span>
  49. </div>
  50. <div className="flex items-center justify-between gap-4">
  51. <span className="text-muted-foreground">User ID</span>
  52. <span className="truncate">{userIdLabel}</span>
  53. </div>
  54. </CardContent>
  55. </Card>
  56. <Card>
  57. <CardHeader>
  58. <CardTitle>E-Mail</CardTitle>
  59. <CardDescription>
  60. Die Änderung der E-Mail-Adresse wird in einem späteren Ticket
  61. aktiviert.
  62. </CardDescription>
  63. </CardHeader>
  64. <CardContent className="grid gap-2">
  65. <Label htmlFor="email">E-Mail-Adresse</Label>
  66. <Input
  67. id="email"
  68. type="email"
  69. placeholder="name@firma.de"
  70. disabled
  71. aria-disabled="true"
  72. />
  73. </CardContent>
  74. <CardFooter className="flex justify-end">
  75. <Button
  76. type="button"
  77. disabled
  78. aria-disabled="true"
  79. title="Kommt später"
  80. >
  81. Speichern
  82. </Button>
  83. </CardFooter>
  84. </Card>
  85. <ChangePasswordCard />
  86. {!isAuthenticated ? (
  87. <p className="text-xs text-muted-foreground">
  88. Hinweis: Profilfunktionen sind nur verfügbar, wenn Sie angemeldet
  89. sind.
  90. </p>
  91. ) : null}
  92. </div>
  93. );
  94. }