Skip to content

Commit 324e571

Browse files
committed
fix print table slow
1 parent ebe83e7 commit 324e571

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

packages/ui/app/components/PrintTasksTable.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {
1010
IconCheck, IconEye, IconHourglassEmpty, IconPrinter, IconRefresh, IconX,
1111
} from '@tabler/icons-react';
1212

13-
export function PrintTasksTable({ codes, refresh }) {
13+
function PrintTaskRow({ task, refresh }) {
1414
const [loading, setLoading] = React.useState(false);
1515

1616
const codeActions = async (_id, operation) => {
@@ -43,12 +43,12 @@ export function PrintTasksTable({ codes, refresh }) {
4343
console.error(e);
4444
notifications.show({ title: 'Error', message: 'Failed to update code', color: 'red' });
4545
}
46+
refresh();
4647
}
4748
setLoading(false);
48-
refresh();
4949
};
5050

51-
const rows = codes.map((task: any) => (
51+
return (
5252
<Table.Tr key={task._id}>
5353
<Table.Td>
5454
<ThemeIcon radius="xl" size="sm" color={task.done ? 'green' : task.printer ? 'blue' : 'gray'}>
@@ -90,8 +90,10 @@ export function PrintTasksTable({ codes, refresh }) {
9090
</Group>
9191
</Table.Td>
9292
</Table.Tr>
93-
));
93+
);
94+
}
9495

96+
export function PrintTasksTable({ codes, refresh }) {
9597
return (
9698
<Table
9799
horizontalSpacing="md" verticalSpacing="xs" miw={700}
@@ -106,7 +108,7 @@ export function PrintTasksTable({ codes, refresh }) {
106108
<Table.Th>Actions</Table.Th>
107109
</Table.Tr>
108110
</Table.Thead>
109-
<Table.Tbody>{rows}</Table.Tbody>
111+
<Table.Tbody>{ codes.map((task) => <PrintTaskRow key={task._id} task={task} refresh={refresh} />) }</Table.Tbody>
110112
</Table>
111113
);
112114
}

0 commit comments

Comments
 (0)