Skip to content

Commit

Permalink
fix(administration): handle outdated records
Browse files Browse the repository at this point in the history
  • Loading branch information
rhahao committed Jun 17, 2023
1 parent 9894a2e commit a08ac18
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,18 @@ const CongregationPersonPocketDevice = ({ device, handleDeleteDevice }) => {
return last_seen ? dateFormat(new Date(last_seen), t('shortDateTimeFormat')) : '';
};

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

let result = device.visitor_details.ip;

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

return result;
};

return (
<Grid item key={device.visitorid} xs={12} md={6}>
<Paper elevation={8} sx={{ padding: '10px' }}>
Expand All @@ -41,9 +53,8 @@ const CongregationPersonPocketDevice = ({ device, handleDeleteDevice }) => {
}}
/>
<Box sx={{ display: 'flex', flexDirection: 'column', gap: '5px' }}>
<Typography
sx={{ fontSize: '14px' }}
>{`IP: ${device.visitor_details.ip} - ${device.visitor_details.ipLocation.country_name}`}</Typography>
<Typography sx={{ fontSize: '18px', fontWeight: 'bold' }}>{`IP: ${getInfoIP()}`}</Typography>
<Typography>{device.visitor_details.browser || ''}</Typography>
<Box>
<Chip
label={formatLastSeen(device.sws_last_seen)}
Expand Down
16 changes: 12 additions & 4 deletions src/features/congregationPersons/CongregationPersonVipDevice.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,16 @@ const CongregationPersonVipDevice = ({ session, handleRevokeSession }) => {
return last_seen ? dateFormat(new Date(last_seen), t('shortDateTimeFormat')) : '';
};

const getInfoIP = () => {
let result = session.visitor_details.ip;

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

return result;
};

return (
<Grid item xs={12} lg={6}>
<Paper elevation={8} sx={{ padding: '10px' }}>
Expand All @@ -34,10 +44,8 @@ const CongregationPersonVipDevice = ({ session, handleRevokeSession }) => {
<Box sx={{ display: 'flex', alignItems: 'center' }}>
<GpsFixedIcon sx={{ fontSize: '60px', marginRight: '10px', color: '#1976d2' }} />
<Box sx={{ display: 'flex', flexDirection: 'column', gap: '5px' }}>
<Typography sx={{ fontSize: '18px', fontWeight: 'bold' }}>
{`IP: ${session.visitor_details.ip} - ${session.visitor_details.ipLocation.country_name}`}
</Typography>
<Typography>{session.visitor_details.browser}</Typography>
<Typography sx={{ fontSize: '18px', fontWeight: 'bold' }}>{`IP: ${getInfoIP()}`}</Typography>
<Typography>{session.visitor_details.browser || ''}</Typography>
<Typography>{t('lastSeen', { last_seen: formatLastSeen(session.sws_last_seen) })}</Typography>
{visitorID === session.visitorid && (
<Box>
Expand Down

0 comments on commit a08ac18

Please sign in to comment.