import { usePrefillDealsWithExcelContext } from "../../../contexts/PrefillDealsWithExcelContext.tsx";
import { Text, Tooltip } from "@mantine/core";
import { IconAlertCircle, IconCircleCheck } from "@tabler/icons-react";

const ParsingResultsTooltip = () => {
    const { errors } = usePrefillDealsWithExcelContext();
    const isError = errors.length !== 0;

    const errorLines = errors.map((error, i) => <Text key={i}>{error}</Text>);
    const tooltipData = isError ? errorLines : "Ошибок при обработке нет";
    const color = isError ? "red" : "grey";

    return (
        <Tooltip
            label={tooltipData}
            multiline
            w={350}
            withArrow
            color={color}
        >
            {isError ? (
                <IconAlertCircle color={"red"}/>
            ) : (
                <IconCircleCheck color={"green"}/>
            )}
        </Tooltip>
    );
};

export default ParsingResultsTooltip;
