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.

fix: customers and suppliers can CRUD documents

Brad Barbin0d21f38a18b2
diff --git a/apps/carbon/app/modules/users/users.server.ts b/apps/carbon/app/modules/users/users.server.ts
index 5bf88109f9..421e7b1e49 100644
--- a/apps/carbon/app/modules/users/users.server.ts
+++ b/apps/carbon/app/modules/users/users.server.ts
@@ -599,6 +599,9 @@ function makeCustomerPermissions(companyId: string) {
// TODO: this should be more dynamic
const permissions: Record<string, string[]> = {
documents_view: [companyId],
+ documents_create: [companyId],
+ documents_udpate: [companyId],
+ documents_delete: [companyId],
jobs_view: [companyId],
sales_view: [companyId],
parts_view: [companyId],
@@ -766,6 +769,9 @@ function makeSupplierPermissions(companyId: string) {
// TODO: this should be more dynamic
const permissions: Record<string, string[]> = {
documents_view: [companyId],
+ documents_create: [companyId],
+ documents_udpate: [companyId],
+ documents_delete: [companyId],
purchasing_view: [companyId],
parts_view: [companyId],
};
diff --git a/apps/website/src/app/page.tsx b/apps/website/src/app/page.tsx
index 3cfd8bee15..eda4f25eb0 100644
--- a/apps/website/src/app/page.tsx
+++ b/apps/website/src/app/page.tsx
@@ -138,7 +138,7 @@ const features = [
"Built on best open-source technologies for incredible performance and security.",
},
{
- name: "Permissive License",
+ name: "Self-Hostable",
icon: HiCode,
description:
"Unlike other open-source ERPs, you can use Carbon to build your own proprietary systems.",
@@ -152,7 +152,7 @@ const features = [
{
name: "Realtime",
icon: BsLightningCharge,
- description: "All data can be updated in realtime across applications.",
+ description: "All data can be accessed in realtime across applications.",
},
{
name: "Manufacturing",
@@ -160,10 +160,9 @@ const features = [
description: "Carbon has first-class support for American manufacturing.",
},
{
- name: "Single Tenant",
+ name: "Multi-Company",
icon: HiFingerPrint,
- description:
- "You're not sharing databases with other companies. Your database is yours. Take it anytime.",
+ description: "Manage mutliple companies with ease, all in one place.",
},
] as const;
diff --git a/packages/database/supabase/migrations/20230123004436_employee.sql b/packages/database/supabase/migrations/20230123004436_employee.sql
index 1b2d455056..4c37981c99 100644
--- a/packages/database/supabase/migrations/20230123004436_employee.sql
+++ b/packages/database/supabase/migrations/20230123004436_employee.sql
@@ -38,7 +38,7 @@ CREATE OR REPLACE VIEW "companies" AS
FROM "userToCompany" uc
INNER JOIN "company" c
ON c.id = uc."companyId"
- INNER JOIN "employee" e
+ LEFT JOIN "employee" e
ON e.id = uc."userId" AND e."companyId" = uc."companyId"
- INNER JOIN "employeeType" et
+ LEFT JOIN "employeeType" et
ON et.id = e."employeeTypeId";
\ No newline at end of file
diff --git a/packages/react/src/Drawer.tsx b/packages/react/src/Drawer.tsx
index 0357fce7fa..30371d09da 100644
--- a/packages/react/src/Drawer.tsx
+++ b/packages/react/src/Drawer.tsx
@@ -11,6 +11,7 @@ import { forwardRef } from "react";
import { MdClose } from "react-icons/md";
+import { ClientOnly } from "./ClientOnly";
import { cn } from "./utils/cn";
const Drawer = DialogPrimitive.Root;
@@ -182,20 +183,24 @@ const DrawerContent = forwardRef<
},
ref
) => (
- <DrawerPortal position={position} container={container}>
- {overlay && <DrawerOverlay />}
- <DialogPrimitive.Content
- ref={ref}
- className={cn(sheetVariants({ position, size }), className)}
- {...props}
- >
- {children}
- <DialogPrimitive.Close className="absolute right-4 top-4 rounded-full opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-secondary">
- <MdClose className="h-6 w-6" />
- <span className="sr-only">Close</span>
- </DialogPrimitive.Close>
- </DialogPrimitive.Content>
- </DrawerPortal>
+ <ClientOnly fallback={null}>
+ {() => (
+ <DrawerPortal position={position} container={container}>
+ {overlay && <DrawerOverlay />}
+ <DialogPrimitive.Content
+ ref={ref}
+ className={cn(sheetVariants({ position, size }), className)}
+ {...props}
+ >
+ {children}
+ <DialogPrimitive.Close className="absolute right-4 top-4 rounded-full opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-secondary">
+ <MdClose className="h-6 w-6" />
+ <span className="sr-only">Close</span>
+ </DialogPrimitive.Close>
+ </DialogPrimitive.Content>
+ </DrawerPortal>
+ )}
+ </ClientOnly>
)
);
DrawerContent.displayName = DialogPrimitive.Content.displayName;
diff --git a/packages/react/src/Modal.tsx b/packages/react/src/Modal.tsx
index df13d64bc3..e2270993a6 100644
--- a/packages/react/src/Modal.tsx
+++ b/packages/react/src/Modal.tsx
@@ -11,6 +11,7 @@ import type {
import { forwardRef } from "react";
import { MdClose } from "react-icons/md";
+import { ClientOnly } from "./ClientOnly";
import { cn } from "./utils/cn";
const Modal = DialogPrimitive.Root;
@@ -73,21 +74,25 @@ const ModalContent = forwardRef<
ComponentPropsWithoutRef<typeof DialogPrimitive.Content> &
VariantProps<typeof ModalContentVariants>
>(({ className, children, size, ...props }, ref) => (
- <ModalPortal>
- <ModalOverlay>
- <DialogPrimitive.Content
- ref={ref}
- className={cn(ModalContentVariants({ size }), className)}
- {...props}
- >
- {children}
- <DialogPrimitive.Close className="absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-foreground-muted">
- <MdClose className="h-4 w-4" />
- <span className="sr-only">Close</span>
- </DialogPrimitive.Close>
- </DialogPrimitive.Content>
- </ModalOverlay>
- </ModalPortal>
+ <ClientOnly fallback={null}>
+ {() => (
+ <ModalPortal>
+ <ModalOverlay>
+ <DialogPrimitive.Content
+ ref={ref}
+ className={cn(ModalContentVariants({ size }), className)}
+ {...props}
+ >
+ {children}
+ <DialogPrimitive.Close className="absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-foreground-muted">
+ <MdClose className="h-4 w-4" />
+ <span className="sr-only">Close</span>
+ </DialogPrimitive.Close>
+ </DialogPrimitive.Content>
+ </ModalOverlay>
+ </ModalPortal>
+ )}
+ </ClientOnly>
));
ModalContent.displayName = DialogPrimitive.Content.displayName;