Skip to content

Open-source manufacturing ERP, MES and QMS. Quoting, MRP, inventory, shop floor, quality and lot/serial traceability on one Postgres schema, with a REST API and MCP server. Self-host or use Carbon Cloud.

Refactor UsedIn component layout and enhance Suspense handling in Consumable and Material routes (#876)

Naveen Kashyapdaabbed7f662
diff --git a/apps/erp/app/modules/items/ui/Item/UsedIn.tsx b/apps/erp/app/modules/items/ui/Item/UsedIn.tsx
index e47999719f..bf473104d6 100644
--- a/apps/erp/app/modules/items/ui/Item/UsedIn.tsx
+++ b/apps/erp/app/modules/items/ui/Item/UsedIn.tsx
@@ -140,7 +140,7 @@ export function UsedInTree({
return (
<VStack className="w-full p-2">
{!hideSearch && (
- <HStack className="w-full py">
+ <HStack className="w-full py-1 sticky top-0 z-10 bg-card -mt-2 pt-2 -mx-2 px-2">
<InputGroup size="sm" className="flex grow">
<InputLeftElement>
<LuSearch className="h-4 w-4" />
diff --git a/apps/erp/app/routes/x+/consumable+/$itemId.tsx b/apps/erp/app/routes/x+/consumable+/$itemId.tsx
index af82e5e8dd..1e598544de 100644
--- a/apps/erp/app/routes/x+/consumable+/$itemId.tsx
+++ b/apps/erp/app/routes/x+/consumable+/$itemId.tsx
@@ -94,117 +94,123 @@ export default function ConsumableRoute() {
<div className="flex flex-grow overflow-hidden">
<ResizablePanels
explorer={
- <Suspense fallback={<UsedInSkeleton />}>
- <Await resolve={usedIn}>
- {(resolvedUsedIn) => {
- const {
- issues,
- jobMaterials,
- maintenanceDispatchItems,
- methodMaterials,
- purchaseOrderLines,
- receiptLines,
- quoteMaterials,
- salesOrderLines,
- shipmentLines,
- supplierQuotes,
- jobMaterialUsage
- } = resolvedUsedIn;
+ <div className="flex flex-col h-full">
+ <div className="flex-1 overflow-y-auto">
+ <Suspense fallback={<UsedInSkeleton />}>
+ <Await resolve={usedIn}>
+ {(resolvedUsedIn) => {
+ const {
+ issues,
+ jobMaterials,
+ maintenanceDispatchItems,
+ methodMaterials,
+ purchaseOrderLines,
+ receiptLines,
+ quoteMaterials,
+ salesOrderLines,
+ shipmentLines,
+ supplierQuotes,
+ jobMaterialUsage
+ } = resolvedUsedIn;
- const tree: UsedInNode[] = [
- {
- key: "issues",
- name: "Issues",
- module: "quality",
- children: issues
- },
- {
- key: "jobMaterials",
- name: "Job Materials",
- module: "production",
- children: jobMaterials
- },
- {
- key: "maintenanceDispatchItems",
- name: "Maintenance",
- module: "resources",
- children: maintenanceDispatchItems
- },
- {
- key: "methodMaterials",
- name: "Method Materials",
- module: "parts",
- // @ts-expect-error
- children: methodMaterials
- },
- {
- key: "purchaseOrderLines",
- name: "Purchase Orders",
- module: "purchasing",
- children: purchaseOrderLines.map((po) => ({
- ...po,
- methodType: "Purchase to Order"
- }))
- },
- {
- key: "receiptLines",
- name: "Receipts",
- module: "inventory",
- children: receiptLines.map((receipt) => ({
- ...receipt,
- methodType: "Pull from Inventory"
- }))
- },
+ const tree: UsedInNode[] = [
+ {
+ key: "issues",
+ name: "Issues",
+ module: "quality",
+ children: issues
+ },
+ {
+ key: "jobMaterials",
+ name: "Job Materials",
+ module: "production",
+ children: jobMaterials
+ },
+ {
+ key: "maintenanceDispatchItems",
+ name: "Maintenance",
+ module: "resources",
+ children: maintenanceDispatchItems
+ },
+ {
+ key: "methodMaterials",
+ name: "Method Materials",
+ module: "parts",
+ // @ts-expect-error
+ children: methodMaterials
+ },
+ {
+ key: "purchaseOrderLines",
+ name: "Purchase Orders",
+ module: "purchasing",
+ children: purchaseOrderLines.map((po) => ({
+ ...po,
+ methodType: "Purchase to Order"
+ }))
+ },
+ {
+ key: "receiptLines",
+ name: "Receipts",
+ module: "inventory",
+ children: receiptLines.map((receipt) => ({
+ ...receipt,
+ methodType: "Pull from Inventory"
+ }))
+ },
- {
- key: "quoteMaterials",
- name: "Quote Materials",
- module: "sales",
- children: quoteMaterials?.map((qm) => ({
- ...qm,
- documentReadableId: qm.documentReadableId ?? ""
- }))
- },
- {
- key: "salesOrderLines",
- name: "Sales Orders",
- module: "sales",
- children: salesOrderLines
- },
- {
- key: "shipmentLines",
- name: "Shipments",
- module: "inventory",
- children: shipmentLines.map((shipment) => ({
- ...shipment,
- methodType: "Shipment"
- }))
- },
- {
- key: "supplierQuotes",
- name: "Supplier Quotes",
- module: "purchasing",
- children: supplierQuotes
- }
- ];
+ {
+ key: "quoteMaterials",
+ name: "Quote Materials",
+ module: "sales",
+ children: quoteMaterials?.map((qm) => ({
+ ...qm,
+ documentReadableId: qm.documentReadableId ?? ""
+ }))
+ },
+ {
+ key: "salesOrderLines",
+ name: "Sales Orders",
+ module: "sales",
+ children: salesOrderLines
+ },
+ {
+ key: "shipmentLines",
+ name: "Shipments",
+ module: "inventory",
+ children: shipmentLines.map((shipment) => ({
+ ...shipment,
+ methodType: "Shipment"
+ }))
+ },
+ {
+ key: "supplierQuotes",
+ name: "Supplier Quotes",
+ module: "purchasing",
+ children: supplierQuotes
+ }
+ ];
- return (
- <UsedInTree
- tree={tree}
- revisions={consumableData.consumableSummary?.revisions}
- itemReadableId={
- consumableData.consumableSummary?.readableId ?? ""
- }
- itemReadableIdWithRevision={
- consumableData.consumableSummary
- ?.readableIdWithRevision ?? ""
- }
- jobMaterialUsage={jobMaterialUsage}
- />
- );
- }}
- </Await>
- </Suspense>
+ return (
+ <UsedInTree
+ tree={tree}
+ revisions={
+ consumableData.consumableSummary?.revisions
+ }
+ itemReadableId={
+ consumableData.consumableSummary?.readableId ?? ""
+ }
+ itemReadableIdWithRevision={
+ consumableData.consumableSummary
+ ?.readableIdWithRevision ?? ""
+ }
+ jobMaterialUsage={jobMaterialUsage}
+ />
+ );
+ }}
+ </Await>
+ </Suspense>
+ </div>
+ </div>
}
content={
<div className="h-[calc(100dvh-99px)] overflow-y-auto scrollbar-thin scrollbar-track-transparent scrollbar-thumb-accent w-full">
diff --git a/apps/erp/app/routes/x+/material+/$itemId.tsx b/apps/erp/app/routes/x+/material+/$itemId.tsx
index d418add01f..8882a4b94a 100644
--- a/apps/erp/app/routes/x+/material+/$itemId.tsx
+++ b/apps/erp/app/routes/x+/material+/$itemId.tsx
@@ -97,118 +97,122 @@ export default function MaterialRoute() {
<div className="flex flex-grow overflow-hidden">
<ResizablePanels
explorer={
- <Suspense fallback={<UsedInSkeleton />}>
- <Await resolve={usedIn}>
- {(resolvedUsedIn) => {
- const {
- issues,
- jobMaterials,
- maintenanceDispatchItems,
- methodMaterials,
- purchaseOrderLines,
- receiptLines,
- quoteMaterials,
- salesOrderLines,
- shipmentLines,
- supplierQuotes,
- jobMaterialUsage
- } = resolvedUsedIn;
+ <div className="flex flex-col h-full">
+ <div className="flex-1 overflow-y-auto">
+ <Suspense fallback={<UsedInSkeleton />}>
+ <Await resolve={usedIn}>
+ {(resolvedUsedIn) => {
+ const {
+ issues,
+ jobMaterials,
+ maintenanceDispatchItems,
+ methodMaterials,
+ purchaseOrderLines,
+ receiptLines,
+ quoteMaterials,
+ salesOrderLines,
+ shipmentLines,
+ supplierQuotes,
+ jobMaterialUsage
+ } = resolvedUsedIn;
- const tree: UsedInNode[] = [
- {
- key: "issues",
- name: "Issues",
- module: "quality",
- children: issues
- },
- {
- key: "jobMaterials",
- name: "Job Materials",
- module: "production",
- children: jobMaterials
- },
- {
- key: "maintenanceDispatchItems",
- name: "Maintenance",
- module: "resources",
- children: maintenanceDispatchItems
- },
- {
- key: "methodMaterials",
- name: "Method Materials",
- module: "parts",
- // @ts-expect-error
- children: methodMaterials
- },
- {
- key: "purchaseOrderLines",
- name: "Purchase Orders",
- module: "purchasing",
- children: purchaseOrderLines.map((po) => ({
- ...po,
- methodType: "Purchase to Order"
- }))
- },
- {
- key: "receiptLines",
- name: "Receipts",
- module: "inventory",
- children: receiptLines.map((receipt) => ({
- ...receipt,
- methodType: "Pull from Inventory"
- }))
- },
+ const tree: UsedInNode[] = [
+ {
+ key: "issues",
+ name: "Issues",
+ module: "quality",
+ children: issues
+ },
+ {
+ key: "jobMaterials",
+ name: "Job Materials",
+ module: "production",
+ children: jobMaterials
+ },
+ {
+ key: "maintenanceDispatchItems",
+ name: "Maintenance",
+ module: "resources",
+ children: maintenanceDispatchItems
+ },
+ {
+ key: "methodMaterials",
+ name: "Method Materials",
+ module: "parts",
+ // @ts-expect-error
+ children: methodMaterials
+ },
+ {
+ key: "purchaseOrderLines",
+ name: "Purchase Orders",
+ module: "purchasing",
+ children: purchaseOrderLines.map((po) => ({
+ ...po,
+ methodType: "Purchase to Order"
+ }))
+ },
+ {
+ key: "receiptLines",
+ name: "Receipts",
+ module: "inventory",
+ children: receiptLines.map((receipt) => ({
+ ...receipt,
+ methodType: "Pull from Inventory"
+ }))
+ },
- {
- key: "quoteMaterials",
- name: "Quote Materials",
- module: "sales",
- children: quoteMaterials?.map((qm) => ({
- ...qm,
- documentReadableId: qm.documentReadableId ?? ""
- }))
- },
- {
- key: "salesOrderLines",
- name: "Sales Orders",
- module: "sales",
- children: salesOrderLines
- },
- {
- key: "shipmentLines",
- name: "Shipments",
- module: "inventory",
- children: shipmentLines.map((shipment) => ({
- ...shipment,
- methodType: "Shipment"
- }))
- },
- {
- key: "supplierQuotes",
- name: "Supplier Quotes",
- module: "purchasing",
- children: supplierQuotes
- }
- ];
+ {
+ key: "quoteMaterials",
+ name: "Quote Materials",
+ module: "sales",
+ children: quoteMaterials?.map((qm) => ({
+ ...qm,
+ documentReadableId: qm.documentReadableId ?? ""
+ }))
+ },
+ {
+ key: "salesOrderLines",
+ name: "Sales Orders",
+ module: "sales",
+ children: salesOrderLines
+ },
+ {
+ key: "shipmentLines",
+ name: "Shipments",
+ module: "inventory",
+ children: shipmentLines.map((shipment) => ({
+ ...shipment,
+ methodType: "Shipment"
+ }))
+ },
+ {
+ key: "supplierQuotes",
+ name: "Supplier Quotes",
+ module: "purchasing",
+ children: supplierQuotes
+ }
+ ];
- return (
- <UsedInTree
- tree={tree}
- hasSizesInsteadOfRevisions={true}
- revisions={materialData.materialSummary?.revisions}
- itemReadableId={
- materialData.materialSummary?.readableId ?? ""
- }
- itemReadableIdWithRevision={
- materialData.materialSummary
- ?.readableIdWithRevision ?? ""
- }
- jobMaterialUsage={jobMaterialUsage}
- />
- );
- }}
- </Await>
- </Suspense>
+ return (
+ <UsedInTree
+ tree={tree}
+ hasSizesInsteadOfRevisions={true}
+ revisions={materialData.materialSummary?.revisions}
+ itemReadableId={
+ materialData.materialSummary?.readableId ?? ""
+ }
+ itemReadableIdWithRevision={
+ materialData.materialSummary
+ ?.readableIdWithRevision ?? ""
+ }
+ jobMaterialUsage={jobMaterialUsage}
+ />
+ );
+ }}
+ </Await>
+ </Suspense>
+ </div>
+ </div>
}
content={
<div className="h-[calc(100dvh-99px)] overflow-y-auto scrollbar-thin scrollbar-track-transparent scrollbar-thumb-accent w-full">