import type { TrainStepOutput } from '@/service/train'; import { getStepOutputContent } from '@/service/train'; import { Modal, Table } from 'antd'; import { useEffect, useState } from 'react'; import { Prism as SyntaxHighlighter } from 'react-syntax-highlighter'; import { tomorrow } from 'react-syntax-highlighter/dist/cjs/styles/prism'; export interface IStepOutputInfo { path?: string; stepName: string; } interface IProps { handleClose: () => void; stepOutputInfo?: IStepOutputInfo; } const TrainExposureModel = (props: IProps) => { const { handleClose, stepOutputInfo } = props; const [outputContent, setOutputContent] = useState(null); const [loading, setLoading] = useState(true); useEffect(() => { if (!stepOutputInfo?.stepName) return; setOutputContent(null); setLoading(true); getStepOutputContent(stepOutputInfo.stepName) .then((res) => { if (res.data.code == 0) { const data = res.data.data; setOutputContent(data); } else { console.error(res.data.message); } }) .finally(() => { setLoading(false); }); }, [stepOutputInfo?.stepName]); const renderOutputContent = () => { if (loading) { return (

loading...

); } if (!outputContent) return 'There are no resources for this step at this time'; if (outputContent.file_type == 'json') { const showContent = JSON.stringify(outputContent.content, null, 2); return ( {showContent} ); } if (outputContent.file_type == 'parquet') { const columns = outputContent.columns.map((item, index) => ({ title: item, dataIndex: item, key: index })); const data = outputContent.content; return ( ); } return 'There are no resources for this step at this time'; }; return (
{stepOutputInfo?.path && (
{`path: ${stepOutputInfo.path}`}
)}
{renderOutputContent()}
); }; export default TrainExposureModel;