Sidebar: Chat als Unterpunkt von Kunden mit Zahl der ungelesenen Nachrichten
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
717a3323fa
commit
005875d970
7 files changed
+187
-17
No files matched your search
@@ -0,0 +1,31 @@
|
||||
import { formatViewLogTime } from './viewLog'
|
||||
|
||||
// Chat im Ticketsystem: reine Hilfen fuer Liste, Hinweiszeile und Sprechblasen (unter Node testbar).
|
||||
|
||||
/** Ungelesene zuerst, sonst die neueste Unterhaltung oben; die Eingabe bleibt unveraendert. */
|
||||
export function sortChats(chats) {
|
||||
return [...chats].sort((a, b) => {
|
||||
const unread = Number((b.unreadFromCustomer || 0) > 0) - Number((a.unreadFromCustomer || 0) > 0)
|
||||
return unread || String(b.lastAt || '').localeCompare(String(a.lastAt || ''))
|
||||
})
|
||||
}
|
||||
|
||||
/** Ergebnis des Mail-Hinweises an den Kunden (K17), Texte wie im Admin-Panel. */
|
||||
export function noticeText(notice, time) {
|
||||
if (!notice) return ''
|
||||
if (notice.sent) return `E-Mail-Hinweis an ${notice.to} gesendet (${time})`
|
||||
if (notice.reason === 'throttled') return 'Kein neuer E-Mail-Hinweis: Der Kunde wurde in den letzten 15 Minuten schon benachrichtigt.'
|
||||
return `Kein E-Mail-Hinweis: ${notice.reason}`
|
||||
}
|
||||
|
||||
export const lastLine = (chat) => `${chat.lastSender === 'admin' ? 'Du: ' : ''}${chat.lastText || ''}`
|
||||
|
||||
/** Zeile unter der Sprechblase: Absender · dd.mm.yyyy hh:mm */
|
||||
export function messageMeta(msg, customerName) {
|
||||
const who = msg.sender === 'admin' ? msg.senderName || 'Team' : customerName
|
||||
return `${who} · ${formatViewLogTime(msg.createdAt)}`
|
||||
}
|
||||
|
||||
// Signierte Anhang-Links gelten 15 Minuten: den Verlauf nach 10 Minuten komplett neu laden
|
||||
const FULL_REFRESH_MS = 10 * 60 * 1000
|
||||
export const needsFullRefresh = (lastFullAt, now) => now - lastFullAt >= FULL_REFRESH_MS
|
||||
@@ -0,0 +1,23 @@
|
||||
// Eintraege der Sidebar als reine Daten (unter Node testbar); Navbar.jsx ordnet die Icons ueber key zu.
|
||||
// Unterpunkte (children) erscheinen eingerueckt unter ihrem Eintrag, count zeigt eine Zahl (nur > 0).
|
||||
|
||||
export function buildNavLinks({ isAdmin, pulseLevel, chatUnread }) {
|
||||
return [
|
||||
{ key: 'tickets', label: 'Tickets', href: '/tickets' },
|
||||
{ key: 'planboard', label: 'Planboard', href: '/planboard' },
|
||||
{ key: 'projects', label: 'Projekte', href: '/projects' },
|
||||
{ key: 'services', label: 'Services', href: '/services' },
|
||||
{
|
||||
key: 'customers',
|
||||
label: 'Kunden',
|
||||
href: '/customers',
|
||||
children: [{ key: 'chat', label: 'Chat', href: '/customers/chat', count: chatUnread }],
|
||||
},
|
||||
// Leads liegen auf Eis (Lead-Automatik gestoppt 2026-09-30): grau, nicht klickbar
|
||||
{ key: 'leads', label: 'Leads', href: '/leads', paused: true },
|
||||
...(isAdmin ? [{ key: 'finance', label: 'Finanzen', href: '/finance', also: '/finanzen' }] : []),
|
||||
{ key: 'legal', label: 'Rechtliches', href: '/rechtliches' },
|
||||
...(isAdmin ? [{ key: 'serverpuls', label: 'Serverpuls', href: '/serverpuls', dot: pulseLevel }] : []),
|
||||
...(isAdmin ? [{ key: 'admin', label: 'Admin', href: '/admin' }] : []),
|
||||
]
|
||||
}
|
||||
Reference in new issue
Block a user