"use client"
import { useEffect, useRef } from "react"
import { ChevronDown, Lock } from "lucide-react"
import {
Popover,
PopoverContent,
PopoverTrigger,
} from "@/components/ui/popover"
import { MailDateText } from "@/components/gmail/mail-date-text"
import type { MessageHeaderDetails } from "@/lib/mail-message-header-details"
import { UnsubscribeActionButton } from "@/components/gmail/email-view/unsubscribe-action-button"
import { cn } from "@/lib/utils"
function DetailRow({
label,
children,
}: {
label: string
children: React.ReactNode
}) {
return (
<>
{label}
{children}
>
)
}
export function EmailViewDetailsPopover({
summary,
details,
open,
onOpenChange,
isSpam,
messageId,
}: {
summary: string
details: MessageHeaderDetails
open: boolean
onOpenChange: (open: boolean) => void
isSpam?: boolean
messageId: string
}) {
const leaveTimerRef = useRef | null>(null)
const clearLeaveTimer = () => {
if (leaveTimerRef.current) {
clearTimeout(leaveTimerRef.current)
leaveTimerRef.current = null
}
}
const scheduleClose = () => {
clearLeaveTimer()
leaveTimerRef.current = setTimeout(() => onOpenChange(false), 150)
}
const keepOpen = () => {
clearLeaveTimer()
}
useEffect(() => () => clearLeaveTimer(), [])
useEffect(() => {
if (!open) clearLeaveTimer()
}, [open])
return (
e.stopPropagation()}
onPointerDownOutside={() => onOpenChange(false)}
onInteractOutside={() => onOpenChange(false)}
onEscapeKeyDown={() => onOpenChange(false)}
onMouseEnter={keepOpen}
onMouseLeave={scheduleClose}
>
{details.fromLine}
{details.replyToLine ? (
{details.replyToLine}
) : null}
{details.toLine}
{details.subject}
{details.mailedBy ? (
{details.mailedBy}
) : null}
{details.signedBy ? (
{details.signedBy}
) : null}
{details.unsubscribe ? (
<>
- se désabonner :
-
>
) : null}
- sécurité :
-
{details.dkimPass === true ? (
Signature DKIM conforme
) : details.dkimPass === false ? (
Signature DKIM non conforme
) : null}
{details.tls ? (
Chiffrement standard (TLS)
) : null}
Chiffrement PGP : non disponible pour l'instant
{isSpam ? (
Ce message est marqué comme spam
) : null}
)
}