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: new table/filter components for customer types table

Brad Barbin9b4f84343bc6
diff --git a/apps/carbon/app/modules/sales/ui/CustomerTypes/CustomerTypesTable.tsx b/apps/carbon/app/modules/sales/ui/CustomerTypes/CustomerTypesTable.tsx
index ed36837562..3757cc99b2 100644
--- a/apps/carbon/app/modules/sales/ui/CustomerTypes/CustomerTypesTable.tsx
+++ b/apps/carbon/app/modules/sales/ui/CustomerTypes/CustomerTypesTable.tsx
@@ -4,7 +4,7 @@ import type { ColumnDef } from "@tanstack/react-table";
import { memo, useCallback, useMemo } from "react";
import { BsFillPenFill, BsPeopleFill } from "react-icons/bs";
import { IoMdTrash } from "react-icons/io";
-import { Table } from "~/components";
+import { TableNew } from "~/components";
import { usePermissions, useUrlParams } from "~/hooks";
import type { CustomerType } from "~/modules/sales";
import { path } from "~/utils/path";
@@ -74,10 +74,13 @@ const CustomerTypesTable = memo(({ data, count }: CustomerTypesTableProps) => {
);
return (
- <Table<(typeof data)[number]>
+ <TableNew<(typeof data)[number]>
data={data}
columns={columns}
count={count}
+ label="Customer Type"
+ newPath={path.to.newCustomerType}
+ newPermission={permissions.can("create", "sales")}
renderContextMenu={renderContextMenu}
/>
);
diff --git a/apps/carbon/app/modules/sales/ui/CustomerTypes/CustomerTypesTableFilters.tsx b/apps/carbon/app/modules/sales/ui/CustomerTypes/CustomerTypesTableFilters.tsx
deleted file mode 100644
index 507d8cb6db..0000000000
--- a/apps/carbon/app/modules/sales/ui/CustomerTypes/CustomerTypesTableFilters.tsx
+++ /dev/null
@@ -1,25 +0,0 @@
-import { HStack } from "@carbon/react";
-import { New } from "~/components";
-import { TableFilters } from "~/components/Layout";
-import { DebouncedInput } from "~/components/Search";
-import { usePermissions, useUrlParams } from "~/hooks";
-
-const CustomerTypesTableFilters = () => {
- const [params] = useUrlParams();
- const permissions = usePermissions();
-
- return (
- <TableFilters>
- <HStack>
- <DebouncedInput param="name" size="sm" placeholder="Search" />
- </HStack>
- <HStack>
- {permissions.can("create", "sales") && (
- <New label="Customer Type" to={`new?${params.toString()}`} />
- )}
- </HStack>
- </TableFilters>
- );
-};
-
-export default CustomerTypesTableFilters;
diff --git a/apps/carbon/app/modules/sales/ui/CustomerTypes/index.ts b/apps/carbon/app/modules/sales/ui/CustomerTypes/index.ts
index bff6a6b24a..3c4b4f200a 100644
--- a/apps/carbon/app/modules/sales/ui/CustomerTypes/index.ts
+++ b/apps/carbon/app/modules/sales/ui/CustomerTypes/index.ts
@@ -1,5 +1,4 @@
import CustomerTypeForm from "./CustomerTypeForm";
import CustomerTypesTable from "./CustomerTypesTable";
-import CustomerTypesTableFilters from "./CustomerTypesTableFilters";
-export { CustomerTypeForm, CustomerTypesTable, CustomerTypesTableFilters };
+export { CustomerTypeForm, CustomerTypesTable };
diff --git a/apps/carbon/app/routes/x+/sales+/customer-types.tsx b/apps/carbon/app/routes/x+/sales+/customer-types.tsx
index e23e18698f..efcba45e76 100644
--- a/apps/carbon/app/routes/x+/sales+/customer-types.tsx
+++ b/apps/carbon/app/routes/x+/sales+/customer-types.tsx
@@ -2,11 +2,7 @@ import { VStack } from "@carbon/react";
import type { LoaderFunctionArgs } from "@remix-run/node";
import { json } from "@remix-run/node";
import { Outlet, useLoaderData } from "@remix-run/react";
-import {
- CustomerTypesTable,
- CustomerTypesTableFilters,
- getCustomerTypes,
-} from "~/modules/sales";
+import { CustomerTypesTable, getCustomerTypes } from "~/modules/sales";
import { requirePermissions } from "~/services/auth";
import type { Handle } from "~/utils/handle";
import { path } from "~/utils/path";
@@ -25,10 +21,13 @@ export async function loader({ request }: LoaderFunctionArgs) {
const url = new URL(request.url);
const searchParams = new URLSearchParams(url.search);
- const name = searchParams.get("name");
- const { limit, offset, sorts } = getGenericQueryFilters(searchParams);
+ const search = searchParams.get("search");
+ const { limit, offset, sorts, filters } =
+ getGenericQueryFilters(searchParams);
- return json(await getCustomerTypes(client, { name, limit, offset, sorts }));
+ return json(
+ await getCustomerTypes(client, { search, limit, offset, sorts, filters })
+ );
}
export default function CustomerTypesRoute() {
@@ -36,7 +35,6 @@ export default function CustomerTypesRoute() {
return (
<VStack spacing={0} className="h-full">
- <CustomerTypesTableFilters />
<CustomerTypesTable data={data ?? []} count={count ?? 0} />
<Outlet />
</VStack>