import React, { useState } from "react"; import { Box, Text, useInput } from "ink"; import { useTerminalTheme } from "../hooks/useTerminalTheme"; export type TErrorAction = { label: string }; export function ErrorPanel(props: { title: string; message: string; suggestions?: string[]; technicalDetails?: string; }) { const theme = useTerminalTheme(); const [expanded, setExpanded] = useState(false); useInput((_input, key) => { if (key.return && props.technicalDetails) { setExpanded((current) => !current); } }); return ( {props.title} {props.message} {props.suggestions && props.suggestions.length > 0 ? ( Try: {props.suggestions.map((suggestion) => ( {" • "}{suggestion} ))} ) : null} {props.technicalDetails ? ( {expanded ? "Technical details (Enter to collapse):" : "Press Enter for technical details"} {expanded ? {props.technicalDetails} : null} ) : null} ); }