import { FC } from 'react'; import { Theme, Typography, CircularProgress } from '@mui/material'; import { useTranslation } from 'react-i18next'; import type { InsertStatusProps } from './Types'; import successPath from '@/assets/imgs/insert/success.png'; import failPath from '@/assets/imgs/insert/fail.png'; import { InsertStatusEnum } from './consts'; import Box from '@mui/material/Box'; const InsertStatus: FC = ({ status, failMsg }) => { const { t: insertTrans } = useTranslation('insert'); const textSx = (theme: Theme) => ({ marginTop: theme.spacing(3) }); const loadingTipSx = (theme: Theme) => ({ marginBottom: theme.spacing(6) }); const loadingSvgSx = (theme: Theme) => ({ color: theme.palette.primary.main, }); const wrapperSx = (theme: Theme) => ({ width: '75vw', height: status === InsertStatusEnum.loading ? '288px' : '200px', display: 'flex', flexDirection: 'column', alignItems: 'center', justifyContent: 'center', }); const InsertSuccess = () => ( <> insert success {insertTrans('statusSuccess')} ); const InsertLoading = () => ( <> {insertTrans('statusLoading')} ({ ...textSx(theme), ...loadingTipSx(theme) })} > {insertTrans('statusLoadingTip')} ); const InsertError = () => ( <> insert error {insertTrans('statusError')} {failMsg && {failMsg}} ); const generateStatus = (status: InsertStatusEnum) => { switch (status) { case InsertStatusEnum.loading: return ; case InsertStatusEnum.success: return ; // status error or init as default default: return ; } }; return ( {generateStatus(status)} ); }; export default InsertStatus;