Skip to content

Commit

Permalink
fix(administration): cpe crashes when viewing some user details
Browse files Browse the repository at this point in the history
  • Loading branch information
rhahao authored Jun 17, 2023
1 parent 9cef0b6 commit f01da28
Showing 1 changed file with 66 additions and 66 deletions.
132 changes: 66 additions & 66 deletions src/features/congregationPersons/CongregationPersonPocketDevice.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,78 +9,78 @@ import Paper from '@mui/material/Paper';
import Typography from '@mui/material/Typography';

const CongregationPersonPocketDevice = ({ device, handleDeleteDevice }) => {
const { t } = useTranslation('ui');
const { t } = useTranslation('ui');

const formatLastSeen = (last_seen) => {
return last_seen ? dateFormat(new Date(last_seen), t('shortDateTimeFormat')) : '';
};
const formatLastSeen = (last_seen) => {
return last_seen ? dateFormat(new Date(last_seen), t('shortDateTimeFormat')) : '';
};

const getInfoIP = () => {
if (!device.visitor_details) return '';
const getInfoIP = () => {
if (!device.visitor_details) return '';

let result = device.visitor_details.ip;
let result = device.visitor_details.ip;

if (device.visitor_details.ipLocation?.country_name) {
result += ` - ${device.visitor_details.ipLocation.country_name}`;
}
if (device.visitor_details.ipLocation?.country_name) {
result += ` - ${device.visitor_details.ipLocation.country_name}`;
}

return result;
};
return result;
};

return (
<Grid item key={device.visitorid} xs={12} md={6}>
<Paper elevation={8} sx={{ padding: '10px' }}>
<Box
sx={{
display: 'flex',
alignItems: 'center',
justifyContent: 'space-between',
flexWrap: 'wrap',
gap: '20px',
}}
>
<Box
sx={{
display: 'flex',
alignItems: 'center',
}}
>
<DevicesIcon
sx={{
fontSize: '60px',
marginRight: '10px',
color: '#1976d2',
}}
/>
<Box sx={{ display: 'flex', flexDirection: 'column', gap: '5px' }}>
<Typography sx={{ fontSize: '18px', fontWeight: 'bold' }}>{`IP: ${getInfoIP()}`}</Typography>
<Typography>{device.visitor_details.browser || ''}</Typography>
<Box>
<Chip
label={formatLastSeen(device.sws_last_seen)}
sx={{
backgroundColor: '#1976d2',
color: 'white',
fontWeight: 'bold',
}}
/>
</Box>
</Box>
</Box>
<Box sx={{ display: 'flex', flexGrow: 1, justifyContent: 'flex-end' }}>
<Button
variant="outlined"
color="error"
sx={{ marginBottom: '10px' }}
onClick={() => handleDeleteDevice(device.visitorid)}
>
{t('sessionRevoke')}
</Button>
</Box>
</Box>
</Paper>
</Grid>
);
return (
<Grid item key={device.visitorid} xs={12} md={6}>
<Paper elevation={8} sx={{ padding: '10px' }}>
<Box
sx={{
display: 'flex',
alignItems: 'center',
justifyContent: 'space-between',
flexWrap: 'wrap',
gap: '20px',
}}
>
<Box
sx={{
display: 'flex',
alignItems: 'center',
}}
>
<DevicesIcon
sx={{
fontSize: '60px',
marginRight: '10px',
color: '#1976d2',
}}
/>
<Box sx={{ display: 'flex', flexDirection: 'column', gap: '5px' }}>
<Typography sx={{ fontSize: '18px', fontWeight: 'bold' }}>{`IP: ${getInfoIP()}`}</Typography>
<Typography>{device.visitor_details?.browser || ''}</Typography>
<Box>
<Chip
label={formatLastSeen(device.sws_last_seen)}
sx={{
backgroundColor: '#1976d2',
color: 'white',
fontWeight: 'bold',
}}
/>
</Box>
</Box>
</Box>
<Box sx={{ display: 'flex', flexGrow: 1, justifyContent: 'flex-end' }}>
<Button
variant='outlined'
color='error'
sx={{ marginBottom: '10px' }}
onClick={() => handleDeleteDevice(device.visitorid)}
>
{t('sessionRevoke')}
</Button>
</Box>
</Box>
</Paper>
</Grid>
);
};

export default CongregationPersonPocketDevice;

0 comments on commit f01da28

Please sign in to comment.