import { Card, Col, Row, Space } from 'antd'; import React from 'react'; import { overviewConfigs } from '../config'; import '../styles/index.less'; import styles from './over-view.less'; const renderCardItem = (data: { label: string; value: React.ReactNode; bgColor: string; }) => { const { label, value, bgColor } = data; return (
{label}
{value}
); }; const Overview: React.FC = (props) => { // const { data = {} } = props; const data = { workers: 8, models: { healthy: 10, warning: 2, error: 1 }, gpus: 30, allocatedGpus: 12, instances: { healthy: 32, warning: 3, error: 2 } }; const renderValue = ( value: | number | { healthy: number; warning: number; error: number; } ) => { if (typeof value === 'number') { return value; } return ( {value.healthy} {value.warning} {value.error} ); }; return (
{overviewConfigs.map((config, index) => ( {renderCardItem({ label: config.label, value: renderValue(data[config.key] || 0), bgColor: config.backgroundColor })} ))}
); }; export default Overview;