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: prefetch detail views instead of index routes

Brad Barbin27c078681751
diff --git a/apps/carbon/app/components/Layout/Navigation/ContentSidebar.tsx b/apps/carbon/app/components/Layout/Navigation/ContentSidebar.tsx
index d10a663012..1f424be2af 100644
--- a/apps/carbon/app/components/Layout/Navigation/ContentSidebar.tsx
+++ b/apps/carbon/app/components/Layout/Navigation/ContentSidebar.tsx
@@ -27,7 +27,10 @@ const ContentSidebar = ({ links }: { links: Route[] }) => {
variant={isActive ? "primary" : "ghost"}
className="w-full justify-start"
>
- <Link to={route.to + (route.q ? `?q=${route.q}` : "")}>
+ <Link
+ to={route.to + (route.q ? `?q=${route.q}` : "")}
+ prefetch="intent"
+ >
{route.name}
</Link>
</Button>
diff --git a/apps/carbon/app/modules/invoicing/ui/PurchaseInvoices/PurchaseInvoicesTable.tsx b/apps/carbon/app/modules/invoicing/ui/PurchaseInvoices/PurchaseInvoicesTable.tsx
index a811d7e8e6..cd84051ff0 100644
--- a/apps/carbon/app/modules/invoicing/ui/PurchaseInvoices/PurchaseInvoicesTable.tsx
+++ b/apps/carbon/app/modules/invoicing/ui/PurchaseInvoices/PurchaseInvoicesTable.tsx
@@ -1,4 +1,5 @@
import { HStack, MenuIcon, MenuItem, useDisclosure } from "@carbon/react";
+import { formatDate } from "@carbon/utils";
import { useNavigate } from "@remix-run/react";
import type { ColumnDef } from "@tanstack/react-table";
import { memo, useMemo, useState } from "react";
@@ -42,7 +43,7 @@ const PurchaseInvoicesTable = memo(
accessorKey: "invoiceId",
header: "Invoice Number",
cell: ({ row }) => (
- <Hyperlink to={path.to.purchaseInvoice(row.original.id!)}>
+ <Hyperlink to={path.to.purchaseInvoiceDetails(row.original.id!)}>
{row.original?.invoiceId}
</Hyperlink>
),
@@ -105,7 +106,7 @@ const PurchaseInvoicesTable = memo(
{
accessorKey: "createdAt",
header: "Created At",
- cell: (item) => item.getValue(),
+ cell: (item) => formatDate(item.getValue<string>()),
},
{
accessorKey: "updatedByFullName",
@@ -122,7 +123,7 @@ const PurchaseInvoicesTable = memo(
{
accessorKey: "updatedAt",
header: "Updated At",
- cell: (item) => item.getValue(),
+ cell: (item) => formatDate(item.getValue<string>()),
},
];
}, [suppliers]);
diff --git a/apps/carbon/app/modules/purchasing/ui/PurchaseOrders/PurchaseOrdersTable.tsx b/apps/carbon/app/modules/purchasing/ui/PurchaseOrders/PurchaseOrdersTable.tsx
index 98b262f5b0..47f663615c 100644
--- a/apps/carbon/app/modules/purchasing/ui/PurchaseOrders/PurchaseOrdersTable.tsx
+++ b/apps/carbon/app/modules/purchasing/ui/PurchaseOrders/PurchaseOrdersTable.tsx
@@ -99,7 +99,7 @@ const PurchaseOrdersTable = memo(
</fetcher.Form>
)}
- <Hyperlink onClick={() => edit(row.original)}>
+ <Hyperlink to={path.to.purchaseOrderDetails(row.original.id!)}>
{row.original.purchaseOrderId}
</Hyperlink>
</HStack>
@@ -218,7 +218,7 @@ const PurchaseOrdersTable = memo(
cell: (item) => item.getValue(),
},
];
- }, [edit, fetcher, suppliers]);
+ }, [fetcher, suppliers]);
const renderContextMenu = useMemo(() => {
// eslint-disable-next-line react/display-name
diff --git a/apps/carbon/app/modules/purchasing/ui/Supplier/SupplierHeader.tsx b/apps/carbon/app/modules/purchasing/ui/Supplier/SupplierHeader.tsx
index cf5bad41fe..ddc1e184cd 100644
--- a/apps/carbon/app/modules/purchasing/ui/Supplier/SupplierHeader.tsx
+++ b/apps/carbon/app/modules/purchasing/ui/Supplier/SupplierHeader.tsx
@@ -72,10 +72,7 @@ const SupplierHeader = () => {
</CardAttribute>
<CardAttribute>
<CardAttributeLabel>Payment Terms</CardAttributeLabel>
- <CardAttributeValue>
- {/* // TODO: defaultPaymentTermId */}
- --
- </CardAttributeValue>
+ <CardAttributeValue>-</CardAttributeValue>
</CardAttribute>
</CardAttributes>
</CardContent>
diff --git a/apps/carbon/app/modules/purchasing/ui/Suppliers/SuppliersTable.tsx b/apps/carbon/app/modules/purchasing/ui/Suppliers/SuppliersTable.tsx
index eeb41e614f..a534abf453 100644
--- a/apps/carbon/app/modules/purchasing/ui/Suppliers/SuppliersTable.tsx
+++ b/apps/carbon/app/modules/purchasing/ui/Suppliers/SuppliersTable.tsx
@@ -30,7 +30,7 @@ const SuppliersTable = memo(
accessorKey: "name",
header: "Name",
cell: ({ row }) => (
- <Hyperlink to={path.to.supplier(row.original.id!)}>
+ <Hyperlink to={path.to.supplierDetails(row.original.id!)}>
{row.original.name}
</Hyperlink>
),
diff --git a/apps/carbon/app/modules/resources/ui/People/PeopleTable.tsx b/apps/carbon/app/modules/resources/ui/People/PeopleTable.tsx
index 5cbd85a661..c4256aa9ef 100644
--- a/apps/carbon/app/modules/resources/ui/People/PeopleTable.tsx
+++ b/apps/carbon/app/modules/resources/ui/People/PeopleTable.tsx
@@ -106,7 +106,7 @@ const PeopleTable = memo(
path={row.original.user?.avatarUrl!}
/>
- <Hyperlink to={path.to.person(row?.original.user?.id!)}>
+ <Hyperlink to={path.to.personDetails(row?.original.user?.id!)}>
{row.original.user?.fullName}
</Hyperlink>
</HStack>
@@ -187,7 +187,9 @@ const PeopleTable = memo(
<MenuItem
onClick={() =>
navigate(
- `${path.to.person(row.user?.id!)}?${params.toString()}`
+ `${path.to.personDetails(
+ row.user?.id!
+ )}?${params.toString()}`
)
}
>
diff --git a/apps/carbon/app/modules/sales/ui/Customers/CustomersTable.tsx b/apps/carbon/app/modules/sales/ui/Customers/CustomersTable.tsx
index e745d48ca1..9a7d0630e6 100644
--- a/apps/carbon/app/modules/sales/ui/Customers/CustomersTable.tsx
+++ b/apps/carbon/app/modules/sales/ui/Customers/CustomersTable.tsx
@@ -26,9 +26,7 @@ const CustomersTable = memo(
accessorKey: "name",
header: "Name",
cell: ({ row }) => (
- <Hyperlink
- onClick={() => navigate(path.to.customer(row.original.id!))}
- >
+ <Hyperlink to={path.to.customerDetails(row.original.id!)}>
{row.original.name}
</Hyperlink>
),
@@ -77,7 +75,7 @@ const CustomersTable = memo(
// ),
// },
];
- }, [customerStatuses, customerTypes, navigate]);
+ }, [customerStatuses, customerTypes]);
const renderContextMenu = useMemo(
// eslint-disable-next-line react/display-name
diff --git a/apps/carbon/app/modules/sales/ui/Quotations/QuotationsTable.tsx b/apps/carbon/app/modules/sales/ui/Quotations/QuotationsTable.tsx
index 181a76c2dc..34435959ef 100644
--- a/apps/carbon/app/modules/sales/ui/Quotations/QuotationsTable.tsx
+++ b/apps/carbon/app/modules/sales/ui/Quotations/QuotationsTable.tsx
@@ -92,7 +92,7 @@ const QuotationsTable = memo(({ data, count }: QuotationsTableProps) => {
</button>
</fetcher.Form>
)}
- <Hyperlink to={path.to.quote(row.original.id!)}>
+ <Hyperlink to={path.to.quoteDetails(row.original.id!)}>
{row.original.quoteId}
</Hyperlink>
</HStack>
diff --git a/packages/database/src/types.ts b/packages/database/src/types.ts
index f8ed638b3b..6181911b16 100644
--- a/packages/database/src/types.ts
+++ b/packages/database/src/types.ts
@@ -12403,14 +12403,14 @@ export type Database = {
},
{
foreignKeyName: "partner_id_fkey"
- columns: ["id"]
+ columns: ["supplierLocationId"]
isOneToOne: false
referencedRelation: "supplierLocation"
referencedColumns: ["id"]
},
{
foreignKeyName: "partner_id_fkey"
- columns: ["supplierLocationId"]
+ columns: ["id"]
isOneToOne: false
referencedRelation: "supplierLocation"
referencedColumns: ["id"]
@@ -12881,14 +12881,14 @@ export type Database = {
Relationships: [
{
foreignKeyName: "address_countryCode_fkey"
- columns: ["customerCountryCode"]
+ columns: ["supplierCountryCode"]
isOneToOne: false
referencedRelation: "country"
referencedColumns: ["id"]
},
{
foreignKeyName: "address_countryCode_fkey"
- columns: ["supplierCountryCode"]
+ columns: ["customerCountryCode"]
isOneToOne: false
referencedRelation: "country"
referencedColumns: ["id"]
diff --git a/packages/database/supabase/functions/lib/types.ts b/packages/database/supabase/functions/lib/types.ts
index f8ed638b3b..6181911b16 100644
--- a/packages/database/supabase/functions/lib/types.ts
+++ b/packages/database/supabase/functions/lib/types.ts
@@ -12403,14 +12403,14 @@ export type Database = {
},
{
foreignKeyName: "partner_id_fkey"
- columns: ["id"]
+ columns: ["supplierLocationId"]
isOneToOne: false
referencedRelation: "supplierLocation"
referencedColumns: ["id"]
},
{
foreignKeyName: "partner_id_fkey"
- columns: ["supplierLocationId"]
+ columns: ["id"]
isOneToOne: false
referencedRelation: "supplierLocation"
referencedColumns: ["id"]
@@ -12881,14 +12881,14 @@ export type Database = {
Relationships: [
{
foreignKeyName: "address_countryCode_fkey"
- columns: ["customerCountryCode"]
+ columns: ["supplierCountryCode"]
isOneToOne: false
referencedRelation: "country"
referencedColumns: ["id"]
},
{
foreignKeyName: "address_countryCode_fkey"
- columns: ["supplierCountryCode"]
+ columns: ["customerCountryCode"]
isOneToOne: false
referencedRelation: "country"
referencedColumns: ["id"]
diff --git a/packages/database/supabase/migrations/20240103010721_employee-summary.sql b/packages/database/supabase/migrations/20240103010721_employee-summary.sql
index dd031d9a09..c19e15efd9 100644
--- a/packages/database/supabase/migrations/20240103010721_employee-summary.sql
+++ b/packages/database/supabase/migrations/20240103010721_employee-summary.sql
@@ -11,7 +11,7 @@ CREATE OR REPLACE VIEW "employeeSummary" WITH(SECURITY_INVOKER=true) AS
FROM "employee" e
INNER JOIN "user" u
ON u.id = e.id
- INNER JOIN "employeeJob" ej
+ LEFT JOIN "employeeJob" ej
ON e.id = ej.id
LEFT OUTER JOIN "location" l
ON l.id = ej."locationId"
diff --git a/packages/redis/docker-compose.yml b/packages/redis/docker-compose.yml
deleted file mode 100644
index 5d9cc08a2a..0000000000
--- a/packages/redis/docker-compose.yml
+++ /dev/null
@@ -1,14 +0,0 @@
-version: "3.8"
-name: "carbon-redis"
-services:
- redis:
- image: redis:7.0-alpine
- restart: always
- ports:
- - "6389:6379"
- command: redis-server --save 20 1 --loglevel warning
- volumes:
- - cache:/data
-volumes:
- cache:
- driver: local
diff --git a/packages/redis/package.json b/packages/redis/package.json
index d42fa04bb9..61503ed721 100644
--- a/packages/redis/package.json
+++ b/packages/redis/package.json
@@ -25,8 +25,6 @@
"scripts": {
"build": "tsup",
"clean": "rimraf .turbo node_modules dist",
- "db:kill": "docker-compose down",
- "db:start": "docker-compose up -d",
"dev": "tsup --watch",
"lint": "TIMING=1 eslint \"src/**/*.ts*\""
},