import { Modal, ModalOverlay, ModalContent, ModalCloseButton, ModalBody, Stack, Heading, Text, HStack, } from '@chakra-ui/react' import { useResults } from 'contexts/ResultsProvider' import React from 'react' import { HeaderIcon } from 'services/typebots/results' import { isDefined } from 'utils' type Props = { resultIdx: number | null onClose: () => void } export const ResultModal = ({ resultIdx, onClose }: Props) => { const { tableData, resultHeader } = useResults() const result = isDefined(resultIdx) ? tableData[resultIdx] : undefined const getHeaderValue = ( val: string | { plainText: string; element?: JSX.Element | undefined } ) => (typeof val === 'string' ? val : val.element ?? val.plainText) return ( {resultHeader.map((header) => result && result[header.label] ? ( {header.label} {getHeaderValue(result[header.label])} ) : ( <> ) )} ) }