Skip to content

Commit

Permalink
refactor: enhance audit log viewer ui
Browse files Browse the repository at this point in the history
  • Loading branch information
hamed-valiollahi committed Nov 14, 2024
1 parent 9ec7770 commit c65b351
Showing 1 changed file with 54 additions and 15 deletions.
69 changes: 54 additions & 15 deletions frontend/src/views/Admin/AdminMenu/components/ViewAuditLog.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
Typography
} from '@mui/material'
import { useTranslation } from 'react-i18next'
import colors from '@/themes/base/colors'

export const ViewAuditLog = () => {
const { auditLogId } = useParams()
Expand Down Expand Up @@ -64,37 +65,63 @@ export const ViewAuditLog = () => {

{/* Display the additional information */}
<Box mb={2}>
<Typography variant="body1">
<Typography variant="body2">
<strong>{t('auditLogColLabels.tableName')}:</strong> {tableName}
</Typography>
<Typography variant="body1">
<Typography variant="body2">
<strong>{t('auditLogColLabels.operation')}:</strong> {operation}
</Typography>
<Typography variant="body1">
<Typography variant="body2">
<strong>{t('auditLogColLabels.rowId')}:</strong> {rowId}
</Typography>
<Typography variant="body1">
<Typography variant="body2">
<strong>{t('auditLogColLabels.createDate')}:</strong>{' '}
{new Date(createDate).toLocaleString()}
</Typography>
<Typography variant="body1">
<Typography variant="body2">
<strong>{t('auditLogColLabels.userId')}:</strong>{' '}
{createUser || t('System')}
</Typography>
</Box>

<TableContainer component={Paper}>
<Table>
<TableHead>
<Table
sx={{
'& td, & th': {
borderRight: '1px solid #ccc',
borderBottom: '1px solid #ccc'
},
'& td:last-child, & th:last-child': {
borderRight: 'none'
},
'& tr:last-child td': {
borderBottom: 'none'
}
}}
>
<TableHead sx={{ textAlign: 'center' }}>
<TableRow>
<TableCell>
<strong>{t('Field')}</strong>
<TableCell
sx={{
width: '20%',
fontWeight: 'bold',
whiteSpace: 'nowrap'
}}
bgcolor={colors.background.grey}
>
{t('Field')}
</TableCell>
<TableCell>
<strong>{t('OldValue')}</strong>
<TableCell
sx={{ width: '40%', fontWeight: 'bold' }}
bgcolor={colors.background.grey}
>
{t('OldValue')}
</TableCell>
<TableCell>
<strong>{t('NewValue')}</strong>
<TableCell
sx={{ width: '40%', fontWeight: 'bold' }}
bgcolor={colors.background.grey}
>
{t('NewValue')}
</TableCell>
</TableRow>
</TableHead>
Expand All @@ -119,8 +146,20 @@ export const ViewAuditLog = () => {
style={operation === 'UPDATE' ? fieldRowStyle : rowStyle}
>
<TableCell>{field}</TableCell>
<TableCell>{formatValue(oldValue)}</TableCell>
<TableCell>{formatValue(newValue)}</TableCell>
<TableCell>
{isChanged ? (
<strong>{formatValue(oldValue)}</strong>
) : (
formatValue(oldValue)
)}
</TableCell>
<TableCell>
{isChanged ? (
<strong>{formatValue(newValue)}</strong>
) : (
formatValue(newValue)
)}
</TableCell>
</TableRow>
)
})}
Expand Down

0 comments on commit c65b351

Please sign in to comment.