import { useEffect, useMemo } from 'react'; import { CopyFeedbackButton } from './CopyFeedbackButton'; import { PlatformInfoBlock } from './PlatformInfoBlock'; import { UnifiedModal } from './UnifiedModal'; import { useCopyFeedback } from './useCopyFeedback'; export type PlatformReportDialogField = { label: string; value: string; multiline?: boolean; }; type PlatformReportDialogProps = { open: boolean; title: string; onClose: () => void; copyIdleLabel: string; fields: readonly PlatformReportDialogField[]; overlayClassName?: string; panelClassName?: string; }; function buildPlatformReportText(fields: readonly PlatformReportDialogField[]) { return fields.map((field) => `${field.label}:${field.value}`).join('\n'); } export function PlatformReportDialog({ open, title, onClose, copyIdleLabel, fields, overlayClassName = 'platform-theme platform-theme--light !items-center', panelClassName = 'platform-remap-surface rounded-[1.5rem]', }: PlatformReportDialogProps) { const { copyState, copyText, resetCopyState } = useCopyFeedback(); const reportText = useMemo(() => buildPlatformReportText(fields), [fields]); useEffect(() => { resetCopyState(); }, [open, reportText, resetCopyState]); const copyReport = () => { if (!reportText) { return; } void copyText(reportText); }; return ( } > {open ? fields.map((field) => ( {field.value} )) : null} ); }