// @mui import { Button, Box, Stepper, Step, StepLabel, Card, Typography, Divider, Stack, CircularProgress, } from '@mui/material'; import { Add } from '@mui/icons-material'; // components import MuiDialog from '../../components/MuiDialog'; // theme import palette from '../../theme/palette'; // React import { ReactElement, useEffect, useState } from 'react'; import { fDate } from '@/utils/formatTime'; import { addMinutes, format } from 'date-fns'; import { LoadingButton } from '@mui/lab'; type DataContent = { claim: object; isLoading: boolean; handleDownloadLog: void; }; type MuiDialogProps = { title?: { name?: string; icon?: string; }; openDialog: boolean; setOpenDialog: Function; content?: ReactElement; data?: DataContent[]; }; const steps = ['Review', 'Approval', 'Disbursement']; const DialogDetailClaim = ({ title, openDialog, setOpenDialog, data }: MuiDialogProps) => { const claim = data.claim ?? null; // --------------------------------------------- // Step const [currentStep, setCurrentStep] = useState(0); useEffect( function () { if (claim?.status == 'requested') { setCurrentStep(0); } if (claim?.status == 'approved') { setCurrentStep(1); } if (claim?.status == 'closed') { setCurrentStep(2); } }, [data] ); // ---------------------------------------------------- // Download LOG const [loadingDownloadLog, setLoadingDownloadLog] = useState(false) const handleDownloadLog = async (claimRequest) => { setLoadingDownloadLog(true) await data.handleDownloadLog(claimRequest).then(() => { setLoadingDownloadLog(false) }) } const getContent = () => ( <> {data.isLoading && ( )} {!data.isLoading && ( <> Claim Request Submission date {/* {JSON.stringify(data)} */} {claim && fDate(claim.created_at)} {steps.map((label) => ( {label} ))} { claim.status == 'approved' && ( } fullWidth // sx={{ typography: 'subtitle2', borderColor: '#F5F5F5' }} onClick={() => {handleDownloadLog(claim)}} > Upload Invoice )} {fDate(claim.created_at)} {/* Download LOG */} {claim.status == 'approved' && ( {format( addMinutes( new Date(claim.created_at), 15 //Math.floor(Math.random() * (20 - 15 + 1)) + 15 ), 'HH:mm' )}{' '} WIB Approved } fullWidth // sx={{ typography: 'subtitle2', borderColor: '#F5F5F5' }} onClick={() => {handleDownloadLog(claim)}} > Download Guarantee Letter )} {/* Item 1 */} {claim.status == 'requested' && ( 09:10 WIB Approval Details : mohon melengkapi kekurangan dokumen Lab pemeriksaan darah )} {/* Item 2 */} {/* // TODO sementara tanggal random */} {format( addMinutes( new Date(claim.created_at), 10// Math.floor(Math.random() * (15 - 5 + 1)) + 5 ), 'HH:mm' )}{' '} WIB Approval Details : Penilaian Dokter {/* Item 3 */} {fDate(claim.created_at, 'HH:mm')} WIB Review Details : Klaim Diajukan )} ); return ( ); }; export default DialogDetailClaim;