ProfilePage.jsx 3.1 KB

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