|
|
@@ -11,6 +11,7 @@ import { useAuth } from "@/components/auth/authContext";
|
|
|
import { logout } from "@/lib/frontend/apiClient";
|
|
|
import { buildLoginUrl, LOGIN_REASONS } from "@/lib/frontend/authRedirect";
|
|
|
import { canManageUsers as canManageUsersRole } from "@/lib/frontend/auth/roles";
|
|
|
+import { buildSupportMailto } from "@/lib/frontend/support/supportMailto";
|
|
|
|
|
|
import { Button } from "@/components/ui/button";
|
|
|
import {
|
|
|
@@ -35,63 +36,6 @@ function formatRole(role) {
|
|
|
return role ? String(role) : "Unbekannt";
|
|
|
}
|
|
|
|
|
|
-function buildSupportMailto({ user, currentUrl, pathname, userAgent }) {
|
|
|
- const to = "info@attus.de";
|
|
|
-
|
|
|
- const roleLabel = user ? formatRole(user.role) : "Unbekannt";
|
|
|
- const userLabel = user?.branchId
|
|
|
- ? `${roleLabel} (${user.branchId})`
|
|
|
- : roleLabel;
|
|
|
-
|
|
|
- const now = new Date();
|
|
|
- const tz =
|
|
|
- typeof Intl !== "undefined"
|
|
|
- ? Intl.DateTimeFormat().resolvedOptions().timeZone
|
|
|
- : "";
|
|
|
-
|
|
|
- const timestampLocal = now.toLocaleString("de-DE");
|
|
|
- const timestampIso = now.toISOString();
|
|
|
-
|
|
|
- const routeLine = pathname ? `Route: ${pathname}` : "Route: (unbekannt)";
|
|
|
- const urlLine = currentUrl ? `URL: ${currentUrl}` : "URL: (bitte einfügen)";
|
|
|
- const uaLine = userAgent
|
|
|
- ? `User-Agent: ${userAgent}`
|
|
|
- : "User-Agent: (unbekannt)";
|
|
|
- const timeLine = tz
|
|
|
- ? `Zeitpunkt: ${timestampLocal} (${tz})`
|
|
|
- : `Zeitpunkt: ${timestampLocal}`;
|
|
|
- const isoLine = `ISO: ${timestampIso}`;
|
|
|
-
|
|
|
- const subject = user?.branchId
|
|
|
- ? `Support – RHL Lieferscheine (${user.branchId})`
|
|
|
- : "Support – RHL Lieferscheine";
|
|
|
-
|
|
|
- const body = [
|
|
|
- "Hallo attus Support,",
|
|
|
- "",
|
|
|
- "bitte beschreibt hier kurz das Anliegen:",
|
|
|
- "",
|
|
|
- "- Was wollten Sie tun?",
|
|
|
- "- Was ist passiert?",
|
|
|
- "- (Optional) Screenshot / Zeitpunkt",
|
|
|
- "",
|
|
|
- "--- Kontext (bitte drin lassen) ---",
|
|
|
- `Benutzer: ${userLabel}`,
|
|
|
- routeLine,
|
|
|
- urlLine,
|
|
|
- timeLine,
|
|
|
- isoLine,
|
|
|
- uaLine,
|
|
|
- "----------------------------------",
|
|
|
- "",
|
|
|
- "Vielen Dank.",
|
|
|
- ].join("\r\n");
|
|
|
-
|
|
|
- return `mailto:${to}?subject=${encodeURIComponent(subject)}&body=${encodeURIComponent(
|
|
|
- body,
|
|
|
- )}`;
|
|
|
-}
|
|
|
-
|
|
|
export default function UserStatus() {
|
|
|
const pathname = usePathname() || "/";
|
|
|
const { status, user } = useAuth();
|