change dialog history in loan history page
This commit is contained in:
@@ -19,21 +19,17 @@ const PrintHistory = ({attachment}) => {
|
||||
}
|
||||
|
||||
|
||||
return (
|
||||
<Button
|
||||
color="primary"
|
||||
variant="contained"
|
||||
size="small"
|
||||
disabled={loading}
|
||||
sx={{textTransform: "unset", alignSelf: "center"}}
|
||||
startIcon={loading ?
|
||||
<CircularProgress size={18} color="inherit"/> :
|
||||
<DescriptionIcon/>}
|
||||
onClick={() => clickHandler(attachment)}
|
||||
>
|
||||
{t("LoanHistory.history_report")}
|
||||
</Button>
|
||||
)
|
||||
return (<Button
|
||||
color="primary"
|
||||
variant="contained"
|
||||
size="small"
|
||||
disabled={loading}
|
||||
sx={{textTransform: "unset", alignSelf: "center", mx: .25}}
|
||||
startIcon={loading ? <CircularProgress size={18} color="inherit"/> : <DescriptionIcon/>}
|
||||
onClick={() => clickHandler(attachment.file)}
|
||||
>
|
||||
{attachment.title}
|
||||
</Button>)
|
||||
}
|
||||
|
||||
export default PrintHistory
|
||||
@@ -33,79 +33,77 @@ const TableContent = ({rowId}) => {
|
||||
})
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<Box>
|
||||
return (<Box>
|
||||
{error ? (<Typography sx={{
|
||||
padding: 2,
|
||||
display: "flex",
|
||||
alignItems: "center",
|
||||
justifyContent: "center"
|
||||
}}>{t("LoanHistory.Table_history_error")}</Typography>) :
|
||||
(isLoading ? (<LinearProgress sx={{width: "100%"}}/>) : (
|
||||
historyDetails.latest_histories.length === 0 ? (
|
||||
<Typography
|
||||
sx={{
|
||||
padding: 2,
|
||||
display: "flex",
|
||||
alignItems: "center",
|
||||
justifyContent: "center"
|
||||
}}
|
||||
variant={'h6'}>{t("LoanHistory.empty_history_detail")}</Typography>
|
||||
) : (
|
||||
<Paper elevation={0} sx={{
|
||||
width: '100%', overflow: 'hidden',
|
||||
'*::-webkit-scrollbar': {
|
||||
width: '0.5em'
|
||||
},
|
||||
'*::-webkit-scrollbar-thumb': {
|
||||
backgroundColor: 'primary.main',
|
||||
}
|
||||
}}>
|
||||
<TableContainer sx={{maxHeight: 600}}>
|
||||
<Table stickyHeader sx={{minWidth: 650}}>
|
||||
<TableHead>
|
||||
<TableRow>
|
||||
<TableCell>{t("LoanHistory.Table_head_name")}</TableCell>
|
||||
<TableCell>{t("LoanHistory.Table_head_date")}</TableCell>
|
||||
<TableCell>{t("LoanHistory.Table_head_position")}</TableCell>
|
||||
<TableCell>{t("LoanHistory.Table_head_action")}</TableCell>
|
||||
<TableCell>{t("LoanHistory.Table_head_expert_description")}</TableCell>
|
||||
<TableCell>{t("LoanHistory.Table_head_file")}</TableCell>
|
||||
</TableRow>
|
||||
</TableHead>
|
||||
<TableBody>
|
||||
{
|
||||
historyDetails.latest_histories.map((latest_history, index) => {
|
||||
return (
|
||||
<TableRow
|
||||
key={index}
|
||||
sx={{
|
||||
'&:last-child td, &:last-child th': {border: 0}
|
||||
}}
|
||||
>
|
||||
<TableCell>
|
||||
{latest_history.expert.name}
|
||||
</TableCell>
|
||||
<TableCell>{moment(latest_history.created_at).locale("fa").format("HH:mm | yyyy/MM/DD")}</TableCell>
|
||||
<TableCell>{latest_history.expert.position}</TableCell>
|
||||
<TableCell>{latest_history.previous_state_name}</TableCell>
|
||||
<TableCell>{latest_history.expert_description}</TableCell>
|
||||
<TableCell>
|
||||
{latest_history.attachment ? (
|
||||
<PrintHistory attachment={latest_history.attachment}/>
|
||||
) : null}
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
)
|
||||
})
|
||||
}
|
||||
</TableBody>
|
||||
</Table>
|
||||
</TableContainer>
|
||||
</Paper>
|
||||
)
|
||||
))
|
||||
}
|
||||
padding: 2, display: "flex", alignItems: "center", justifyContent: "center"
|
||||
}}>{t("LoanHistory.Table_history_error")}</Typography>) : (isLoading ? (
|
||||
<LinearProgress sx={{width: "100%"}}/>) : (historyDetails.latest_histories.length === 0 ? (<Typography
|
||||
sx={{
|
||||
padding: 2, display: "flex", alignItems: "center", justifyContent: "center"
|
||||
}}
|
||||
variant={'h6'}>{t("LoanHistory.empty_history_detail")}</Typography>) : (<Paper elevation={0} sx={{
|
||||
width: '100%', overflow: 'hidden', '*::-webkit-scrollbar': {
|
||||
width: '0.5em'
|
||||
}, '*::-webkit-scrollbar-thumb': {
|
||||
backgroundColor: 'primary.main',
|
||||
}
|
||||
}}>
|
||||
<TableContainer sx={{maxHeight: 600}}>
|
||||
<Table stickyHeader sx={{minWidth: 800}}>
|
||||
<TableHead>
|
||||
<TableRow>
|
||||
<TableCell>{t("LoanHistory.Table_head_name")}</TableCell>
|
||||
<TableCell>{t("LoanHistory.Table_head_date")}</TableCell>
|
||||
<TableCell>{t("LoanHistory.Table_head_position")}</TableCell>
|
||||
<TableCell>{t("LoanHistory.Table_head_action")}</TableCell>
|
||||
<TableCell>{t("LoanHistory.Table_head_expert_description")}</TableCell>
|
||||
<TableCell>{t("LoanHistory.Table_head_file")}</TableCell>
|
||||
</TableRow>
|
||||
</TableHead>
|
||||
<TableBody>
|
||||
<TableRow
|
||||
sx={{
|
||||
'&:last-child td, &:last-child th': {border: 0}
|
||||
}}
|
||||
>
|
||||
<TableCell>
|
||||
{historyDetails.latest_histories[0].expert.name}
|
||||
</TableCell>
|
||||
<TableCell>{moment(historyDetails.latest_histories[0].created_at).locale("fa").format("HH:mm | yyyy/MM/DD")}</TableCell>
|
||||
<TableCell>{historyDetails.latest_histories[0].expert.position}</TableCell>
|
||||
<TableCell>{historyDetails.state_name}</TableCell>
|
||||
<TableCell>{historyDetails.latest_histories[0].expert_description}</TableCell>
|
||||
<TableCell>
|
||||
{historyDetails.latest_histories[0].attachments.map(attachment => <PrintHistory
|
||||
attachment={attachment}/>)}
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
{historyDetails.latest_histories.map((latest_history, index) => {
|
||||
const _name = historyDetails.latest_histories.length > (index + 1) ? historyDetails.latest_histories[index + 1].expert.name : '-'
|
||||
const _created_at = historyDetails.latest_histories.length > (index + 1) ? moment(historyDetails.latest_histories[index + 1].created_at).locale("fa").format("HH:mm | yyyy/MM/DD") : '-'
|
||||
const _position = historyDetails.latest_histories.length > (index + 1) ? historyDetails.latest_histories[index + 1].expert.position : '-'
|
||||
const _expert_description = historyDetails.latest_histories.length > (index + 1) ? historyDetails.latest_histories[index + 1].expert_description : '-'
|
||||
const _attachments = historyDetails.latest_histories.length > (index + 1) ? historyDetails.latest_histories[index + 1].attachments : []
|
||||
return (<TableRow
|
||||
key={index}
|
||||
sx={{
|
||||
'&:last-child td, &:last-child th': {border: 0}
|
||||
}}
|
||||
>
|
||||
<TableCell> {_name}</TableCell>
|
||||
<TableCell>{_created_at}</TableCell>
|
||||
<TableCell>{_position}</TableCell>
|
||||
<TableCell>{latest_history.previous_state_name}</TableCell>
|
||||
<TableCell>{_expert_description}</TableCell>
|
||||
<TableCell>
|
||||
{_attachments.map(attachment => <PrintHistory attachment={attachment}/>)}
|
||||
</TableCell>
|
||||
</TableRow>)
|
||||
})}
|
||||
</TableBody>
|
||||
</Table>
|
||||
</TableContainer>
|
||||
</Paper>)))}
|
||||
</Box>
|
||||
|
||||
)
|
||||
|
||||
@@ -19,7 +19,7 @@ const History = ({rowId, mutate}) => {
|
||||
<HistoryIcon/>
|
||||
</IconButton>
|
||||
</Tooltip>
|
||||
<Dialog scroll={'paper'} fullWidth maxWidth='lg' open={openConfirmDialog}
|
||||
<Dialog scroll={'paper'} fullWidth maxWidth="xl" open={openConfirmDialog}
|
||||
PaperProps={{sx: {boxShadow: 'rgba(60, 64, 67, 0.3) 0px 1px 16px 0px, rgba(60, 64, 67, 0.15) 0px 1px 10px 0px'}}}>
|
||||
<DialogTitle>{t("LoanHistory.history")}</DialogTitle>
|
||||
<HistoryContent mutate={mutate} rowId={rowId} setOpenConfirmDialog={setOpenConfirmDialog}/>
|
||||
|
||||
Reference in New Issue
Block a user