- Updated routing for mail settings to redirect to the new settings layout. - Introduced new account layout and section components for better organization. - Replaced hardcoded paths with constants for account and mail settings to enhance maintainability. - Removed deprecated mail settings layout and integrated it into the new settings structure. - Enhanced user experience by streamlining navigation between account and mail settings.
79 lines
2.1 KiB
TypeScript
79 lines
2.1 KiB
TypeScript
import type { LucideIcon } from "lucide-react"
|
|
import { Home, ShieldCheck, Sparkles, UserRound } from "lucide-react"
|
|
|
|
export type CompteSettingsSectionId = "home" | "personal-info" | "security" | "usage-ia"
|
|
|
|
export const ACCOUNT_SETTINGS_BASE_PATH = "/account"
|
|
|
|
export type CompteSettingsNavItem = {
|
|
id: CompteSettingsSectionId
|
|
label: string
|
|
description: string
|
|
href: string
|
|
icon: LucideIcon
|
|
}
|
|
|
|
export const COMPTE_SETTINGS_NAV: CompteSettingsNavItem[] = [
|
|
{
|
|
id: "home",
|
|
label: "Accueil",
|
|
description: "Vue d'ensemble de votre compte Ulti",
|
|
href: ACCOUNT_SETTINGS_BASE_PATH,
|
|
icon: Home,
|
|
},
|
|
{
|
|
id: "personal-info",
|
|
label: "Informations personnelles",
|
|
description: "Nom, adresse e-mail et identifiant",
|
|
href: `${ACCOUNT_SETTINGS_BASE_PATH}/informations`,
|
|
icon: UserRound,
|
|
},
|
|
{
|
|
id: "usage-ia",
|
|
label: "Usage IA",
|
|
description: "Consommation LLM et clés API personnelles",
|
|
href: `${ACCOUNT_SETTINGS_BASE_PATH}/usage-ia`,
|
|
icon: Sparkles,
|
|
},
|
|
{
|
|
id: "security",
|
|
label: "Sécurité",
|
|
description: "Mot de passe, sessions et appareils",
|
|
href: `${ACCOUNT_SETTINGS_BASE_PATH}/securite`,
|
|
icon: ShieldCheck,
|
|
},
|
|
]
|
|
|
|
export function isAccountSettingsPath(pathname: string | null): boolean {
|
|
return (
|
|
pathname === ACCOUNT_SETTINGS_BASE_PATH ||
|
|
pathname?.startsWith(`${ACCOUNT_SETTINGS_BASE_PATH}/`) === true
|
|
)
|
|
}
|
|
|
|
export function isCompteSettingsNavActive(
|
|
pathname: string | null,
|
|
item: CompteSettingsNavItem
|
|
): boolean {
|
|
if (item.href === ACCOUNT_SETTINGS_BASE_PATH) {
|
|
return (
|
|
pathname === ACCOUNT_SETTINGS_BASE_PATH ||
|
|
pathname === `${ACCOUNT_SETTINGS_BASE_PATH}/accueil`
|
|
)
|
|
}
|
|
return (
|
|
pathname === item.href || Boolean(pathname?.startsWith(`${item.href}/`))
|
|
)
|
|
}
|
|
|
|
export function resolveCompteSettingsSection(
|
|
segments: string[] | undefined
|
|
): CompteSettingsSectionId {
|
|
const slug = segments?.[0]
|
|
const match = COMPTE_SETTINGS_NAV.find((item) => {
|
|
if (item.id === "home") return !slug || slug === "accueil"
|
|
return item.href.endsWith(`/${slug}`)
|
|
})
|
|
return match?.id ?? "home"
|
|
}
|