supportMailto.js 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. function formatRole(role) {
  2. if (role === "branch") return "Niederlassung";
  3. if (role === "admin") return "Admin";
  4. if (role === "superadmin") return "Superadmin";
  5. if (role === "dev") return "Entwicklung";
  6. return role ? String(role) : "Unbekannt";
  7. }
  8. export function buildSupportMailto({ user, currentUrl, pathname, userAgent }) {
  9. const to = "info@attus.de";
  10. const roleLabel = user ? formatRole(user.role) : "Unbekannt";
  11. const userLabel = user?.branchId
  12. ? `${roleLabel} (${user.branchId})`
  13. : roleLabel;
  14. const now = new Date();
  15. const tz =
  16. typeof Intl !== "undefined"
  17. ? Intl.DateTimeFormat().resolvedOptions().timeZone
  18. : "";
  19. const timestampLocal = now.toLocaleString("de-DE");
  20. const timestampIso = now.toISOString();
  21. const routeLine = pathname ? `Route: ${pathname}` : "Route: (unbekannt)";
  22. const urlLine = currentUrl ? `URL: ${currentUrl}` : "URL: (bitte einfügen)";
  23. const uaLine = userAgent
  24. ? `User-Agent: ${userAgent}`
  25. : "User-Agent: (unbekannt)";
  26. const timeLine = tz
  27. ? `Zeitpunkt: ${timestampLocal} (${tz})`
  28. : `Zeitpunkt: ${timestampLocal}`;
  29. const isoLine = `ISO: ${timestampIso}`;
  30. const subject = user?.branchId
  31. ? `Support – RHL Lieferscheine (${user.branchId})`
  32. : "Support – RHL Lieferscheine";
  33. const body = [
  34. "Hallo attus Support,",
  35. "",
  36. "bitte beschreibt hier kurz das Anliegen:",
  37. "",
  38. "- Was wollten Sie tun?",
  39. "- Was ist passiert?",
  40. "- (Optional) Screenshot / Zeitpunkt",
  41. "",
  42. "--- Kontext (bitte drin lassen) ---",
  43. `Benutzer: ${userLabel}`,
  44. routeLine,
  45. urlLine,
  46. timeLine,
  47. isoLine,
  48. uaLine,
  49. "----------------------------------",
  50. "",
  51. "Vielen Dank.",
  52. ].join("\r\n");
  53. return `mailto:${to}?subject=${encodeURIComponent(subject)}&body=${encodeURIComponent(
  54. body,
  55. )}`;
  56. }