"use client"
import { useMemo } from "react"
import { useTheme } from "next-themes"
import { ExternalLink } from "lucide-react"
import { Button } from "@/components/ui/button"
import { CompteSettingsCard } from "@/components/compte/compte-settings-card"
import {
buildAuthentikUrl,
resolveAuthentikTheme,
type AuthentikUserSettingsTab,
} from "@/lib/auth/authentik-user-url"
import { useMailSettingsStore } from "@/lib/stores/mail-settings-store"
type CompteAuthentikPanelProps = {
title: string
description: string
tab?: AuthentikUserSettingsTab
flowSlug?: string
actionLabel: string
icon?: React.ReactNode
}
export function CompteAuthentikPanel({
title,
description,
tab,
flowSlug,
actionLabel,
icon,
}: CompteAuthentikPanelProps) {
const themeMode = useMailSettingsStore((s) => s.themeMode)
const { resolvedTheme } = useTheme()
const authentikTheme = resolveAuthentikTheme(themeMode, resolvedTheme)
const url = useMemo(
() => buildAuthentikUrl({ tab, flowSlug, theme: authentikTheme }),
[tab, flowSlug, authentikTheme]
)
if (!url) {
return (
Portail d'identité non configuré.
Ouverture du portail d'identité Authentik dans un nouvel onglet.
{description}