feat: rm loading logic for robots table
This commit is contained in:
@@ -148,7 +148,6 @@ export const RecordingsTable = ({
|
|||||||
const [rows, setRows] = React.useState<Data[]>([]);
|
const [rows, setRows] = React.useState<Data[]>([]);
|
||||||
const [isModalOpen, setModalOpen] = React.useState(false);
|
const [isModalOpen, setModalOpen] = React.useState(false);
|
||||||
const [searchTerm, setSearchTerm] = React.useState('');
|
const [searchTerm, setSearchTerm] = React.useState('');
|
||||||
const [isLoading, setIsLoading] = React.useState(true);
|
|
||||||
|
|
||||||
const columns = useMemo(() => [
|
const columns = useMemo(() => [
|
||||||
{ id: 'interpret', label: t('recordingtable.run'), minWidth: 80 },
|
{ id: 'interpret', label: t('recordingtable.run'), minWidth: 80 },
|
||||||
@@ -202,7 +201,6 @@ export const RecordingsTable = ({
|
|||||||
};
|
};
|
||||||
|
|
||||||
const fetchRecordings = useCallback(async () => {
|
const fetchRecordings = useCallback(async () => {
|
||||||
setIsLoading(true);
|
|
||||||
try {
|
try {
|
||||||
const recordings = await getStoredRecordings();
|
const recordings = await getStoredRecordings();
|
||||||
if (recordings) {
|
if (recordings) {
|
||||||
@@ -222,15 +220,13 @@ export const RecordingsTable = ({
|
|||||||
})
|
})
|
||||||
.filter(Boolean)
|
.filter(Boolean)
|
||||||
.sort((a, b) => b.parsedDate.getTime() - a.parsedDate.getTime());
|
.sort((a, b) => b.parsedDate.getTime() - a.parsedDate.getTime());
|
||||||
|
|
||||||
setRecordings(parsedRows.map((recording) => recording.name));
|
setRecordings(parsedRows.map((recording) => recording.name));
|
||||||
setRows(parsedRows);
|
setRows(parsedRows);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error fetching recordings:', error);
|
console.error('Error fetching recordings:', error);
|
||||||
notify('error', t('recordingtable.notifications.fetch_error'));
|
notify('error', t('recordingtable.notifications.fetch_error'));
|
||||||
} finally {
|
|
||||||
setIsLoading(false);
|
|
||||||
}
|
}
|
||||||
}, [setRecordings, notify, t]);
|
}, [setRecordings, notify, t]);
|
||||||
|
|
||||||
@@ -359,39 +355,32 @@ export const RecordingsTable = ({
|
|||||||
</IconButton>
|
</IconButton>
|
||||||
</Box>
|
</Box>
|
||||||
</Box>
|
</Box>
|
||||||
{isLoading ? (
|
<TableContainer component={Paper} sx={{ width: '100%', overflow: 'hidden', marginTop: '15px' }}>
|
||||||
<Box display="flex" justifyContent="center" alignItems="center" height="50%">
|
<Table stickyHeader aria-label="sticky table">
|
||||||
<CircularProgress />
|
<TableHead>
|
||||||
</Box>
|
<TableRow>
|
||||||
) : (
|
{columns.map((column) => (
|
||||||
<TableContainer component={Paper} sx={{ width: '100%', overflow: 'hidden', marginTop: '15px' }}>
|
<MemoizedTableCell
|
||||||
<Table stickyHeader aria-label="sticky table">
|
key={column.id}
|
||||||
<TableHead>
|
style={{ minWidth: column.minWidth }}
|
||||||
<TableRow>
|
>
|
||||||
{columns.map((column) => (
|
{column.label}
|
||||||
<MemoizedTableCell
|
</MemoizedTableCell>
|
||||||
key={column.id}
|
|
||||||
// align={column.align}
|
|
||||||
style={{ minWidth: column.minWidth }}
|
|
||||||
>
|
|
||||||
{column.label}
|
|
||||||
</MemoizedTableCell>
|
|
||||||
))}
|
|
||||||
</TableRow>
|
|
||||||
</TableHead>
|
|
||||||
<TableBody>
|
|
||||||
{visibleRows.map((row) => (
|
|
||||||
<TableRowMemoized
|
|
||||||
key={row.id}
|
|
||||||
row={row}
|
|
||||||
columns={columns}
|
|
||||||
handlers={handlers}
|
|
||||||
/>
|
|
||||||
))}
|
))}
|
||||||
</TableBody>
|
</TableRow>
|
||||||
</Table>
|
</TableHead>
|
||||||
</TableContainer>
|
<TableBody>
|
||||||
)}
|
{visibleRows.map((row) => (
|
||||||
|
<TableRowMemoized
|
||||||
|
key={row.id}
|
||||||
|
row={row}
|
||||||
|
columns={columns}
|
||||||
|
handlers={handlers}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
</TableBody>
|
||||||
|
</Table>
|
||||||
|
</TableContainer>
|
||||||
|
|
||||||
<TablePagination
|
<TablePagination
|
||||||
rowsPerPageOptions={[10, 25, 50, 100]}
|
rowsPerPageOptions={[10, 25, 50, 100]}
|
||||||
|
|||||||
Reference in New Issue
Block a user