ultisuite-client/lib/sidebar-nav-data.ts
2026-05-15 17:40:17 +02:00

103 lines
3.6 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/** Données navigation dossiers / libellés (partagées sidebar + filtre mails). */
import {
buildEmailLabelToSidebarFolderId,
buildFolderIdToLabelRecord,
type FolderTreeNode,
type LabelRowItem,
} from "@/lib/sidebar-nav-maps"
export type { FolderTreeNode, LabelRowItem } from "@/lib/sidebar-nav-maps"
export const folderTree: FolderTreeNode[] = [
{
id: "folder-travail",
label: "Travail",
color: "bg-blue-500",
count: 24,
children: [
{ id: "folder-travail-clients", label: "Clients", color: "bg-blue-400", count: 11 },
{
id: "folder-travail-projets",
label: "Projets",
color: "bg-blue-400",
count: 8,
children: [
{ id: "folder-travail-projets-q1", label: "Q1 2026", color: "bg-sky-400", count: 3 },
{ id: "folder-travail-projets-archive", label: "Archives projets", color: "bg-slate-400", count: 5 },
],
},
{ id: "folder-travail-rh", label: "RH", color: "bg-blue-400", count: 5 },
],
},
{
id: "folder-perso",
label: "Personnel",
color: "bg-emerald-500",
count: 18,
children: [
{ id: "folder-perso-voyages", label: "Voyages", color: "bg-emerald-400", count: 6 },
{ id: "folder-perso-famille", label: "Famille", color: "bg-emerald-400", count: 12 },
],
},
{ id: "folder-factures", label: "Factures", color: "bg-amber-500", count: 42 },
]
export const labelItems: readonly LabelRowItem[] = [
{ id: "imap-sent", label: "[Imap]/Sent", color: "bg-gray-500" },
{ id: "imap-trash", label: "[Imap]/Trash", color: "bg-red-400", count: 4 },
{ id: "browser-alerts", label: "BrowserAlerts", color: "bg-red-400", count: 1 },
{ id: "cctv", label: "CCTV", color: "bg-red-400" },
{ id: "cm-security", label: "CMSecurity Alerts", color: "bg-red-400", count: 14 },
{ id: "twitch", label: "Twitch", color: "bg-purple-500", count: 137 },
]
/** id de ligne sidebar (dossier hiérarchique ou libellé) → libellé Gmail pour matcher `email.labels`. */
export const sidebarNavFolderIdToLabel: Readonly<Record<string, string>> =
buildFolderIdToLabelRecord(folderTree, labelItems)
/** Libellé Gmail (comme dans `email.labels`) → id de ligne sidebar correspondant. */
export const emailLabelToSidebarFolderId: Readonly<Record<string, string>> =
buildEmailLabelToSidebarFolderId(sidebarNavFolderIdToLabel)
/** Libellés navigation (boîtes, catégories latérales) — alignés sur la sidebar. */
const STATIC_NAV_FOLDER_LABELS: Record<string, string> = {
inbox: "Boîte de réception",
starred: "Messages suivis",
snoozed: "En attente",
important: "Important",
sent: "Messages envoyés",
drafts: "Brouillons",
scheduled: "Planifié",
spam: "Indésirables",
purchases: "Achats",
travel: "Déplacements",
social: "Réseaux sociaux",
notifications: "Notifications",
updates: "Mises à jour",
forums: "Forums",
finance: "Finance",
promotions: "Promotions",
}
/** Libellé lisible pour id de ligne (liste vide, messages détat). Dossiers / libellés IMAP viennent de larbre. */
export function getMailNavFolderLabel(
folderId: string,
dynamicFolderIdToLabel?: Record<string, string>
): string {
const fromStatic = STATIC_NAV_FOLDER_LABELS[folderId]
if (fromStatic) return fromStatic
const mapped =
dynamicFolderIdToLabel?.[folderId] ?? sidebarNavFolderIdToLabel[folderId]
if (mapped && mapped !== "scheduled") return mapped
return folderId
}
export function cloneDefaultFolderTree(): FolderTreeNode[] {
return structuredClone(folderTree)
}
export function cloneDefaultLabelRows(): LabelRowItem[] {
return labelItems.map((r) => ({ ...r }))
}