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 account currencies table

Brad Barbinb5e330ddc883
diff --git a/apps/carbon/app/components/Table/components/Pagination/Pagination.tsx b/apps/carbon/app/components/Table/components/Pagination/Pagination.tsx
index 09e7fff041..1a0dcf3831 100644
--- a/apps/carbon/app/components/Table/components/Pagination/Pagination.tsx
+++ b/apps/carbon/app/components/Table/components/Pagination/Pagination.tsx
@@ -15,6 +15,7 @@ import {
TooltipTrigger,
useKeyboardShortcuts,
} from "@carbon/react";
+import { prettifyKeyboardShortcut } from "@carbon/utils";
import { useRef } from "react";
import { BsChevronLeft, BsChevronRight } from "react-icons/bs";
@@ -92,11 +93,11 @@ export const PaginationButtons = ({
const previousButtonRef = useRef<HTMLButtonElement>(null);
useKeyboardShortcuts({
- j: (event: KeyboardEvent) => {
+ ArrowRight: (event: KeyboardEvent) => {
event.stopPropagation();
nextButtonRef.current?.click();
},
- f: (event: KeyboardEvent) => {
+ ArrowLeft: (event: KeyboardEvent) => {
event.stopPropagation();
previousButtonRef.current?.click();
},
@@ -154,7 +155,7 @@ export const PaginationButtons = ({
</Button>
</TooltipTrigger>
<TooltipContent>
- <HStack>F</HStack>
+ <HStack>{prettifyKeyboardShortcut("ArrowLeft")}</HStack>
</TooltipContent>
</Tooltip>
<Tooltip>
@@ -170,7 +171,7 @@ export const PaginationButtons = ({
</Button>
</TooltipTrigger>
<TooltipContent>
- <HStack>J</HStack>
+ <HStack>{prettifyKeyboardShortcut("ArrowRight")}</HStack>
</TooltipContent>
</Tooltip>
</TooltipProvider>
diff --git a/apps/carbon/app/components/Table/components/TableHeader.tsx b/apps/carbon/app/components/Table/components/TableHeader.tsx
index 3a43670498..104c841e8c 100644
--- a/apps/carbon/app/components/Table/components/TableHeader.tsx
+++ b/apps/carbon/app/components/Table/components/TableHeader.tsx
@@ -1,6 +1,6 @@
import { Button, HStack } from "@carbon/react";
import type { Column, ColumnOrderState } from "@tanstack/react-table";
-import type { ReactNode } from "react";
+import { type ReactNode } from "react";
import { BsFillCheckCircleFill } from "react-icons/bs";
import { MdOutlineEditNote } from "react-icons/md";
import { DebouncedInput } from "~/components/Search";
diff --git a/apps/carbon/app/modules/accounting/ui/Currencies/CurrenciesTable.tsx b/apps/carbon/app/modules/accounting/ui/Currencies/CurrenciesTable.tsx
index 6e7eb7fdba..f4b2cb261b 100644
--- a/apps/carbon/app/modules/accounting/ui/Currencies/CurrenciesTable.tsx
+++ b/apps/carbon/app/modules/accounting/ui/Currencies/CurrenciesTable.tsx
@@ -4,7 +4,7 @@ import type { ColumnDef } from "@tanstack/react-table";
import { memo, useCallback, useMemo } from "react";
import { BsFillPenFill } from "react-icons/bs";
import { IoMdTrash } from "react-icons/io";
-import { Table } from "~/components";
+import { New, TableNew } from "~/components";
import { usePermissions, useUrlParams } from "~/hooks";
import type { Currency } from "~/modules/accounting";
import { path } from "~/utils/path";
@@ -19,7 +19,7 @@ const CurrenciesTable = memo(({ data, count }: CurrenciesTableProps) => {
const navigate = useNavigate();
const permissions = usePermissions();
- const columns = useMemo<ColumnDef<(typeof data)[number]>[]>(() => {
+ const columns = useMemo<ColumnDef<Currency>[]>(() => {
return [
{
accessorKey: "name",
@@ -55,7 +55,7 @@ const CurrenciesTable = memo(({ data, count }: CurrenciesTableProps) => {
}, [navigate]);
const renderContextMenu = useCallback(
- (row: (typeof data)[number]) => {
+ (row: Currency) => {
return (
<>
<MenuItem
@@ -85,10 +85,15 @@ const CurrenciesTable = memo(({ data, count }: CurrenciesTableProps) => {
);
return (
- <Table<(typeof data)[number]>
+ <TableNew<Currency>
data={data}
columns={columns}
count={count}
+ primaryAction={
+ permissions.can("create", "accounting") && (
+ <New label="Currency" to={`new?${params.toString()}`} />
+ )
+ }
renderContextMenu={renderContextMenu}
/>
);
diff --git a/apps/carbon/app/modules/documents/ui/Documents/DocumentForm.tsx b/apps/carbon/app/modules/documents/ui/Documents/DocumentForm.tsx
index b2073567c2..c1dd76ad5c 100644
--- a/apps/carbon/app/modules/documents/ui/Documents/DocumentForm.tsx
+++ b/apps/carbon/app/modules/documents/ui/Documents/DocumentForm.tsx
@@ -45,7 +45,7 @@ const DocumentForm = ({ initialValues, ownerId }: DocumentFormProps) => {
className="flex flex-col h-full"
>
<DrawerHeader>
- <DrawerTitle>{`Edit ${initialValues.name}.${initialValues.extension}`}</DrawerTitle>
+ <DrawerTitle>{`${initialValues.name}.${initialValues.extension}`}</DrawerTitle>
</DrawerHeader>
<DrawerBody>
<Hidden name="id" />
diff --git a/apps/carbon/app/routes/x+/accounting+/currencies.tsx b/apps/carbon/app/routes/x+/accounting+/currencies.tsx
index e50a25fb3d..d5095a05bd 100644
--- a/apps/carbon/app/routes/x+/accounting+/currencies.tsx
+++ b/apps/carbon/app/routes/x+/accounting+/currencies.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 {
- CurrenciesTable,
- CurrenciesTableFilters,
- getCurrencies,
-} from "~/modules/accounting";
+import { CurrenciesTable, getCurrencies } from "~/modules/accounting";
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 getCurrencies(client, { name, limit, offset, sorts }));
+ return json(
+ await getCurrencies(client, { search, limit, offset, sorts, filters })
+ );
}
export default function CurrenciesRoute() {
@@ -36,7 +35,6 @@ export default function CurrenciesRoute() {
return (
<VStack spacing={0} className="h-full">
- <CurrenciesTableFilters />
<CurrenciesTable data={data ?? []} count={count ?? 0} />
<Outlet />
</VStack>
diff --git a/packages/utils/src/keyboard.ts b/packages/utils/src/keyboard.ts
index d1d1bf09e6..124700b3da 100644
--- a/packages/utils/src/keyboard.ts
+++ b/packages/utils/src/keyboard.ts
@@ -2,6 +2,8 @@ export function prettifyKeyboardShortcut(input: string) {
return input
.split("+")
.join("")
+ .replace("ArrowRight", "→")
+ .replace("ArrowLeft", "←")
.replace("Command", "⌘")
.replace("Shift", "⇧")
.replace("Control", "⌃")