fix: account active sessions styles

This commit is contained in:
Sajad Mirjalili
2025-09-29 13:47:45 +03:30
parent e3fe01b9c3
commit 4a420da452

View File

@@ -1,11 +1,10 @@
import React, { useState, useEffect } from 'react'; import { useState, useEffect } from 'react';
import { import {
Box, Box,
Typography, Typography,
Button, Button,
useTheme,
useMediaQuery,
CircularProgress, CircularProgress,
Stack,
} from '@mui/material'; } from '@mui/material';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
import { DeviceMessage, Logout } from 'iconsax-react'; import { DeviceMessage, Logout } from 'iconsax-react';
@@ -24,8 +23,6 @@ export function ActiveDevicesPage() {
const { t, i18n } = useTranslation('setting'); const { t, i18n } = useTranslation('setting');
const [devices, setDevices] = useState<Device[]>([]); const [devices, setDevices] = useState<Device[]>([]);
const [loadingDeleteIds, setLoadingDeleteIds] = useState<string[]>([]); const [loadingDeleteIds, setLoadingDeleteIds] = useState<string[]>([]);
const theme = useTheme();
const isXsup = useMediaQuery(theme.breakpoints.up('xs'));
const showToast = useToast(); const showToast = useToast();
const { isLoadingProfile, refetchProfile } = useProfile(); const { isLoadingProfile, refetchProfile } = useProfile();
@@ -132,7 +129,9 @@ export function ActiveDevicesPage() {
flexGrow: 0, flexGrow: 0,
width: 'auto', width: 'auto',
}} }}
disabled={isLoadingProfile || isTerminating} disabled={
isLoadingProfile || isTerminating || devices.length === 1
}
> >
{isTerminating {isTerminating
? t('active.deleting') ? t('active.deleting')
@@ -158,20 +157,23 @@ export function ActiveDevicesPage() {
sx={{ sx={{
mx: { xs: 2, sm: 3, md: 4 }, mx: { xs: 2, sm: 3, md: 4 },
py: 2, py: 2,
display: 'flex',
flexDirection: 'column',
gap: 2,
bgcolor: 'background.paper', bgcolor: 'background.paper',
}} }}
> >
{devices.map((device) => ( {devices.map((device) => (
<React.Fragment key={device.id}> <Stack
alignItems="center"
justifyContent="space-between"
flexDirection="row"
key={device.id}
>
<Box <Box
sx={{ sx={{
display: 'flex', display: 'flex',
flexDirection: { xs: 'column', sm: 'row' }, flexDirection: { xs: 'column', sm: 'row' },
alignItems: { xs: 'flex-start', sm: 'center' }, alignItems: { xs: 'flex-start', sm: 'center' },
minHeight: 50, minHeight: 50,
gap: 0.5,
py: 1.5, py: 1.5,
}} }}
> >
@@ -217,17 +219,7 @@ export function ActiveDevicesPage() {
> >
{device.ip} {device.ip}
</Typography> </Typography>
</Box>
<Box
sx={{
flexBasis: { xs: '100%', sm: 'auto' },
mb: { xs: 1, sm: 0 },
minWidth: { sm: '126px' },
order: { xs: 4, sm: 4 },
alignItems: 'center',
justifyContent: 'center',
}}
>
{device.current && ( {device.current && (
<Button <Button
variant="outlined" variant="outlined"
@@ -250,17 +242,8 @@ export function ActiveDevicesPage() {
{t('active.currentDevice')} {t('active.currentDevice')}
</Button> </Button>
)} )}
</Box>
<Box {!device.current && (
sx={{
flexBasis: { xs: '100%', sm: 'auto' },
mb: { xs: 1, sm: 0 },
textAlign: { xs: 'left', sm: 'center' },
minWidth: { sm: '138px' },
order: { xs: 5, sm: 5 },
}}
>
<Button <Button
size="small" size="small"
variant="outlined" variant="outlined"
@@ -268,34 +251,22 @@ export function ActiveDevicesPage() {
disabled={ disabled={
device.current || loadingDeleteIds.includes(device.id) device.current || loadingDeleteIds.includes(device.id)
} }
loading={loadingDeleteIds.includes(device.id)}
onClick={() => handleDeleteDevice(device.id)} onClick={() => handleDeleteDevice(device.id)}
sx={{ sx={{
color: 'error.main', color: 'error.main',
borderRadius: 1, borderRadius: 1,
borderColor: 'error.main', borderColor: 'error.main',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
whiteSpace: 'nowrap',
textTransform: 'none',
'& .MuiButton-startIcon': { '& .MuiButton-startIcon': {
marginRight: 0.5, marginRight: 0.5,
marginLeft: 0, marginLeft: 0,
}, },
}} }}
> >
{loadingDeleteIds.includes(device.id) ? ( {t('active.deleteDevice')}
<CircularProgress size={20} color="error" />
) : (
t('active.deleteDevice')
)}
</Button> </Button>
</Box>
</Box>
{isXsup && (
<Box sx={{ borderBottom: 1, borderColor: 'divider' }} />
)} )}
</React.Fragment> </Stack>
))} ))}
</Box> </Box>
)} )}