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.

feat: add chart to materials, tools, and consumables

Brad Barbin2b8cda7689b6
diff --git a/apps/erp/app/modules/inventory/ui/Inventory/InventoryDetails.tsx b/apps/erp/app/modules/inventory/ui/Inventory/InventoryDetails.tsx
index 355bcaf648..61cfec92f7 100644
--- a/apps/erp/app/modules/inventory/ui/Inventory/InventoryDetails.tsx
+++ b/apps/erp/app/modules/inventory/ui/Inventory/InventoryDetails.tsx
@@ -60,7 +60,12 @@ const InventoryDetails = ({
<VStack>Quantity on Purchase Order</VStack>
</CardDescription>
<CardTitle className="text-4xl ">
- {`${formatter.format(quantities?.quantityOnPurchaseOrder ?? 0)}`}
+ <div className="flex justify-start items-center gap-1">
+ {`${formatter.format(
+ quantities?.quantityOnPurchaseOrder ?? 0
+ )}`}
+ <LuMoveUp className="text-emerald-500 text-lg" />
+ </div>
</CardTitle>
</CardHeader>
</Card>
@@ -70,7 +75,10 @@ const InventoryDetails = ({
<VStack>Quantity on Sales Order</VStack>
</CardDescription>
<CardTitle className="text-4xl">
- {`${formatter.format(quantities?.quantityOnSalesOrder ?? 0)}`}
+ <div className="flex justify-start items-center gap-1">
+ {`${formatter.format(quantities?.quantityOnSalesOrder ?? 0)}`}
+ <LuMoveDown className="text-red-500 text-lg" />
+ </div>
</CardTitle>
</CardHeader>
</Card>
diff --git a/apps/erp/app/modules/items/ui/Consumables/useConsumableNavigation.tsx b/apps/erp/app/modules/items/ui/Consumables/useConsumableNavigation.tsx
index 11f31cac84..fc4aaa1412 100644
--- a/apps/erp/app/modules/items/ui/Consumables/useConsumableNavigation.tsx
+++ b/apps/erp/app/modules/items/ui/Consumables/useConsumableNavigation.tsx
@@ -51,6 +51,7 @@ export function useConsumableNavigation() {
{
name: "Planning",
to: path.to.consumablePlanning(itemId),
+ isDisabled: itemTrackingType === "Non-Inventory",
role: ["employee"],
icon: LuChartLine,
shortcut: "Command+Shift+p",
diff --git a/apps/erp/app/modules/items/ui/Item/ItemDemandChart.tsx b/apps/erp/app/modules/items/ui/Item/ItemPlanningChart.tsx
similarity index 56%
rename from apps/erp/app/modules/items/ui/Item/ItemDemandChart.tsx
rename to apps/erp/app/modules/items/ui/Item/ItemPlanningChart.tsx
index 384fd38ade..604b3116df 100644
--- a/apps/erp/app/modules/items/ui/Item/ItemDemandChart.tsx
+++ b/apps/erp/app/modules/items/ui/Item/ItemPlanningChart.tsx
@@ -18,6 +18,7 @@ import { useFetcher } from "@remix-run/react";
import { useMemo } from "react";
import { Bar, BarChart, CartesianGrid, Line, XAxis, YAxis } from "recharts";
+import { Empty } from "~/components";
import type { loader as forecastLoader } from "~/routes/api+/items.$id.$locationId.forecast";
import { path } from "~/utils/path";
@@ -43,7 +44,7 @@ interface ChartDataPoint {
forecast: number;
}
-export const ItemDemandChart = ({
+export const ItemPlanningChart = ({
itemId,
locationId,
}: {
@@ -113,62 +114,77 @@ export const ItemDemandChart = ({
const chartConfig = {} satisfies ChartConfig;
+ if (forecastFetcher.data?.demand.length === 0) {
+ return (
+ <Card>
+ <CardHeader>
+ <CardTitle>Demand</CardTitle>
+ </CardHeader>
+ <CardContent className="min-h-[360px] flex items-center justify-center">
+ <Empty>No demand data</Empty>
+ </CardContent>
+ </Card>
+ );
+ }
+
return (
- <Card>
- <CardHeader>
- <CardTitle>Demand</CardTitle>
- </CardHeader>
- <CardContent>
- <div className="min-h-[200px] max-h-[360px]">
- <Loading isLoading={isFetching}>
- <ChartContainer config={chartConfig} className="w-full h-full">
- <BarChart data={chartData}>
- <CartesianGrid vertical={false} />
- <XAxis
- dataKey="startDate"
- tickLine={false}
- axisLine={false}
- tickFormatter={(value) =>
- dateFormatter.format(
- parseDate(value).toDate(getLocalTimeZone())
- )
- }
- />
- <YAxis tickLine={false} axisLine={false} />
- <ChartTooltip
- content={
- <ChartTooltipContent
- labelFormatter={(value) =>
- `Week of ${dateFormatter.format(
- parseDate(value).toDate(getLocalTimeZone())
- )}`
+ <>
+ <Card>
+ <CardHeader>
+ <CardTitle>Demand</CardTitle>
+ </CardHeader>
+ <CardContent>
+ <div className="min-h-[200px] max-h-[360px]">
+ <Loading isLoading={isFetching}>
+ <ChartContainer config={chartConfig} className="w-full h-full">
+ <BarChart data={chartData}>
+ <CartesianGrid vertical={false} />
+ <XAxis
+ dataKey="startDate"
+ tickLine={false}
+ axisLine={false}
+ tickFormatter={(value) =>
+ dateFormatter.format(
+ parseDate(value).toDate(getLocalTimeZone())
+ )
+ }
+ />
+ <YAxis tickLine={false} axisLine={false} />
+ <ChartTooltip
+ content={
+ <ChartTooltipContent
+ labelFormatter={(value) =>
+ `Week of ${dateFormatter.format(
+ parseDate(value).toDate(getLocalTimeZone())
+ )}`
+ }
+ />
+ }
+ />
+ {sourceTypes.map((sourceType: string, index: number) => (
+ <Bar
+ key={sourceType}
+ dataKey={sourceType}
+ stackId="demand"
+ className={
+ sourceType === "Sales Order"
+ ? "fill-violet-600"
+ : "fill-teal-500"
}
/>
- }
- />
- {sourceTypes.map((sourceType: string, index: number) => (
- <Bar
- key={sourceType}
- dataKey={sourceType}
- stackId="demand"
- className={
- sourceType === "Sales Order"
- ? "fill-violet-600"
- : "fill-teal-500"
- }
+ ))}
+ <Line
+ type="monotone"
+ dataKey="forecast"
+ stroke="#ff7300"
+ strokeWidth={2}
/>
- ))}
- <Line
- type="monotone"
- dataKey="forecast"
- stroke="#ff7300"
- strokeWidth={2}
- />
- </BarChart>
- </ChartContainer>
- </Loading>
- </div>
- </CardContent>
- </Card>
+ </BarChart>
+ </ChartContainer>
+ </Loading>
+ </div>
+ </CardContent>
+ </Card>
+ </>
);
};
diff --git a/apps/erp/app/modules/items/ui/Materials/useMaterialNavigation.tsx b/apps/erp/app/modules/items/ui/Materials/useMaterialNavigation.tsx
index aa6ea24e26..0e2f103edd 100644
--- a/apps/erp/app/modules/items/ui/Materials/useMaterialNavigation.tsx
+++ b/apps/erp/app/modules/items/ui/Materials/useMaterialNavigation.tsx
@@ -51,6 +51,7 @@ export function useMaterialNavigation() {
{
name: "Planning",
to: path.to.materialPlanning(itemId),
+ isDisabled: itemTrackingType === "Non-Inventory",
role: ["employee"],
icon: LuChartLine,
shortcut: "Command+Shift+p",
diff --git a/apps/erp/app/modules/items/ui/Parts/usePartNavigation.tsx b/apps/erp/app/modules/items/ui/Parts/usePartNavigation.tsx
index fb2049aac5..654b099592 100644
--- a/apps/erp/app/modules/items/ui/Parts/usePartNavigation.tsx
+++ b/apps/erp/app/modules/items/ui/Parts/usePartNavigation.tsx
@@ -54,14 +54,6 @@ export function usePartNavigation() {
icon: LuFactory,
shortcut: "Command+Shift+m",
},
- {
- name: "Inventory",
- to: path.to.partInventory(itemId),
- isDisabled: itemTrackingType === "Non-Inventory",
- role: ["employee", "supplier"],
- icon: LuBox,
- shortcut: "Command+Shift+i",
- },
{
name: "Costing",
to: path.to.partCosting(itemId),
@@ -73,10 +65,19 @@ export function usePartNavigation() {
{
name: "Planning",
to: path.to.partPlanning(itemId),
+ isDisabled: itemTrackingType === "Non-Inventory",
role: ["employee"],
icon: LuChartLine,
shortcut: "Command+Shift+p",
},
+ {
+ name: "Inventory",
+ to: path.to.partInventory(itemId),
+ isDisabled: itemTrackingType === "Non-Inventory",
+ role: ["employee", "supplier"],
+ icon: LuBox,
+ shortcut: "Command+Shift+i",
+ },
{
name: "Sales",
to: path.to.partSales(itemId),
diff --git a/apps/erp/app/modules/items/ui/Tools/useToolNavigation.tsx b/apps/erp/app/modules/items/ui/Tools/useToolNavigation.tsx
index f424083e29..139c16c44d 100644
--- a/apps/erp/app/modules/items/ui/Tools/useToolNavigation.tsx
+++ b/apps/erp/app/modules/items/ui/Tools/useToolNavigation.tsx
@@ -64,6 +64,7 @@ export function useToolNavigation() {
{
name: "Planning",
to: path.to.toolPlanning(itemId),
+ isDisabled: itemTrackingType === "Non-Inventory",
role: ["employee"],
icon: LuChartLine,
shortcut: "Command+Shift+p",
diff --git a/apps/erp/app/routes/api+/items.$id.$locationId.forecast.ts b/apps/erp/app/routes/api+/items.$id.$locationId.forecast.ts
index 5cd12ff4f1..33e1b72e00 100644
--- a/apps/erp/app/routes/api+/items.$id.$locationId.forecast.ts
+++ b/apps/erp/app/routes/api+/items.$id.$locationId.forecast.ts
@@ -8,6 +8,7 @@ import { getItemDemand, getPeriods } from "~/modules/items/items.service";
const defaultResponse = {
demand: [],
periods: [],
+ forecast: 0,
};
export async function loader({ request, params }: LoaderFunctionArgs) {
@@ -49,5 +50,5 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
);
}
- return json({ demand: demand.data, periods: periods.data });
+ return json({ demand: demand.data, periods: periods.data, forecast: 10 });
}
diff --git a/apps/erp/app/routes/x+/consumable+/$itemId.inventory.tsx b/apps/erp/app/routes/x+/consumable+/$itemId.inventory.tsx
index cd24d58af3..91273e87d8 100644
--- a/apps/erp/app/routes/x+/consumable+/$itemId.inventory.tsx
+++ b/apps/erp/app/routes/x+/consumable+/$itemId.inventory.tsx
@@ -18,6 +18,7 @@ import {
upsertPickMethod,
} from "~/modules/items";
import { PickMethodForm } from "~/modules/items/ui/Item";
+import { ItemPlanningChart } from "~/modules/items/ui/Item/ItemPlanningChart";
import { getLocationsList } from "~/modules/resources";
import { getUserDefaults } from "~/modules/users/users.server";
import { useItems } from "~/stores/items";
@@ -146,6 +147,7 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
itemShelfQuantities: itemShelfQuantities.data,
quantities: quantities.data,
itemId,
+ locationId,
});
}
@@ -197,8 +199,13 @@ export default function ConsumableInventoryRoute() {
unitOfMeasures: UnitOfMeasureListItem[];
}>(path.to.consumableRoot);
- const { consumableInventory, itemShelfQuantities, quantities, itemId } =
- useLoaderData<typeof loader>();
+ const {
+ consumableInventory,
+ itemShelfQuantities,
+ quantities,
+ itemId,
+ locationId,
+ } = useLoaderData<typeof loader>();
const consumableData = useRouteData<{
consumableSummary: Consumable;
@@ -233,6 +240,10 @@ export default function ConsumableInventoryRoute() {
quantities={quantities}
shelves={sharedConsumablesData?.shelves ?? []}
/>
+ <ItemPlanningChart
+ itemId={consumableInventory.itemId}
+ locationId={locationId}
+ />
</VStack>
);
}
diff --git a/apps/erp/app/routes/x+/consumable+/$itemId.planning.tsx b/apps/erp/app/routes/x+/consumable+/$itemId.planning.tsx
index cf39166d88..79dbf4f5a5 100644
--- a/apps/erp/app/routes/x+/consumable+/$itemId.planning.tsx
+++ b/apps/erp/app/routes/x+/consumable+/$itemId.planning.tsx
@@ -2,6 +2,7 @@ import { assertIsPost, error, success } from "@carbon/auth";
import { requirePermissions } from "@carbon/auth/auth.server";
import { flash } from "@carbon/auth/session.server";
import { validationError, validator } from "@carbon/form";
+import { VStack } from "@carbon/react";
import { useLoaderData } from "@remix-run/react";
import type { ActionFunctionArgs, LoaderFunctionArgs } from "@vercel/remix";
import { json, redirect } from "@vercel/remix";
@@ -12,6 +13,7 @@ import {
upsertItemPlanning,
} from "~/modules/items";
import { ItemPlanningForm } from "~/modules/items/ui/Item";
+import { ItemPlanningChart } from "~/modules/items/ui/Item/ItemPlanningChart";
import { getLocationsList } from "~/modules/resources";
import { getUserDefaults } from "~/modules/users/users.server";
import type { ListItem } from "~/types";
@@ -106,6 +108,7 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
return json({
consumablePlanning: consumablePlanning.data,
+ locationId,
});
}
@@ -155,20 +158,26 @@ export default function ConsumablePlanningRoute() {
locations: ListItem[];
}>(path.to.consumableRoot);
- const { consumablePlanning } = useLoaderData<typeof loader>();
+ const { consumablePlanning, locationId } = useLoaderData<typeof loader>();
if (!sharedConsumablesData)
throw new Error("Could not load shared consumables data");
return (
- <ItemPlanningForm
- key={consumablePlanning.itemId}
- initialValues={{
- ...consumablePlanning,
- ...getCustomFields(consumablePlanning.customFields),
- }}
- locations={sharedConsumablesData.locations ?? []}
- type="Consumable"
- />
+ <VStack spacing={2} className="p-2">
+ <ItemPlanningForm
+ key={consumablePlanning.itemId}
+ initialValues={{
+ ...consumablePlanning,
+ ...getCustomFields(consumablePlanning.customFields),
+ }}
+ locations={sharedConsumablesData.locations ?? []}
+ type="Consumable"
+ />
+ <ItemPlanningChart
+ itemId={consumablePlanning.itemId}
+ locationId={locationId}
+ />
+ </VStack>
);
}
diff --git a/apps/erp/app/routes/x+/job+/methods+/$jobId.material.$id.tsx b/apps/erp/app/routes/x+/job+/methods+/$jobId.material.$id.tsx
index a569246326..ee972ee9fa 100644
--- a/apps/erp/app/routes/x+/job+/methods+/$jobId.material.$id.tsx
+++ b/apps/erp/app/routes/x+/job+/methods+/$jobId.material.$id.tsx
@@ -7,6 +7,7 @@ import {
jobMaterialValidator,
recalculateJobMakeMethodRequirements,
recalculateJobOperationDependencies,
+ runMRP,
upsertJobMaterial,
} from "~/modules/production";
import { setCustomFields } from "~/utils/form";
@@ -139,6 +140,13 @@ export async function action({ request, params }: ActionFunctionArgs) {
}
}
+ await runMRP(client, {
+ type: "item",
+ id: validation.data.itemId,
+ companyId,
+ userId,
+ });
+
return json({
id: jobMaterialId,
methodType: updateJobMaterial.data.methodType,
diff --git a/apps/erp/app/routes/x+/job+/methods+/$jobId.material.new.tsx b/apps/erp/app/routes/x+/job+/methods+/$jobId.material.new.tsx
index 8587966672..25e69a6ed1 100644
--- a/apps/erp/app/routes/x+/job+/methods+/$jobId.material.new.tsx
+++ b/apps/erp/app/routes/x+/job+/methods+/$jobId.material.new.tsx
@@ -7,6 +7,7 @@ import {
jobMaterialValidator,
recalculateJobMakeMethodRequirements,
recalculateJobOperationDependencies,
+ runMRP,
upsertJobMaterial,
upsertJobMaterialMakeMethod,
} from "~/modules/production";
@@ -148,6 +149,13 @@ export async function action({ request, params }: ActionFunctionArgs) {
)
);
}
+
+ await runMRP(serviceRole, {
+ type: "item",
+ id: validation.data.itemId,
+ companyId,
+ userId,
+ });
}
return json({ id: jobMaterialId });
diff --git a/apps/erp/app/routes/x+/material+/$itemId.inventory.tsx b/apps/erp/app/routes/x+/material+/$itemId.inventory.tsx
index ef9bf556a8..2bb3ec8d60 100644
--- a/apps/erp/app/routes/x+/material+/$itemId.inventory.tsx
+++ b/apps/erp/app/routes/x+/material+/$itemId.inventory.tsx
@@ -17,6 +17,7 @@ import {
upsertPickMethod,
} from "~/modules/items";
import { PickMethodForm } from "~/modules/items/ui/Item";
+import { ItemPlanningChart } from "~/modules/items/ui/Item/ItemPlanningChart";
import { getLocationsList } from "~/modules/resources";
import { getUserDefaults } from "~/modules/users/users.server";
import { useItems } from "~/stores";
@@ -142,6 +143,7 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
itemShelfQuantities: itemShelfQuantities.data,
quantities: quantities.data,
itemId,
+ locationId,
});
}
@@ -193,8 +195,13 @@ export default function MaterialInventoryRoute() {
unitOfMeasures: UnitOfMeasureListItem[];
}>(path.to.materialRoot);
- const { materialInventory, itemShelfQuantities, quantities, itemId } =
- useLoaderData<typeof loader>();
+ const {
+ materialInventory,
+ itemShelfQuantities,
+ quantities,
+ itemId,
+ locationId,
+ } = useLoaderData<typeof loader>();
const materialData = useRouteData<{
materialSummary: Material;
@@ -229,6 +236,7 @@ export default function MaterialInventoryRoute() {
quantities={quantities}
shelves={sharedMaterialsData?.shelves ?? []}
/>
+ <ItemPlanningChart itemId={itemId} locationId={locationId} />
</VStack>
);
}
diff --git a/apps/erp/app/routes/x+/material+/$itemId.planning.tsx b/apps/erp/app/routes/x+/material+/$itemId.planning.tsx
index a4af6a3d78..42e1c05a13 100644
--- a/apps/erp/app/routes/x+/material+/$itemId.planning.tsx
+++ b/apps/erp/app/routes/x+/material+/$itemId.planning.tsx
@@ -2,6 +2,7 @@ import { assertIsPost, error, success } from "@carbon/auth";
import { requirePermissions } from "@carbon/auth/auth.server";
import { flash } from "@carbon/auth/session.server";
import { validationError, validator } from "@carbon/form";
+import { VStack } from "@carbon/react";
import { useLoaderData } from "@remix-run/react";
import type { ActionFunctionArgs, LoaderFunctionArgs } from "@vercel/remix";
import { json, redirect } from "@vercel/remix";
@@ -12,6 +13,7 @@ import {
upsertItemPlanning,
} from "~/modules/items";
import { ItemPlanningForm } from "~/modules/items/ui/Item";
+import { ItemPlanningChart } from "~/modules/items/ui/Item/ItemPlanningChart";
import { getLocationsList } from "~/modules/resources";
import { getUserDefaults } from "~/modules/users/users.server";
import type { ListItem } from "~/types";
@@ -106,6 +108,7 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
return json({
materialPlanning: materialPlanning.data,
+ locationId,
});
}
@@ -152,20 +155,26 @@ export default function MateriallanningRoute() {
locations: ListItem[];
}>(path.to.materialRoot);
- const { materialPlanning } = useLoaderData<typeof loader>();
+ const { materialPlanning, locationId } = useLoaderData<typeof loader>();
if (!sharedMaterialsData)
throw new Error("Could not load shared materials data");
return (
- <ItemPlanningForm
- key={materialPlanning.itemId}
- initialValues={{
- ...materialPlanning,
- ...getCustomFields(materialPlanning.customFields),
- }}
- locations={sharedMaterialsData.locations ?? []}
- type="Material"
- />
+ <VStack spacing={2} className="p-2">
+ <ItemPlanningForm
+ key={materialPlanning.itemId}
+ initialValues={{
+ ...materialPlanning,
+ ...getCustomFields(materialPlanning.customFields),
+ }}
+ locations={sharedMaterialsData.locations ?? []}
+ type="Material"
+ />
+ <ItemPlanningChart
+ itemId={materialPlanning.itemId}
+ locationId={locationId}
+ />
+ </VStack>
);
}
diff --git a/apps/erp/app/routes/x+/part+/$itemId.inventory.tsx b/apps/erp/app/routes/x+/part+/$itemId.inventory.tsx
index e97c34c627..ea67de6027 100644
--- a/apps/erp/app/routes/x+/part+/$itemId.inventory.tsx
+++ b/apps/erp/app/routes/x+/part+/$itemId.inventory.tsx
@@ -17,7 +17,7 @@ import {
upsertPickMethod,
} from "~/modules/items";
import { PickMethodForm } from "~/modules/items/ui/Item";
-import { ItemDemandChart } from "~/modules/items/ui/Item/ItemDemandChart";
+import { ItemPlanningChart } from "~/modules/items/ui/Item/ItemPlanningChart";
import { getLocationsList } from "~/modules/resources";
import { getUserDefaults } from "~/modules/users/users.server";
import { useItems } from "~/stores";
@@ -222,7 +222,7 @@ export default function PartInventoryRoute() {
quantities={quantities}
shelves={sharedPartsData?.shelves ?? []}
/>
- <ItemDemandChart itemId={itemId} locationId={locationId} />
+ <ItemPlanningChart itemId={itemId} locationId={locationId} />
</VStack>
);
}
diff --git a/apps/erp/app/routes/x+/part+/$itemId.planning.tsx b/apps/erp/app/routes/x+/part+/$itemId.planning.tsx
index 4e7367ec0d..8b4a483d03 100644
--- a/apps/erp/app/routes/x+/part+/$itemId.planning.tsx
+++ b/apps/erp/app/routes/x+/part+/$itemId.planning.tsx
@@ -13,7 +13,7 @@ import {
upsertItemPlanning,
} from "~/modules/items";
import { ItemPlanningForm } from "~/modules/items/ui/Item";
-import { ItemDemandChart } from "~/modules/items/ui/Item/ItemDemandChart";
+import { ItemPlanningChart } from "~/modules/items/ui/Item/ItemPlanningChart";
import { getLocationsList } from "~/modules/resources";
import { getUserDefaults } from "~/modules/users/users.server";
import type { ListItem } from "~/types";
@@ -162,7 +162,7 @@ export default function PartPlanningRoute() {
locations={sharedPartsData.locations ?? []}
type="Part"
/>
- <ItemDemandChart itemId={partPlanning.itemId} locationId={locationId} />
+ <ItemPlanningChart itemId={partPlanning.itemId} locationId={locationId} />
</VStack>
);
}
diff --git a/apps/erp/app/routes/x+/tool+/$itemId.inventory.tsx b/apps/erp/app/routes/x+/tool+/$itemId.inventory.tsx
index d36996c022..a5cd37a489 100644
--- a/apps/erp/app/routes/x+/tool+/$itemId.inventory.tsx
+++ b/apps/erp/app/routes/x+/tool+/$itemId.inventory.tsx
@@ -17,6 +17,7 @@ import {
upsertPickMethod,
} from "~/modules/items";
import { PickMethodForm } from "~/modules/items/ui/Item";
+import { ItemPlanningChart } from "~/modules/items/ui/Item/ItemPlanningChart";
import { getLocationsList } from "~/modules/resources";
import { getUserDefaults } from "~/modules/users/users.server";
import { useItems } from "~/stores/items";
@@ -134,6 +135,7 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
itemShelfQuantities: itemShelfQuantities.data,
quantities: quantities.data,
itemId,
+ locationId,
});
}
@@ -185,7 +187,7 @@ export default function ToolInventoryRoute() {
unitOfMeasures: UnitOfMeasureListItem[];
}>(path.to.toolRoot);
- const { toolInventory, itemShelfQuantities, quantities, itemId } =
+ const { toolInventory, itemShelfQuantities, quantities, itemId, locationId } =
useLoaderData<typeof loader>();
const toolData = useRouteData<{
@@ -220,6 +222,10 @@ export default function ToolInventoryRoute() {
quantities={quantities}
shelves={sharedToolsData?.shelves ?? []}
/>
+ <ItemPlanningChart
+ itemId={toolInventory.itemId}
+ locationId={locationId}
+ />
</VStack>
);
}
diff --git a/apps/erp/app/routes/x+/tool+/$itemId.planning.tsx b/apps/erp/app/routes/x+/tool+/$itemId.planning.tsx
index b811b21f2d..e49c82fea2 100644
--- a/apps/erp/app/routes/x+/tool+/$itemId.planning.tsx
+++ b/apps/erp/app/routes/x+/tool+/$itemId.planning.tsx
@@ -13,6 +13,7 @@ import {
upsertItemPlanning,
} from "~/modules/items";
import { ItemPlanningForm } from "~/modules/items/ui/Item";
+import { ItemPlanningChart } from "~/modules/items/ui/Item/ItemPlanningChart";
import { getLocationsList } from "~/modules/resources";
import { getUserDefaults } from "~/modules/users/users.server";
import type { ListItem } from "~/types";
@@ -99,6 +100,7 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
return json({
toolPlanning: toolPlanning.data,
+ locationId,
});
}
@@ -145,7 +147,7 @@ export default function ToolPlanningRoute() {
locations: ListItem[];
}>(path.to.toolRoot);
- const { toolPlanning } = useLoaderData<typeof loader>();
+ const { toolPlanning, locationId } = useLoaderData<typeof loader>();
if (!sharedToolsData) throw new Error("Could not load shared tools data");
@@ -160,6 +162,7 @@ export default function ToolPlanningRoute() {
locations={sharedToolsData.locations ?? []}
type="Tool"
/>
+ <ItemPlanningChart itemId={toolPlanning.itemId} locationId={locationId} />
</VStack>
);
}