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: materials ui

Brad Barbinbbb1a0be1c95
diff --git a/apps/carbon/app/modules/items/items.models.ts b/apps/carbon/app/modules/items/items.models.ts
index ffec2d1d02..64bd92feb4 100644
--- a/apps/carbon/app/modules/items/items.models.ts
+++ b/apps/carbon/app/modules/items/items.models.ts
@@ -60,6 +60,19 @@ export const fixtureValidator = itemValidator.merge(
})
);
+export const materialValidator = itemValidator.merge(
+ z.object({
+ id: z.string().min(1, { message: "Material ID is required" }).max(255),
+ materialSubstanceId: z
+ .string()
+ .min(1, { message: "Substance is required" }),
+ materialFormId: z.string().min(1, { message: "Form is required" }),
+ finish: z.string().optional(),
+ grade: z.string().optional(),
+ dimensions: z.string().optional(),
+ })
+);
+
export const partValidator = itemValidator.merge(
z.object({
id: z.string().min(1, { message: "Part ID is required" }).max(255),
diff --git a/apps/carbon/app/modules/items/items.service.ts b/apps/carbon/app/modules/items/items.service.ts
index 3270fc6ff1..639f9afe39 100644
--- a/apps/carbon/app/modules/items/items.service.ts
+++ b/apps/carbon/app/modules/items/items.service.ts
@@ -283,6 +283,65 @@ export async function getItemReplenishment(
.single();
}
+export async function getMaterial(
+ client: SupabaseClient<Database>,
+ itemId: string,
+ companyId: string
+) {
+ return client
+ .from("materials")
+ .select("*")
+ .eq("itemId", itemId)
+ .or(`companyId.eq.${companyId},companyId.is.null`)
+ .single();
+}
+
+export async function getMaterials(
+ client: SupabaseClient<Database>,
+ companyId: string,
+ args: GenericQueryFilters & {
+ search: string | null;
+ supplierId: string | null;
+ }
+) {
+ let query = client
+ .from("materials")
+ .select("*", {
+ count: "exact",
+ })
+ .or(`companyId.eq.${companyId},companyId.is.null`);
+
+ if (args.search) {
+ query = query.or(
+ `id.ilike.%${args.search}%,name.ilike.%${args.search}%,description.ilike.%${args.search}%`
+ );
+ }
+
+ if (args.supplierId) {
+ query = query.contains("supplierIds", [args.supplierId]);
+ }
+
+ query = setGenericQueryFilters(query, args, [
+ { column: "id", ascending: true },
+ ]);
+ return query;
+}
+
+export async function getMaterialsList(
+ client: SupabaseClient<Database>,
+ companyId: string
+) {
+ let query = client
+ .from("item")
+ .select("id, name, readableId")
+ .eq("type", "Material")
+ .or(`companyId.eq.${companyId},companyId.is.null`)
+ .eq("blocked", false)
+ .eq("active", true);
+
+ return query.order("name");
+}
+
export async function getMaterialForm(
client: SupabaseClient<Database>,
id: string
diff --git a/apps/carbon/app/modules/items/types.ts b/apps/carbon/app/modules/items/types.ts
index cf9742fb93..a4281735a0 100644
--- a/apps/carbon/app/modules/items/types.ts
+++ b/apps/carbon/app/modules/items/types.ts
@@ -9,6 +9,7 @@ import type {
getItemSuppliers,
getMaterialForms,
getMaterialSubstances,
+ getMaterials,
getPart,
getParts,
getServices,
@@ -58,6 +59,10 @@ export type ItemSupplier = NonNullable<
export type InventoryItemType =
Database["public"]["Enums"]["itemInventoryType"];
+export type Material = NonNullable<
+ Awaited<ReturnType<typeof getMaterials>>["data"]
+>[number];
+
export type MaterialForm = NonNullable<
Awaited<ReturnType<typeof getMaterialForms>>["data"]
>[number];
diff --git a/apps/carbon/app/modules/items/ui/Materials/MaterialForm.tsx b/apps/carbon/app/modules/items/ui/Materials/MaterialForm.tsx
new file mode 100644
index 0000000000..2fe60d21b7
--- /dev/null
+++ b/apps/carbon/app/modules/items/ui/Materials/MaterialForm.tsx
@@ -0,0 +1,188 @@
+import {
+ ModalCard,
+ ModalCardBody,
+ ModalCardContent,
+ ModalCardDescription,
+ ModalCardFooter,
+ ModalCardHeader,
+ ModalCardProvider,
+ ModalCardTitle,
+ cn,
+ toast,
+} from "@carbon/react";
+import { ValidatedForm } from "@carbon/remix-validated-form";
+import { useFetcher } from "@remix-run/react";
+import type { PostgrestResponse } from "@supabase/supabase-js";
+import { useEffect } from "react";
+import type { z } from "zod";
+import {
+ Boolean,
+ CustomFormFields,
+ Hidden,
+ Input,
+ InputControlled,
+ ItemGroup,
+ Select,
+ Submit,
+ TextArea,
+ UnitOfMeasure,
+} from "~/components/Form";
+import { useNextItemId, usePermissions } from "~/hooks";
+import { itemInventoryTypes, materialValidator } from "~/modules/items";
+import type { ListItem } from "~/types";
+import { path } from "~/utils/path";
+
+type MaterialFormProps = {
+ initialValues: z.infer<typeof materialValidator>;
+ substances: ListItem[];
+ forms: ListItem[];
+ type?: "card" | "modal";
+ onClose?: () => void;
+};
+
+function startsWithLetter(value: string) {
+ return /^[A-Za-z]/.test(value);
+}
+
+const MaterialForm = ({
+ initialValues,
+ type = "card",
+ substances,
+ forms,
+ onClose,
+}: MaterialFormProps) => {
+ const fetcher = useFetcher<PostgrestResponse<{ id: string }>>();
+
+ useEffect(() => {
+ if (type !== "modal") return;
+
+ if (fetcher.state === "loading" && fetcher.data?.data) {
+ onClose?.();
+ toast.success(`Created material`);
+ } else if (fetcher.state === "idle" && fetcher.data?.error) {
+ toast.error(`Failed to create material: ${fetcher.data.error.message}`);
+ }
+ }, [fetcher.data, fetcher.state, onClose, type]);
+
+ const { id, onIdChange, loading } = useNextItemId("Material");
+ const permissions = usePermissions();
+ const isEditing = !!initialValues.id;
+
+ const itemInventoryTypeOptions =
+ itemInventoryTypes.map((itemInventoryType) => ({
+ label: itemInventoryType,
+ value: itemInventoryType,
+ })) ?? [];
+
+ const substanceOptions = substances.map((substance) => ({
+ label: substance.name,
+ value: substance.id,
+ }));
+
+ const formOptions = forms.map((form) => ({
+ label: form.name,
+ value: form.id,
+ }));
+
+ return (
+ <ModalCardProvider type={type}>
+ <ModalCard onClose={onClose}>
+ <ModalCardContent>
+ <ValidatedForm
+ action={isEditing ? undefined : path.to.newMaterial}
+ method="post"
+ validator={materialValidator}
+ defaultValues={initialValues}
+ fetcher={fetcher}
+ >
+ <ModalCardHeader>
+ <ModalCardTitle>
+ {isEditing ? "Material Details" : "New Material"}
+ </ModalCardTitle>
+ {!isEditing && (
+ <ModalCardDescription>
+ A material is a physical item used to make a part that can be
+ used across multiple jobs
+ </ModalCardDescription>
+ )}
+ </ModalCardHeader>
+ <ModalCardBody>
+ <Hidden name="type" value={type} />
+ <div
+ className={cn(
+ "grid w-full gap-x-8 gap-y-2",
+ isEditing ? "grid-cols-1 md:grid-cols-3" : "grid-cols-1"
+ )}
+ >
+ {isEditing ? (
+ <Input name="id" label="Material ID" isReadOnly />
+ ) : (
+ <InputControlled
+ name="id"
+ label="Material ID"
+ helperText={
+ startsWithLetter(id)
+ ? "Use ... to get the next material ID"
+ : undefined
+ }
+ value={id}
+ onChange={onIdChange}
+ isDisabled={loading}
+ autoFocus
+ />
+ )}
+
+ <Input name="name" label="Name" />
+ <Select
+ name="materialSubstanceId"
+ label="Substance"
+ options={substanceOptions}
+ />
+ <Select
+ name="materialFormId"
+ label="Form"
+ options={formOptions}
+ />
+ <Input name="finish" label="Finish" />
+ <Input name="grade" label="Grade" />
+ <Input name="dimensions" label="Dimensions" />
+ <ItemGroup name="itemGroupId" label="Posting Group" />
+ {isEditing && (
+ <TextArea name="description" label="Description" />
+ )}
+
+ <Select
+ name="itemInventoryType"
+ label="Material Type"
+ options={itemInventoryTypeOptions}
+ />
+ <UnitOfMeasure
+ name="unitOfMeasureCode"
+ label="Unit of Measure"
+ />
+
+ <Boolean name="blocked" label="Blocked" />
+ {isEditing && <Boolean name="active" label="Active" />}
+
+ <CustomFormFields table="material" />
+ </div>
+ </ModalCardBody>
+ <ModalCardFooter>
+ <Submit
+ isDisabled={
+ isEditing
+ ? !permissions.can("update", "parts")
+ : !permissions.can("create", "parts")
+ }
+ >
+ Save
+ </Submit>
+ </ModalCardFooter>
+ </ValidatedForm>
+ </ModalCardContent>
+ </ModalCard>
+ </ModalCardProvider>
+ );
+};
+
+export default MaterialForm;
diff --git a/apps/carbon/app/modules/items/ui/Materials/MaterialHeader.tsx b/apps/carbon/app/modules/items/ui/Materials/MaterialHeader.tsx
new file mode 100644
index 0000000000..35ac6ec917
--- /dev/null
+++ b/apps/carbon/app/modules/items/ui/Materials/MaterialHeader.tsx
@@ -0,0 +1,128 @@
+import {
+ Card,
+ CardAction,
+ CardAttribute,
+ CardAttributeLabel,
+ CardAttributeValue,
+ CardAttributes,
+ CardContent,
+ CardDescription,
+ CardHeader,
+ CardTitle,
+ Enumerable,
+ HStack,
+ Menubar,
+ VStack,
+} from "@carbon/react";
+
+import { useParams } from "@remix-run/react";
+import { Assign, EmployeeAvatar, useOptimisticAssignment } from "~/components";
+import { usePermissions, useRouteData } from "~/hooks";
+import type { Material } from "~/modules/items";
+import { path } from "~/utils/path";
+
+const MaterialHeader = () => {
+ const permissions = usePermissions();
+ const { itemId } = useParams();
+ if (!itemId) throw new Error("itemId not found");
+
+ const routeData = useRouteData<{ materialSummary: Material }>(
+ path.to.material(itemId)
+ );
+
+ const optimisticAssignment = useOptimisticAssignment({
+ id: itemId,
+ table: "item",
+ });
+ const assignee =
+ optimisticAssignment !== undefined
+ ? optimisticAssignment
+ : routeData?.materialSummary?.assignee;
+
+ return (
+ <VStack>
+ {permissions.is("employee") && !!routeData?.materialSummary?.id && (
+ <Menubar>
+ <Assign
+ id={itemId}
+ table="item"
+ value={routeData?.materialSummary?.assignee ?? ""}
+ />
+ </Menubar>
+ )}
+ <Card>
+ <HStack className="justify-between items-start">
+ <CardHeader>
+ <CardTitle>{routeData?.materialSummary?.id}</CardTitle>
+ <CardDescription>
+ {routeData?.materialSummary?.name}
+ </CardDescription>
+ </CardHeader>
+ <CardAction>
+ {/* <Button
+ variant="secondary"
+ onClick={() => alert("TODO")}
+ leftIcon={<FaHistory />}
+ >
+ View History
+ </Button> */}
+ </CardAction>
+ </HStack>
+ <CardContent>
+ <CardAttributes>
+ <CardAttribute>
+ <CardAttributeLabel>Assignee</CardAttributeLabel>
+ <CardAttributeValue>
+ {assignee ? (
+ <EmployeeAvatar employeeId={assignee ?? null} />
+ ) : (
+ "-"
+ )}
+ </CardAttributeValue>
+ </CardAttribute>
+ <CardAttribute>
+ <CardAttributeLabel>Form</CardAttributeLabel>
+ <CardAttributeValue>
+ <Enumerable
+ value={routeData?.materialSummary?.materialForm ?? null}
+ />
+ </CardAttributeValue>
+ </CardAttribute>
+ <CardAttribute>
+ <CardAttributeLabel>Substance</CardAttributeLabel>
+ <CardAttributeValue>
+ <Enumerable
+ value={routeData?.materialSummary?.materialSubstance ?? null}
+ />
+ </CardAttributeValue>
+ </CardAttribute>
+ <CardAttribute>
+ <CardAttributeLabel>Finish</CardAttributeLabel>
+ <CardAttributeValue>
+ <Enumerable
+ value={routeData?.materialSummary?.finish ?? null}
+ />
+ </CardAttributeValue>
+ </CardAttribute>
+ <CardAttribute>
+ <CardAttributeLabel>Grade</CardAttributeLabel>
+ <CardAttributeValue>
+ <Enumerable value={routeData?.materialSummary?.grade ?? null} />
+ </CardAttributeValue>
+ </CardAttribute>
+ <CardAttribute>
+ <CardAttributeLabel>UoM</CardAttributeLabel>
+ <CardAttributeValue>
+ <Enumerable
+ value={routeData?.materialSummary?.unitOfMeasure ?? null}
+ />
+ </CardAttributeValue>
+ </CardAttribute>
+ </CardAttributes>
+ </CardContent>
+ </Card>
+ </VStack>
+ );
+};
+
+export default MaterialHeader;
diff --git a/apps/carbon/app/modules/items/ui/Materials/MaterialNavigation.tsx b/apps/carbon/app/modules/items/ui/Materials/MaterialNavigation.tsx
new file mode 100644
index 0000000000..410c9f353f
--- /dev/null
+++ b/apps/carbon/app/modules/items/ui/Materials/MaterialNavigation.tsx
@@ -0,0 +1,80 @@
+import { useParams } from "@remix-run/react";
+
+import {
+ LuBox,
+ LuFileBarChart,
+ LuFileText,
+ LuShare2,
+ LuShoppingCart,
+ LuTags,
+} from "react-icons/lu";
+import { DetailSidebar } from "~/components/Layout";
+import { usePermissions } from "~/hooks";
+import type { Role } from "~/types";
+import { path } from "~/utils/path";
+
+export function useMaterialNavigation() {
+ const permissions = usePermissions();
+ const { itemId } = useParams();
+ if (!itemId) throw new Error("itemId not found");
+
+ return [
+ {
+ name: "Details",
+ to: path.to.materialDetails(itemId),
+ icon: LuFileText,
+ shortcut: "Command+Shift+d",
+ },
+ {
+ name: "Purchasing",
+ to: path.to.materialPurchasing(itemId),
+ role: ["employee", "supplier"],
+ icon: LuShoppingCart,
+ shortcut: "Command+Shift+p",
+ },
+ {
+ name: "Suppliers",
+ to: path.to.materialSuppliers(itemId),
+ role: ["employee", "supplier"],
+ icon: LuShare2,
+ shortcut: "Command+Shift+s",
+ },
+
+ {
+ name: "Costing",
+ to: path.to.materialCosting(itemId),
+ role: ["employee", "supplier"],
+ icon: LuTags,
+ shortcut: "Command+Shift+c",
+ },
+ {
+ name: "Planning",
+ to: path.to.materialPlanning(itemId),
+ role: ["employee"],
+ icon: LuFileBarChart,
+ shortcut: "Command+Shift+p",
+ },
+ {
+ name: "Inventory",
+ to: path.to.materialInventory(itemId),
+ role: ["employee", "supplier"],
+ icon: LuBox,
+ shortcut: "Command+Shift+i",
+ },
+ ].filter(
+ (item) =>
+ item.role === undefined ||
+ item.role.some((role) => permissions.is(role as Role))
+ );
+}
+
+const MaterialNavigation = () => {
+ const { itemId } = useParams();
+ if (!itemId) throw new Error("itemId not found");
+
+ const links = useMaterialNavigation();
+
+ return <DetailSidebar links={links} />;
+};
+
+export default MaterialNavigation;
diff --git a/apps/carbon/app/modules/items/ui/Materials/MaterialsTable.tsx b/apps/carbon/app/modules/items/ui/Materials/MaterialsTable.tsx
new file mode 100644
index 0000000000..9b3757b0b2
--- /dev/null
+++ b/apps/carbon/app/modules/items/ui/Materials/MaterialsTable.tsx
@@ -0,0 +1,262 @@
+import { Checkbox, Enumerable, MenuIcon, MenuItem } from "@carbon/react";
+import { formatDate } from "@carbon/utils";
+import { useNavigate } from "@remix-run/react";
+import type { ColumnDef } from "@tanstack/react-table";
+import { memo, useMemo } from "react";
+import { LuPencil } from "react-icons/lu";
+import { EmployeeAvatar, Hyperlink, New, Table } from "~/components";
+import { usePermissions, useUrlParams } from "~/hooks";
+import { useCustomColumns } from "~/hooks/useCustomColumns";
+import type { Material } from "~/modules/items";
+import { itemInventoryTypes } from "~/modules/items";
+import { usePeople } from "~/stores";
+import type { ListItem } from "~/types";
+import { path } from "~/utils/path";
+
+type MaterialsTableProps = {
+ data: Material[];
+ itemGroups: ListItem[];
+ count: number;
+};
+
+const MaterialsTable = memo(
+ ({ data, count, itemGroups }: MaterialsTableProps) => {
+ const navigate = useNavigate();
+ const permissions = usePermissions();
+ const [params] = useUrlParams();
+ const [people] = usePeople();
+ const customColumns = useCustomColumns<Material>("material");
+
+ const columns = useMemo<ColumnDef<Material>[]>(() => {
+ const defaultColumns: ColumnDef<Material>[] = [
+ {
+ accessorKey: "id",
+ header: "Material ID",
+ cell: ({ row }) => (
+ <Hyperlink to={path.to.materialDetails(row.original.itemId!)}>
+ {row.original.id}
+ </Hyperlink>
+ ),
+ },
+ {
+ accessorKey: "name",
+ header: "Name",
+ cell: (item) => item.getValue(),
+ },
+ {
+ accessorKey: "description",
+ header: "Description",
+ cell: (item) => item.getValue(),
+ },
+ {
+ accessorKey: "materialSubstance",
+ header: "Substance",
+ cell: (item) => <Enumerable value={item.getValue<string>()} />,
+ meta: {
+ filter: {
+ type: "fetcher",
+ endpoint: path.to.api.materialSubstances,
+ transform: (data: { id: string; name: string }[] | null) =>
+ data?.map(({ name }) => ({
+ value: name,
+ label: <Enumerable value={name} />,
+ })) ?? [],
+ },
+ },
+ },
+ {
+ accessorKey: "materialForm",
+ header: "Form",
+ cell: (item) => <Enumerable value={item.getValue<string>()} />,
+ meta: {
+ filter: {
+ type: "fetcher",
+ endpoint: path.to.api.materialForms,
+ transform: (data: { id: string; name: string }[] | null) =>
+ data?.map(({ name }) => ({
+ value: name,
+ label: <Enumerable value={name} />,
+ })) ?? [],
+ },
+ },
+ },
+ {
+ accessorKey: "finish",
+ header: "Finish",
+ cell: (item) => item.getValue(),
+ },
+ {
+ accessorKey: "grade",
+ header: "Grade",
+ cell: (item) => item.getValue(),
+ },
+ {
+ accessorKey: "dimensions",
+ header: "Dimensions",
+ cell: (item) => item.getValue(),
+ },
+ {
+ accessorKey: "itemInventoryType",
+ header: "Inventory",
+ cell: (item) => <Enumerable value={item.getValue<string>()} />,
+ meta: {
+ filter: {
+ type: "static",
+ options: itemInventoryTypes.map((type) => ({
+ value: type,
+ label: <Enumerable value={type} />,
+ })),
+ },
+ },
+ },
+ {
+ accessorKey: "itemGroup",
+ header: "Posting Group",
+ cell: (item) => <Enumerable value={item.getValue<string>()} />,
+ meta: {
+ filter: {
+ type: "static",
+ options: itemGroups.map(({ name }) => ({
+ value: name,
+ label: <Enumerable value={name} />,
+ })),
+ },
+ },
+ },
+ {
+ accessorKey: "active",
+ header: "Active",
+ cell: (item) => <Checkbox isChecked={item.getValue<boolean>()} />,
+ meta: {
+ filter: {
+ type: "static",
+ options: [
+ { value: "true", label: "Active" },
+ { value: "false", label: "Inactive" },
+ ],
+ },
+ pluralHeader: "Active Statuses",
+ },
+ },
+ {
+ accessorKey: "blocked",
+ header: "Blocked",
+ cell: (item) => <Checkbox isChecked={item.getValue<boolean>()} />,
+ meta: {
+ filter: {
+ type: "static",
+ options: [
+ { value: "true", label: "Blocked" },
+ { value: "false", label: "Not Blocked" },
+ ],
+ },
+ pluralHeader: "Blocked Statuses",
+ },
+ },
+ {
+ id: "assignee",
+ header: "Assignee",
+ cell: ({ row }) => (
+ <EmployeeAvatar employeeId={row.original.assignee} />
+ ),
+ meta: {
+ filter: {
+ type: "static",
+ options: people.map((employee) => ({
+ value: employee.id,
+ label: employee.name,
+ })),
+ },
+ },
+ },
+ {
+ id: "createdBy",
+ header: "Created By",
+ cell: ({ row }) => (
+ <EmployeeAvatar employeeId={row.original.createdBy} />
+ ),
+ meta: {
+ filter: {
+ type: "static",
+ options: people.map((employee) => ({
+ value: employee.id,
+ label: employee.name,
+ })),
+ },
+ },
+ },
+ {
+ accessorKey: "createdAt",
+ header: "Created At",
+ cell: (item) => formatDate(item.getValue<string>()),
+ },
+ {
+ id: "updatedBy",
+ header: "Updated By",
+ cell: ({ row }) => (
+ <EmployeeAvatar employeeId={row.original.updatedBy} />
+ ),
+ meta: {
+ filter: {
+ type: "static",
+ options: people.map((employee) => ({
+ value: employee.id,
+ label: employee.name,
+ })),
+ },
+ },
+ },
+ {
+ accessorKey: "updatedAt",
+ header: "Created At",
+ cell: (item) => formatDate(item.getValue<string>()),
+ },
+ ];
+ return [...defaultColumns, ...customColumns];
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ }, [params]);
+
+ const renderContextMenu = useMemo(() => {
+ // eslint-disable-next-line react/display-name
+ return (row: Material) => (
+ <MenuItem onClick={() => navigate(path.to.material(row.id!))}>
+ <MenuIcon icon={<LuPencil />} />
+ Edit Material
+ </MenuItem>
+ );
+ }, [navigate]);
+
+ return (
+ <>
+ <Table<Material>
+ count={count}
+ columns={columns}
+ data={data}
+ defaultColumnPinning={{
+ left: ["id"],
+ }}
+ defaultColumnVisibility={{
+ description: false,
+ active: false,
+ blocked: false,
+ createdBy: false,
+ createdAt: false,
+ updatedBy: false,
+ updatedAt: false,
+ }}
+ primaryAction={
+ permissions.can("create", "parts") && (
+ <New label="Material" to={path.to.newMaterial} />
+ )
+ }
+ renderContextMenu={renderContextMenu}
+ withColumnOrdering
+ />
+ </>
+ );
+ }
+);
+
+MaterialsTable.displayName = "MaterialTable";
+
+export default MaterialsTable;
diff --git a/apps/carbon/app/modules/items/ui/Materials/index.ts b/apps/carbon/app/modules/items/ui/Materials/index.ts
new file mode 100644
index 0000000000..49b8126d1a
--- /dev/null
+++ b/apps/carbon/app/modules/items/ui/Materials/index.ts
@@ -0,0 +1,6 @@
+import MaterialForm from "./MaterialForm";
+import MaterialHeader from "./MaterialHeader";
+import MaterialNavigation from "./MaterialNavigation";
+import MaterialsTable from "./MaterialsTable";
+
+export { MaterialForm, MaterialHeader, MaterialNavigation, MaterialsTable };
diff --git a/apps/carbon/app/modules/items/ui/index.ts b/apps/carbon/app/modules/items/ui/index.ts
index 59a5a437da..d2834221d9 100644
--- a/apps/carbon/app/modules/items/ui/index.ts
+++ b/apps/carbon/app/modules/items/ui/index.ts
@@ -6,6 +6,7 @@ export * from "./Item";
export * from "./ItemGroups";
export * from "./MaterialForms";
export * from "./MaterialSubstances";
+export * from "./Materials";
export * from "./Parts";
export * from "./Services";
export * from "./Tools";
diff --git a/apps/carbon/app/routes/api+/items.forms.ts b/apps/carbon/app/routes/api+/items.forms.ts
new file mode 100644
index 0000000000..c3ca450e99
--- /dev/null
+++ b/apps/carbon/app/routes/api+/items.forms.ts
@@ -0,0 +1,10 @@
+import type { LoaderFunctionArgs } from "@remix-run/node";
+import { json } from "@remix-run/node";
+import { getMaterialFormsList } from "~/modules/items";
+import { requirePermissions } from "~/services/auth/auth.server";
+
+export async function loader({ request }: LoaderFunctionArgs) {
+ const { client, companyId } = await requirePermissions(request, {});
+
+ return json(await getMaterialFormsList(client, companyId));
+}
diff --git a/apps/carbon/app/routes/api+/items.parts.ts b/apps/carbon/app/routes/api+/items.parts.ts
index d648b592ea..67d0fb81d5 100644
--- a/apps/carbon/app/routes/api+/items.parts.ts
+++ b/apps/carbon/app/routes/api+/items.parts.ts
@@ -1,6 +1,5 @@
import type { LoaderFunctionArgs } from "@remix-run/node";
import { json } from "@remix-run/node";
-import type { ItemReplenishmentSystem } from "~/modules/items";
import { getPartsList } from "~/modules/items";
import { requirePermissions } from "~/services/auth/auth.server";
import { flash } from "~/services/session.server";
@@ -9,13 +8,7 @@ import { error } from "~/utils/result";
export async function loader({ request }: LoaderFunctionArgs) {
const { client, companyId } = await requirePermissions(request, {});
- const url = new URL(request.url);
- const searchParams = new URLSearchParams(url.search);
- const replenishmentSystem = searchParams.get(
- "replenishmentSystem"
- ) as ItemReplenishmentSystem | null;
-
- const parts = await getPartsList(client, companyId, replenishmentSystem);
+ const parts = await getPartsList(client, companyId);
if (parts.error) {
return json(
parts,
diff --git a/apps/carbon/app/routes/api+/items.substances.ts b/apps/carbon/app/routes/api+/items.substances.ts
new file mode 100644
index 0000000000..825d1d1377
--- /dev/null
+++ b/apps/carbon/app/routes/api+/items.substances.ts
@@ -0,0 +1,10 @@
+import type { LoaderFunctionArgs } from "@remix-run/node";
+import { json } from "@remix-run/node";
+import { getMaterialSubstancesList } from "~/modules/items";
+import { requirePermissions } from "~/services/auth/auth.server";
+
+export async function loader({ request }: LoaderFunctionArgs) {
+ const { client, companyId } = await requirePermissions(request, {});
+
+ return json(await getMaterialSubstancesList(client, companyId));
+}
diff --git a/apps/carbon/app/utils/path.ts b/apps/carbon/app/utils/path.ts
index db79430b40..9ce0a45d77 100644
--- a/apps/carbon/app/utils/path.ts
+++ b/apps/carbon/app/utils/path.ts
@@ -31,6 +31,8 @@ export const path = {
item: (type: string) => generatePath(`${api}/item/${type}`),
locations: `${api}/resources/locations`,
itemGroups: `${api}/items/groups`,
+ materialForms: `${api}/items/forms`,
+ materialSubstances: `${api}/items/substances`,
rollback: (table: string, id: string) =>
generatePath(
`${api}/settings/sequence/rollback?table=${table}&currentSequence=${id}`
@@ -322,19 +324,34 @@ export const path = {
locations: `${x}/resources/locations`,
login: "/login",
logout: "/logout",
- materials: `${x}/items/materials`,
+ material: (id: string) => generatePath(`${x}/material/${id}`),
+ materialCosting: (id: string) =>
+ generatePath(`${x}/material/${id}/costing`),
+ materialDetails: (id: string) =>
+ generatePath(`${x}/material/${id}/details`),
materialForm: (id: string) => generatePath(`${x}/items/forms/${id}`),
materialForms: `${x}/items/forms`,
materialInventory: (id: string) =>
generatePath(`${x}/material/${id}/inventory`),
+ materialInventoryLocation: (id: string, locationId: string) =>
+ generatePath(`${x}/material/${id}/inventory?location=${locationId}`),
materialPlanning: (id: string) =>
generatePath(`${x}/material/${id}/planning`),
+ materialPlanningLocation: (id: string, locationId: string) =>
+ generatePath(`${x}/material/${id}/planning?location=${locationId}`),
+ materialPricing: (id: string) =>
+ generatePath(`${x}/material/${id}/pricing`),
+ materialPurchasing: (id: string) =>
+ generatePath(`${x}/material/${id}/purchasing`),
+ materialRoot: `${x}/material`,
+ materialSupplier: (itemId: string, id: string) =>
+ generatePath(`${x}/material/${itemId}/suppliers/${id}`),
+ materialSuppliers: (id: string) =>
+ generatePath(`${x}/material/${id}/suppliers`),
+ materials: `${x}/items/materials`,
materialSubstance: (id: string) =>
generatePath(`${x}/items/substances/${id}`),
materialSubstances: `${x}/items/substances`,
- materialSupplier: (itemId: string, id: string) =>
- generatePath(`${x}/material/${itemId}/suppliers/${id}`),
- messaging: `${x}/messaging`,
newAbility: `${x}/resources/abilities/new`,
newAccountingCategory: `${x}/accounting/categories/new`,
newAccountingSubcategory: (id: string) =>
@@ -376,6 +393,7 @@ export const path = {
newGroup: `${x}/users/groups/new`,
newHoliday: `${x}/resources/holidays/new`,
newLocation: `${x}/resources/locations/new`,
+ newMaterial: `${x}/material/new`,
newNote: `${x}/shared/notes/new`,
newPart: `${x}/part/new`,
newItemGroup: `${x}/items/groups/new`,