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.

- updated to using tables

Gaurav Bhatt83d2c3d474e7
diff --git a/apps/erp/app/components/Grid/components/Row.tsx b/apps/erp/app/components/Grid/components/Row.tsx
index 09ab80e34e..4f917472e3 100644
--- a/apps/erp/app/components/Grid/components/Row.tsx
+++ b/apps/erp/app/components/Grid/components/Row.tsx
@@ -32,8 +32,7 @@ const Row = <T extends object>({
rowRef,
selectedCell,
onCellClick,
- onCellUpdate,
- onEditRow
+ onCellUpdate
}: RowProps<T>) => {
const onUpdate = onCellUpdate(row.index);
@@ -41,17 +40,7 @@ const Row = <T extends object>({
<Tr
key={row.id}
ref={rowRef}
- className={cn((rowIsClickable || onEditRow) && "cursor-pointer")}
- onClick={
- onEditRow
- ? (e: React.MouseEvent) => {
- // Don't trigger row click if clicking a button/menu inside the row
- const target = e.target as HTMLElement;
- if (target.closest("button, a, [role='menuitem']")) return;
- onEditRow(row.original);
- }
- : undefined
- }
+ className={cn(rowIsClickable && "cursor-pointer")}
>
{row.getVisibleCells().map((cell, columnIndex) => {
const isSelected =
@@ -66,13 +55,9 @@ const Row = <T extends object>({
// @ts-ignore
editableComponents={editableComponents}
editedCells={editedCells}
- isSelected={onEditRow ? false : isSelected}
- isEditing={onEditRow ? false : isEditing}
- onClick={
- onEditRow
- ? undefined
- : () => onCellClick(cell.row.index, columnIndex)
- }
+ isSelected={isSelected}
+ isEditing={isEditing}
+ onClick={() => onCellClick(cell.row.index, columnIndex)}
onUpdate={onUpdate}
/>
);
diff --git a/apps/erp/app/modules/items/ui/Item/SupplierPartForm.tsx b/apps/erp/app/modules/items/ui/Item/SupplierPartForm.tsx
index 78c316a2da..f82c018c18 100644
--- a/apps/erp/app/modules/items/ui/Item/SupplierPartForm.tsx
+++ b/apps/erp/app/modules/items/ui/Item/SupplierPartForm.tsx
@@ -31,10 +31,7 @@ import { path } from "~/utils/path";
import { supplierPartValidator } from "../../items.models";
type SupplierPartFormProps = {
- initialValues: z.infer<typeof supplierPartValidator> & {
- lastPurchaseDate?: string | null;
- lastPOQuantity?: number | null;
- };
+ initialValues: z.infer<typeof supplierPartValidator>;
type: "Part" | "Service" | "Tool" | "Consumable" | "Material";
unitOfMeasureCode: string;
onClose: () => void;
diff --git a/apps/erp/app/modules/items/ui/Item/SupplierParts/SupplierParts.tsx b/apps/erp/app/modules/items/ui/Item/SupplierParts/SupplierParts.tsx
index c84cac840a..2891ca6f12 100644
--- a/apps/erp/app/modules/items/ui/Item/SupplierParts/SupplierParts.tsx
+++ b/apps/erp/app/modules/items/ui/Item/SupplierParts/SupplierParts.tsx
@@ -1,9 +1,10 @@
-import { Card, CardContent, CardHeader, CardTitle, cn } from "@carbon/react";
+import { MenuIcon, MenuItem } from "@carbon/react";
import type { ColumnDef } from "@tanstack/react-table";
-import { useMemo } from "react";
+import { useCallback, useMemo } from "react";
+import { LuPencil } from "react-icons/lu";
import { Outlet, useNavigate } from "react-router";
-import { SupplierAvatar } from "~/components";
-import Grid from "~/components/Grid";
+import { New, SupplierAvatar } from "~/components";
+import Table from "~/components/Table";
import { useCurrencyFormatter } from "~/hooks";
import { useCustomColumns } from "~/hooks/useCustomColumns";
import type { SupplierPart } from "../../../types";
@@ -98,22 +99,28 @@ const SupplierParts = ({
return [...defaultColumns, ...customColumns];
}, [customColumns, formatter]);
+ const renderContextMenu = useCallback(
+ (row: Part) => (
+ <MenuItem onClick={() => navigate(row.id!)}>
+ <MenuIcon icon={<LuPencil />} />
+ Edit Supplier Part
+ </MenuItem>
+ ),
+ [navigate]
+ );
+
return (
<>
- <Card className={cn(compact && "border-none p-0 dark:shadow-none")}>
- <CardHeader className={cn(compact && "px-0")}>
- <CardTitle>Supplier Parts</CardTitle>
- </CardHeader>
- <CardContent className={cn(compact && "px-0")}>
- <Grid<Part>
- contained={false}
- data={supplierParts}
- columns={columns}
- onEditRow={(row) => navigate(row.id!)}
- onNewRow={canEdit ? () => navigate("new") : undefined}
- />
- </CardContent>
- </Card>
+ <Table<Part>
+ data={supplierParts}
+ columns={columns}
+ count={supplierParts.length}
+ title="Supplier Parts"
+ renderContextMenu={canEdit ? renderContextMenu : undefined}
+ primaryAction={
+ canEdit ? <New label="Supplier Part" to="new" /> : undefined
+ }
+ />
<Outlet />
</>
);
diff --git a/apps/erp/app/modules/purchasing/ui/SupplierQuote/SupplierQuoteCompareDrawer.tsx b/apps/erp/app/modules/purchasing/ui/SupplierQuote/SupplierQuoteCompareDrawer.tsx
index da3a5ff5d8..c5152dc382 100644
--- a/apps/erp/app/modules/purchasing/ui/SupplierQuote/SupplierQuoteCompareDrawer.tsx
+++ b/apps/erp/app/modules/purchasing/ui/SupplierQuote/SupplierQuoteCompareDrawer.tsx
@@ -199,7 +199,10 @@ const SupplierQuoteCompareDrawer = ({
<DrawerTitle>
{step === "compare"
? "Compare Supplier Quotes"
- : `Create Order from ${selectedQuote?.supplier?.name ?? selectedQuote?.supplierQuoteId}`}
+ : `Create Order from ${
+ selectedQuote?.supplier?.name ??
+ selectedQuote?.supplierQuoteId
+ }`}
</DrawerTitle>
{step === "compare" && totalQuotes > 0 && (
<span className="text-sm text-muted-foreground">
diff --git a/apps/erp/app/routes/x+/consumable+/$itemId.purchasing.$supplierPartId.tsx b/apps/erp/app/routes/x+/consumable+/$itemId.purchasing.$supplierPartId.tsx
index 964d96b531..0de9e5985b 100644
--- a/apps/erp/app/routes/x+/consumable+/$itemId.purchasing.$supplierPartId.tsx
+++ b/apps/erp/app/routes/x+/consumable+/$itemId.purchasing.$supplierPartId.tsx
@@ -1,7 +1,7 @@
import { assertIsPost, success } from "@carbon/auth";
import { requirePermissions } from "@carbon/auth/auth.server";
import { flash } from "@carbon/auth/session.server";
-import { validator } from "@carbon/form";
+import { validationError, validator } from "@carbon/form";
import { useRouteData } from "@carbon/remix";
import type { ActionFunctionArgs, LoaderFunctionArgs } from "react-router";
import { redirect, useLoaderData, useNavigate, useParams } from "react-router";
@@ -13,8 +13,7 @@ import { path } from "~/utils/path";
export async function loader({ request, params }: LoaderFunctionArgs) {
const { client, companyId } = await requirePermissions(request, {
- view: "parts",
- role: "employee"
+ view: "parts"
});
const { supplierPartId } = params;
@@ -35,8 +34,7 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
export async function action({ request, params }: ActionFunctionArgs) {
assertIsPost(request);
const { client, userId } = await requirePermissions(request, {
- update: "parts",
- role: "employee"
+ update: "parts"
});
const { itemId, supplierPartId } = params;
@@ -47,7 +45,7 @@ export async function action({ request, params }: ActionFunctionArgs) {
const validation = await validator(supplierPartValidator).validate(formData);
if (validation.error) {
- return { success: false, message: "Invalid form data" };
+ return validationError(validation.error);
}
// biome-ignore lint/correctness/noUnusedVariables: suppressed due to migration
diff --git a/apps/erp/app/routes/x+/material+/$itemId.purchasing.$supplierPartId.tsx b/apps/erp/app/routes/x+/material+/$itemId.purchasing.$supplierPartId.tsx
index 4238b77415..b3952e41b0 100644
--- a/apps/erp/app/routes/x+/material+/$itemId.purchasing.$supplierPartId.tsx
+++ b/apps/erp/app/routes/x+/material+/$itemId.purchasing.$supplierPartId.tsx
@@ -1,7 +1,7 @@
import { assertIsPost, success } from "@carbon/auth";
import { requirePermissions } from "@carbon/auth/auth.server";
import { flash } from "@carbon/auth/session.server";
-import { validator } from "@carbon/form";
+import { validationError, validator } from "@carbon/form";
import { useRouteData } from "@carbon/remix";
import type { ActionFunctionArgs, LoaderFunctionArgs } from "react-router";
import { redirect, useLoaderData, useNavigate, useParams } from "react-router";
@@ -13,8 +13,7 @@ import { path } from "~/utils/path";
export async function loader({ request, params }: LoaderFunctionArgs) {
const { client, companyId } = await requirePermissions(request, {
- view: "parts",
- role: "employee"
+ view: "parts"
});
const { supplierPartId } = params;
@@ -35,8 +34,7 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
export async function action({ request, params }: ActionFunctionArgs) {
assertIsPost(request);
const { client, userId } = await requirePermissions(request, {
- update: "parts",
- role: "employee"
+ update: "parts"
});
const { itemId, supplierPartId } = params;
@@ -47,7 +45,7 @@ export async function action({ request, params }: ActionFunctionArgs) {
const validation = await validator(supplierPartValidator).validate(formData);
if (validation.error) {
- return { success: false, message: "Invalid form data" };
+ return validationError(validation.error);
}
// biome-ignore lint/correctness/noUnusedVariables: suppressed due to migration
diff --git a/apps/erp/app/routes/x+/part+/$itemId.purchasing.$supplierPartId.tsx b/apps/erp/app/routes/x+/part+/$itemId.purchasing.$supplierPartId.tsx
index 5e07b00eb5..4fbeb2a876 100644
--- a/apps/erp/app/routes/x+/part+/$itemId.purchasing.$supplierPartId.tsx
+++ b/apps/erp/app/routes/x+/part+/$itemId.purchasing.$supplierPartId.tsx
@@ -13,8 +13,7 @@ import { path } from "~/utils/path";
export async function loader({ request, params }: LoaderFunctionArgs) {
const { client, companyId } = await requirePermissions(request, {
- view: "parts",
- role: "employee"
+ view: "parts"
});
const { supplierPartId } = params;
@@ -35,8 +34,7 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
export async function action({ request, params }: ActionFunctionArgs) {
assertIsPost(request);
const { client, userId } = await requirePermissions(request, {
- update: "parts",
- role: "employee"
+ update: "parts"
});
const { itemId, supplierPartId } = params;
diff --git a/apps/erp/app/routes/x+/tool+/$itemId.purchasing.$supplierPartId.tsx b/apps/erp/app/routes/x+/tool+/$itemId.purchasing.$supplierPartId.tsx
index 3bbfbde320..0d51fec0dc 100644
--- a/apps/erp/app/routes/x+/tool+/$itemId.purchasing.$supplierPartId.tsx
+++ b/apps/erp/app/routes/x+/tool+/$itemId.purchasing.$supplierPartId.tsx
@@ -13,8 +13,7 @@ import { path } from "~/utils/path";
export async function loader({ request, params }: LoaderFunctionArgs) {
const { client, companyId } = await requirePermissions(request, {
- view: "parts",
- role: "employee"
+ view: "parts"
});
const { supplierPartId } = params;
@@ -35,8 +34,7 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
export async function action({ request, params }: ActionFunctionArgs) {
assertIsPost(request);
const { client, userId } = await requirePermissions(request, {
- update: "parts",
- role: "employee"
+ update: "parts"
});
const { itemId, supplierPartId } = params;
diff --git a/apps/erp/app/utils/path.ts b/apps/erp/app/utils/path.ts
index 6b895f4168..43eb05f74c 100644
--- a/apps/erp/app/utils/path.ts
+++ b/apps/erp/app/utils/path.ts
@@ -478,7 +478,7 @@ export const path = {
generatePath(`${x}/consumable/${id}/purchasing`),
consumableRoot: `${x}/consumable`,
consumableSupplier: (itemId: string, id: string) =>
- generatePath(`${x}/consumable/${itemId}/suppliers/${id}`),
+ generatePath(`${x}/consumable/${itemId}/purchasing/${id}`),
consumableSuppliers: (id: string) =>
generatePath(`${x}/consumable/${id}/suppliers`),
convertQuoteToOrder: (id: string) =>
@@ -965,7 +965,7 @@ export const path = {
generatePath(`${x}/material/${id}/purchasing`),
materialRoot: `${x}/material`,
materialSupplier: (itemId: string, id: string) =>
- generatePath(`${x}/material/${itemId}/suppliers/${id}`),
+ generatePath(`${x}/material/${itemId}/purchasing/${id}`),
materialSuppliers: (id: string) =>
generatePath(`${x}/material/${id}/suppliers`),
materials: `${x}/items/materials`,
@@ -1178,7 +1178,7 @@ export const path = {
partRoot: `${x}/part`,
partSales: (id: string) => generatePath(`${x}/part/${id}/sales`),
partSupplier: (itemId: string, id: string) =>
- generatePath(`${x}/part/${itemId}/view/purchasing/${id}`),
+ generatePath(`${x}/part/${itemId}/purchasing/${id}`),
parts: `${x}/items/parts`,
partner: (id: string, abilityId: string) =>
generatePath(`${x}/resources/partners/${id}/${abilityId}`),
@@ -1569,7 +1569,7 @@ export const path = {
toolPurchasing: (id: string) => generatePath(`${x}/tool/${id}/purchasing`),
toolRoot: `${x}/tool`,
toolSupplier: (itemId: string, id: string) =>
- generatePath(`${x}/tool/${itemId}/view/purchasing/${id}`),
+ generatePath(`${x}/tool/${itemId}/purchasing/${id}`),
toolSuppliers: (id: string) =>
generatePath(`${x}/tool/${id}/view/suppliers`),
tools: `${x}/items/tools`,
diff --git a/packages/database/src/types.ts b/packages/database/src/types.ts
index 44efbea60c..0420ffd81d 100644
--- a/packages/database/src/types.ts
+++ b/packages/database/src/types.ts
@@ -52069,14 +52069,14 @@ export type Database = {
Relationships: [
{
foreignKeyName: "address_countryCode_fkey"
- columns: ["customerCountryCode"]
+ columns: ["invoiceCountryCode"]
isOneToOne: false
referencedRelation: "country"
referencedColumns: ["alpha2"]
},
{
foreignKeyName: "address_countryCode_fkey"
- columns: ["invoiceCountryCode"]
+ columns: ["customerCountryCode"]
isOneToOne: false
referencedRelation: "country"
referencedColumns: ["alpha2"]
diff --git a/packages/database/supabase/functions/lib/types.ts b/packages/database/supabase/functions/lib/types.ts
index 44efbea60c..0420ffd81d 100644
--- a/packages/database/supabase/functions/lib/types.ts
+++ b/packages/database/supabase/functions/lib/types.ts
@@ -52069,14 +52069,14 @@ export type Database = {
Relationships: [
{
foreignKeyName: "address_countryCode_fkey"
- columns: ["customerCountryCode"]
+ columns: ["invoiceCountryCode"]
isOneToOne: false
referencedRelation: "country"
referencedColumns: ["alpha2"]
},
{
foreignKeyName: "address_countryCode_fkey"
- columns: ["invoiceCountryCode"]
+ columns: ["customerCountryCode"]
isOneToOne: false
referencedRelation: "country"
referencedColumns: ["alpha2"]