[PUI] Table loading refactor (#6014)

* Pre-commit alterations

* Change PK for ID on panels only using ID

* Remove '-1' calls to Tables

* Remove unused imports
This commit is contained in:
Lavissa 2023-12-08 05:03:47 +01:00 committed by GitHub
parent 5b5df279c0
commit 5d42fb3f88
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 18 additions and 20 deletions

View File

@ -3,9 +3,7 @@ import { Group, LoadingOverlay, Stack, Table } from '@mantine/core';
import {
IconClipboardCheck,
IconClipboardList,
IconCopy,
IconDots,
IconEdit,
IconFileTypePdf,
IconInfoCircle,
IconList,
@ -122,7 +120,7 @@ export default function BuildDetail() {
content: (
<StockItemTable
params={{
build: build.pk ?? -1,
build: id,
is_building: false
}}
/>
@ -135,7 +133,7 @@ export default function BuildDetail() {
content: (
<StockItemTable
params={{
consumed_by: build.pk ?? -1
consumed_by: id
}}
/>
)
@ -147,7 +145,7 @@ export default function BuildDetail() {
content: (
<BuildOrderTable
params={{
parent: build.pk ?? -1
parent: id
}}
/>
)
@ -160,7 +158,7 @@ export default function BuildDetail() {
<AttachmentTable
endpoint={ApiPaths.build_order_attachment_list}
model="build"
pk={build.pk ?? -1}
pk={Number(id)}
/>
)
},
@ -177,7 +175,7 @@ export default function BuildDetail() {
)
}
];
}, [build]);
}, [build, id]);
const editBuildOrder = useCallback(() => {
let fields = buildOrderFields();

View File

@ -49,7 +49,7 @@ export default function CategoryDetail({}: {}) {
<PartListTable
props={{
params: {
category: category.pk ?? null
category: id
}
}}
/>
@ -62,7 +62,7 @@ export default function CategoryDetail({}: {}) {
content: (
<PartCategoryTable
params={{
parent: category.pk ?? null
parent: id
}}
/>
)

View File

@ -59,7 +59,7 @@ export default function PurchaseOrderDetail() {
name: 'line-items',
label: t`Line Items`,
icon: <IconList />,
content: order?.pk && <PurchaseOrderLineItemTable orderId={order.pk} />
content: <PurchaseOrderLineItemTable orderId={Number(id)} />
},
{
name: 'received-stock',
@ -81,7 +81,7 @@ export default function PurchaseOrderDetail() {
<AttachmentTable
endpoint={ApiPaths.purchase_order_attachment_list}
model="order"
pk={order.pk ?? -1}
pk={Number(id)}
/>
)
},
@ -91,7 +91,7 @@ export default function PurchaseOrderDetail() {
icon: <IconNotes />,
content: (
<NotesEditor
url={apiUrl(ApiPaths.purchase_order_list, order.pk)}
url={apiUrl(ApiPaths.purchase_order_list, id)}
data={order.notes ?? ''}
allowEdit={true}
/>

View File

@ -41,7 +41,7 @@ export default function ReturnOrderDetail() {
<AttachmentTable
endpoint={ApiPaths.return_order_attachment_list}
model="order"
pk={order.pk ?? -1}
pk={Number(id)}
/>
)
},
@ -51,7 +51,7 @@ export default function ReturnOrderDetail() {
icon: <IconNotes />,
content: (
<NotesEditor
url={apiUrl(ApiPaths.return_order_list, order.pk)}
url={apiUrl(ApiPaths.return_order_list, id)}
data={order.notes ?? ''}
allowEdit={true}
/>

View File

@ -69,7 +69,7 @@ export default function SalesOrderDetail() {
<AttachmentTable
endpoint={ApiPaths.sales_order_attachment_list}
model="order"
pk={order.pk ?? -1}
pk={Number(id)}
/>
)
},
@ -79,7 +79,7 @@ export default function SalesOrderDetail() {
icon: <IconNotes />,
content: (
<NotesEditor
url={apiUrl(ApiPaths.sales_order_list, order.pk)}
url={apiUrl(ApiPaths.sales_order_list, id)}
data={order.notes ?? ''}
allowEdit={true}
/>

View File

@ -38,7 +38,7 @@ export default function Stock() {
content: (
<StockItemTable
params={{
location: location.pk ?? null
location: id
}}
/>
)
@ -50,7 +50,7 @@ export default function Stock() {
content: (
<StockLocationTable
params={{
parent: location.pk ?? null
parent: id
}}
/>
)

View File

@ -111,7 +111,7 @@ export default function StockDetail() {
<AttachmentTable
endpoint={ApiPaths.stock_attachment_list}
model="stock_item"
pk={stockitem.pk ?? -1}
pk={Number(id)}
/>
)
},
@ -121,7 +121,7 @@ export default function StockDetail() {
icon: <IconNotes />,
content: (
<NotesEditor
url={apiUrl(ApiPaths.stock_item_list, stockitem.pk)}
url={apiUrl(ApiPaths.stock_item_list, id)}
data={stockitem.notes ?? ''}
allowEdit={true}
/>