fix(home): use correct refine useList API pattern
Some checks failed
CI / style (push) Has been cancelled
CI / build-client (push) Has been cancelled
CI / build-amd64 (push) Has been cancelled
CI / build-tester (push) Has been cancelled
CI / test (cockroachdb) (push) Has been cancelled
CI / test (mariadb) (push) Has been cancelled
CI / test (postgres) (push) Has been cancelled
CI / test (sqlite) (push) Has been cancelled
CI / build-arm64 (push) Has been cancelled
CI / build-armv7 (push) Has been cancelled
CI / publish-images (push) Has been cancelled
CI / publish-release (push) Has been cancelled

Fix TypeScript errors by using { result, query } destructuring:
- result.data and result.total for list data
- query.isLoading for loading state

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-01-15 23:34:54 -06:00
parent 267fadfc54
commit f2fecede35

View File

@@ -31,7 +31,7 @@ export const Home: React.FC<IResourceComponentsProps> = () => {
const pageSize = 15; const pageSize = 15;
// Fetch all spools (not archived) for the main list // Fetch all spools (not archived) for the main list
const spools = useList<ISpool>({ const { result: spoolsResult, query: spoolsQuery } = useList<ISpool>({
resource: "spool", resource: "spool",
pagination: { current: currentPage, pageSize }, pagination: { current: currentPage, pageSize },
sorters: [{ field: "last_used", order: "desc" }], sorters: [{ field: "last_used", order: "desc" }],
@@ -43,25 +43,25 @@ export const Home: React.FC<IResourceComponentsProps> = () => {
}); });
// Fetch counts for stats // Fetch counts for stats
const filaments = useList<IFilament>({ const { result: filamentsResult, query: filamentsQuery } = useList<IFilament>({
resource: "filament", resource: "filament",
pagination: { pageSize: 1 }, pagination: { pageSize: 1 },
}); });
const vendors = useList<IVendor>({ const { result: vendorsResult, query: vendorsQuery } = useList<IVendor>({
resource: "vendor", resource: "vendor",
pagination: { pageSize: 1 }, pagination: { pageSize: 1 },
}); });
// Calculate low stock spools // Calculate low stock spools
const lowStockCount = useMemo(() => { const lowStockCount = useMemo(() => {
if (!spools.data?.data) return 0; if (!spoolsResult?.data) return 0;
return spools.data.data.filter( return spoolsResult.data.filter(
(spool) => spool.remaining_weight !== undefined && spool.remaining_weight < LOW_STOCK_THRESHOLD (spool: ISpool) => spool.remaining_weight !== undefined && spool.remaining_weight < LOW_STOCK_THRESHOLD
).length; ).length;
}, [spools.data?.data]); }, [spoolsResult?.data]);
// For accurate low stock count, we need all spools // For accurate low stock count, we need all spools
const allSpoolsForLowStock = useList<ISpool>({ const { result: lowStockResult } = useList<ISpool>({
resource: "spool", resource: "spool",
pagination: { pageSize: 1000 }, pagination: { pageSize: 1000 },
filters: [ filters: [
@@ -78,7 +78,7 @@ export const Home: React.FC<IResourceComponentsProps> = () => {
}, },
}); });
const totalLowStock = allSpoolsForLowStock.data?.total ?? lowStockCount; const totalLowStock = lowStockResult?.total ?? lowStockCount;
const spoolColumns = [ const spoolColumns = [
{ {
@@ -118,7 +118,7 @@ export const Home: React.FC<IResourceComponentsProps> = () => {
key: "remaining_weight", key: "remaining_weight",
width: 120, width: 120,
align: "right" as const, align: "right" as const,
render: (weight: number | undefined, record: ISpool) => { render: (weight: number | undefined) => {
if (weight === undefined) return t("unknown"); if (weight === undefined) return t("unknown");
const isLowStock = weight < LOW_STOCK_THRESHOLD; const isLowStock = weight < LOW_STOCK_THRESHOLD;
return ( return (
@@ -153,8 +153,8 @@ export const Home: React.FC<IResourceComponentsProps> = () => {
<Col> <Col>
<Statistic <Statistic
title={t("spool.spool")} title={t("spool.spool")}
value={spools.data?.total ?? 0} value={spoolsResult?.total ?? 0}
loading={spools.isLoading} loading={spoolsQuery.isLoading}
valueStyle={{ fontSize: 36, fontWeight: 600 }} valueStyle={{ fontSize: 36, fontWeight: 600 }}
/> />
</Col> </Col>
@@ -192,10 +192,10 @@ export const Home: React.FC<IResourceComponentsProps> = () => {
styles={{ body: { padding: 0 } }} styles={{ body: { padding: 0 } }}
> >
<Table <Table
dataSource={spools.data?.data} dataSource={spoolsResult?.data}
columns={spoolColumns} columns={spoolColumns}
rowKey="id" rowKey="id"
loading={spools.isLoading} loading={spoolsQuery.isLoading}
pagination={false} pagination={false}
size="small" size="small"
onRow={(record) => ({ onRow={(record) => ({
@@ -207,7 +207,7 @@ export const Home: React.FC<IResourceComponentsProps> = () => {
<Pagination <Pagination
current={currentPage} current={currentPage}
pageSize={pageSize} pageSize={pageSize}
total={spools.data?.total ?? 0} total={spoolsResult?.total ?? 0}
onChange={setCurrentPage} onChange={setCurrentPage}
showSizeChanger={false} showSizeChanger={false}
size="small" size="small"
@@ -222,8 +222,8 @@ export const Home: React.FC<IResourceComponentsProps> = () => {
<Card hoverable size="small"> <Card hoverable size="small">
<Statistic <Statistic
title={t("filament.filament")} title={t("filament.filament")}
value={filaments.data?.total ?? 0} value={filamentsResult?.total ?? 0}
loading={filaments.isLoading} loading={filamentsQuery.isLoading}
prefix={<HighlightOutlined />} prefix={<HighlightOutlined />}
/> />
</Card> </Card>
@@ -234,8 +234,8 @@ export const Home: React.FC<IResourceComponentsProps> = () => {
<Card hoverable size="small"> <Card hoverable size="small">
<Statistic <Statistic
title={t("vendor.vendor")} title={t("vendor.vendor")}
value={vendors.data?.total ?? 0} value={vendorsResult?.total ?? 0}
loading={vendors.isLoading} loading={vendorsQuery.isLoading}
prefix={<UserOutlined />} prefix={<UserOutlined />}
/> />
</Card> </Card>