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.

chore: put customer portals behind businesss plan

Sidwebworks22181263886b
diff --git a/apps/erp/app/modules/sales/ui/CustomerPortals/CustomerPortalsUpgradeOverlay.tsx b/apps/erp/app/modules/sales/ui/CustomerPortals/CustomerPortalsUpgradeOverlay.tsx
new file mode 100644
index 0000000000..100f683a67
--- /dev/null
+++ b/apps/erp/app/modules/sales/ui/CustomerPortals/CustomerPortalsUpgradeOverlay.tsx
@@ -0,0 +1,83 @@
+import type { Database } from "@carbon/database";
+import { Trans } from "@lingui/react/macro";
+import { LuGlobe } from "react-icons/lu";
+import {
+ UpgradeOverlay,
+ UpgradeOverlayActions,
+ UpgradeOverlayCard,
+ UpgradeOverlayContent,
+ UpgradeOverlayDescription,
+ UpgradeOverlayIcon,
+ UpgradeOverlayPreview,
+ UpgradeOverlayTitle,
+ UpgradeOverlayUpgradeButton
+} from "~/components/UpgradeOverlay";
+import CustomerPortalsTable from "./CustomerPortalsTable";
+
+type CustomerPortal = Database["public"]["Tables"]["externalLink"]["Row"];
+
+const mockPortals: CustomerPortal[] = [
+ {
+ id: "mock-1",
+ documentType: "Customer",
+ documentId: "mock-customer-1",
+ customerId: "mock-customer-1",
+ supplierId: null,
+ expiresAt: null,
+ companyId: "mock",
+ createdAt: "2026-01-15T10:00:00Z"
+ },
+ {
+ id: "mock-2",
+ documentType: "Customer",
+ documentId: "mock-customer-2",
+ customerId: "mock-customer-2",
+ supplierId: null,
+ expiresAt: null,
+ companyId: "mock",
+ createdAt: "2026-02-01T09:30:00Z"
+ },
+ {
+ id: "mock-3",
+ documentType: "Customer",
+ documentId: "mock-customer-3",
+ customerId: "mock-customer-3",
+ supplierId: null,
+ expiresAt: null,
+ companyId: "mock",
+ createdAt: "2026-03-20T14:00:00Z"
+ }
+];
+
+export default function CustomerPortalsUpgradeOverlay() {
+ return (
+ <UpgradeOverlay>
+ <UpgradeOverlayPreview>
+ <CustomerPortalsTable
+ appUrl="https://app.carbon.ms"
+ data={mockPortals}
+ count={mockPortals.length}
+ />
+ </UpgradeOverlayPreview>
+ <UpgradeOverlayCard>
+ <UpgradeOverlayIcon>
+ <LuGlobe className="size-6 text-muted-foreground" />
+ </UpgradeOverlayIcon>
+ <UpgradeOverlayContent>
+ <UpgradeOverlayTitle>
+ <Trans>Customer Portals</Trans>
+ </UpgradeOverlayTitle>
+ <UpgradeOverlayDescription>
+ <Trans>
+ Share a branded portal link so customers can track their orders
+ and documents.
+ </Trans>
+ </UpgradeOverlayDescription>
+ </UpgradeOverlayContent>
+ <UpgradeOverlayActions>
+ <UpgradeOverlayUpgradeButton />
+ </UpgradeOverlayActions>
+ </UpgradeOverlayCard>
+ </UpgradeOverlay>
+ );
+}
diff --git a/apps/erp/app/modules/sales/ui/CustomerPortals/index.ts b/apps/erp/app/modules/sales/ui/CustomerPortals/index.ts
index 8fa118481f..84cc10b62f 100644
--- a/apps/erp/app/modules/sales/ui/CustomerPortals/index.ts
+++ b/apps/erp/app/modules/sales/ui/CustomerPortals/index.ts
@@ -1,2 +1,3 @@
export { default as CustomerPortalForm } from "./CustomerPortalForm";
export { default as CustomerPortalsTable } from "./CustomerPortalsTable";
+export { default as CustomerPortalsUpgradeOverlay } from "./CustomerPortalsUpgradeOverlay";
diff --git a/apps/erp/app/routes/share+/customer.$id.$.tsx b/apps/erp/app/routes/share+/customer.$id.$.tsx
index 1562213fdc..f9f1b998a4 100644
--- a/apps/erp/app/routes/share+/customer.$id.$.tsx
+++ b/apps/erp/app/routes/share+/customer.$id.$.tsx
@@ -1,4 +1,5 @@
import { getCarbonServiceRole } from "@carbon/auth/client.server";
+import { companyHasPlan } from "@carbon/ee/plan.server";
import { Ratelimit, redis } from "@carbon/kv";
import { supportedModelTypes } from "@carbon/utils";
import type { LoaderFunctionArgs } from "react-router";
@@ -66,6 +67,13 @@ export let loader = async ({ params, request }: LoaderFunctionArgs) => {
throw new Error("Customer not found");
}
+ const hasPlan = await companyHasPlan(serviceRole, customer.data.companyId, {
+ feature: "CUSTOMER_PORTALS"
+ });
+ if (!hasPlan) {
+ return new Response(null, { status: 403 });
+ }
+
let path = params["*"];
let bucket = "private"; // TODO: refactor to use companyId when we separate the storage buckets
diff --git a/apps/erp/app/routes/share+/customer.$id.tsx b/apps/erp/app/routes/share+/customer.$id.tsx
index 1697fbb3d8..2cb8e022ba 100644
--- a/apps/erp/app/routes/share+/customer.$id.tsx
+++ b/apps/erp/app/routes/share+/customer.$id.tsx
@@ -1,4 +1,5 @@
import { getCarbonServiceRole } from "@carbon/auth/client.server";
+import { companyHasPlan } from "@carbon/ee/plan.server";
import { Avatar } from "@carbon/react";
import { formatDate } from "@carbon/utils";
import { useLocale, useNumberFormatter } from "@react-aria/i18n";
@@ -60,6 +61,13 @@ export async function loader({ params, request }: LoaderFunctionArgs) {
throw new Error("Customer not found");
}
+ const hasPlan = await companyHasPlan(serviceRole, customer.data.companyId, {
+ feature: "CUSTOMER_PORTALS"
+ });
+ if (!hasPlan) {
+ throw new Response("Not found", { status: 404 });
+ }
+
const url = new URL(request.url);
const searchParams = new URLSearchParams(url.search);
const search = searchParams.get("search");
diff --git a/apps/erp/app/routes/x+/sales+/customer-portals.$id.tsx b/apps/erp/app/routes/x+/sales+/customer-portals.$id.tsx
index 8fbfc25019..7fb6b52327 100644
--- a/apps/erp/app/routes/x+/sales+/customer-portals.$id.tsx
+++ b/apps/erp/app/routes/x+/sales+/customer-portals.$id.tsx
@@ -1,6 +1,7 @@
import { assertIsPost, error, notFound, success } from "@carbon/auth";
import { requirePermissions } from "@carbon/auth/auth.server";
import { flash } from "@carbon/auth/session.server";
+import { requirePlan } from "@carbon/ee/plan.server";
import { validationError, validator } from "@carbon/form";
import type { ActionFunctionArgs, LoaderFunctionArgs } from "react-router";
import { data, redirect, useLoaderData, useNavigate } from "react-router";
@@ -38,10 +39,18 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
export async function action({ request }: ActionFunctionArgs) {
assertIsPost(request);
- const { client } = await requirePermissions(request, {
+ const { client, companyId } = await requirePermissions(request, {
update: "sales"
});
+ await requirePlan({
+ request,
+ client,
+ companyId,
+ feature: "CUSTOMER_PORTALS",
+ redirectTo: path.to.customerPortals
+ });
+
const formData = await request.formData();
const validation = await validator(customerPortalValidator).validate(
formData
diff --git a/apps/erp/app/routes/x+/sales+/customer-portals.delete.$id.tsx b/apps/erp/app/routes/x+/sales+/customer-portals.delete.$id.tsx
index a429a8d2a3..a89bfe05c0 100644
--- a/apps/erp/app/routes/x+/sales+/customer-portals.delete.$id.tsx
+++ b/apps/erp/app/routes/x+/sales+/customer-portals.delete.$id.tsx
@@ -1,6 +1,7 @@
import { error, notFound, success } from "@carbon/auth";
import { requirePermissions } from "@carbon/auth/auth.server";
import { flash } from "@carbon/auth/session.server";
+import { requirePlan } from "@carbon/ee/plan.server";
import { useLingui } from "@lingui/react/macro";
import type { ActionFunctionArgs, LoaderFunctionArgs } from "react-router";
import { redirect, useLoaderData, useNavigate, useParams } from "react-router";
@@ -31,10 +32,18 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
}
export async function action({ request, params }: ActionFunctionArgs) {
- const { client } = await requirePermissions(request, {
+ const { client, companyId } = await requirePermissions(request, {
delete: "sales"
});
+ await requirePlan({
+ request,
+ client,
+ companyId,
+ feature: "CUSTOMER_PORTALS",
+ redirectTo: path.to.customerPortals
+ });
+
const { id } = params;
if (!id) {
throw redirect(
diff --git a/apps/erp/app/routes/x+/sales+/customer-portals.new.tsx b/apps/erp/app/routes/x+/sales+/customer-portals.new.tsx
index 887b5d7e10..9cf58c8385 100644
--- a/apps/erp/app/routes/x+/sales+/customer-portals.new.tsx
+++ b/apps/erp/app/routes/x+/sales+/customer-portals.new.tsx
@@ -1,6 +1,7 @@
import { assertIsPost, error, success } from "@carbon/auth";
import { requirePermissions } from "@carbon/auth/auth.server";
import { flash } from "@carbon/auth/session.server";
+import { requirePlan } from "@carbon/ee/plan.server";
import { validationError, validator } from "@carbon/form";
import type { ActionFunctionArgs, LoaderFunctionArgs } from "react-router";
import { redirect, useNavigate } from "react-router";
@@ -24,6 +25,14 @@ export async function action({ request }: ActionFunctionArgs) {
create: "sales"
});
+ await requirePlan({
+ request,
+ client,
+ companyId,
+ feature: "CUSTOMER_PORTALS",
+ redirectTo: path.to.customerPortals
+ });
+
const formData = await request.formData();
const modal = formData.get("type") === "modal";
diff --git a/apps/erp/app/routes/x+/sales+/customer-portals.tsx b/apps/erp/app/routes/x+/sales+/customer-portals.tsx
index b9d1c815ca..08bf747463 100644
--- a/apps/erp/app/routes/x+/sales+/customer-portals.tsx
+++ b/apps/erp/app/routes/x+/sales+/customer-portals.tsx
@@ -4,7 +4,11 @@ import { VStack } from "@carbon/react";
import { msg } from "@lingui/core/macro";
import type { LoaderFunctionArgs } from "react-router";
import { Outlet, useLoaderData } from "react-router";
-import { CustomerPortalsTable } from "~/modules/sales/ui/CustomerPortals";
+import { usePlanGate } from "~/hooks/usePlanGate";
+import {
+ CustomerPortalsTable,
+ CustomerPortalsUpgradeOverlay
+} from "~/modules/sales/ui/CustomerPortals";
import { getCustomerPortals } from "~/modules/shared";
import type { Handle } from "~/utils/handle";
import { path } from "~/utils/path";
@@ -41,6 +45,11 @@ export async function loader({ request }: LoaderFunctionArgs) {
export default function CustomerPortalsRoute() {
const { appUrl, data, count } = useLoaderData<typeof loader>();
+ const { isGated } = usePlanGate({ feature: "CUSTOMER_PORTALS" });
+
+ if (isGated) {
+ return <CustomerPortalsUpgradeOverlay />;
+ }
return (
<VStack spacing={0} className="h-full">
diff --git a/packages/ee/src/plan.ts b/packages/ee/src/plan.ts
index 6698203e31..52aa3e1d98 100644
--- a/packages/ee/src/plan.ts
+++ b/packages/ee/src/plan.ts
@@ -12,7 +12,8 @@ export const FEATURE_PLANS = {
ITEM_RULES: [Plan.Business, Plan.Partner],
AUDIT_LOG: [Plan.Business, Plan.Partner],
EMAIL_NOTIFICATIONS: [Plan.Business, Plan.Partner],
- STORAGE_RULES: [Plan.Business, Plan.Partner]
+ STORAGE_RULES: [Plan.Business, Plan.Partner],
+ CUSTOMER_PORTALS: [Plan.Business, Plan.Partner]
} as const satisfies Record<string, Plan[]>;
export type Feature = keyof typeof FEATURE_PLANS;
diff --git a/packages/locale/locales/de/erp.po b/packages/locale/locales/de/erp.po
index 0dade6e7f2..528fed3bb5 100644
--- a/packages/locale/locales/de/erp.po
+++ b/packages/locale/locales/de/erp.po
@@ -7259,6 +7259,9 @@ msgstr "Formen"
msgid "Share"
msgstr "Teilen"
+msgid "Share a branded portal link so customers can track their orders and documents."
+msgstr ""
+
msgid "Share Link"
msgstr "Link teilen"
diff --git a/packages/locale/locales/en/erp.po b/packages/locale/locales/en/erp.po
index 7d2f23d5b2..69482dc3a3 100644
--- a/packages/locale/locales/en/erp.po
+++ b/packages/locale/locales/en/erp.po
@@ -7259,6 +7259,9 @@ msgstr "Shapes"
msgid "Share"
msgstr "Share"
+msgid "Share a branded portal link so customers can track their orders and documents."
+msgstr "Share a branded portal link so customers can track their orders and documents."
+
msgid "Share Link"
msgstr "Share Link"
diff --git a/packages/locale/locales/es/erp.po b/packages/locale/locales/es/erp.po
index 198e3e99ef..1e2ccd01ad 100644
--- a/packages/locale/locales/es/erp.po
+++ b/packages/locale/locales/es/erp.po
@@ -7259,6 +7259,9 @@ msgstr "Formas"
msgid "Share"
msgstr "Compartir"
+msgid "Share a branded portal link so customers can track their orders and documents."
+msgstr ""
+
msgid "Share Link"
msgstr "Enlace compartido"
diff --git a/packages/locale/locales/fr/erp.po b/packages/locale/locales/fr/erp.po
index c5639c7c88..0fe745022d 100644
--- a/packages/locale/locales/fr/erp.po
+++ b/packages/locale/locales/fr/erp.po
@@ -7259,6 +7259,9 @@ msgstr "Formes"
msgid "Share"
msgstr "Partager"
+msgid "Share a branded portal link so customers can track their orders and documents."
+msgstr ""
+
msgid "Share Link"
msgstr "Lien de partage"
diff --git a/packages/locale/locales/hi/erp.po b/packages/locale/locales/hi/erp.po
index a77cd36f76..12e99c101d 100644
--- a/packages/locale/locales/hi/erp.po
+++ b/packages/locale/locales/hi/erp.po
@@ -7259,6 +7259,9 @@ msgstr "आकार"
msgid "Share"
msgstr "साझा करें"
+msgid "Share a branded portal link so customers can track their orders and documents."
+msgstr ""
+
msgid "Share Link"
msgstr "लिंक साझा करें"
diff --git a/packages/locale/locales/it/erp.po b/packages/locale/locales/it/erp.po
index befa9c886a..deb6e6f5a4 100644
--- a/packages/locale/locales/it/erp.po
+++ b/packages/locale/locales/it/erp.po
@@ -7259,6 +7259,9 @@ msgstr "Forme"
msgid "Share"
msgstr "Condividi"
+msgid "Share a branded portal link so customers can track their orders and documents."
+msgstr ""
+
msgid "Share Link"
msgstr "Condividi Link"
diff --git a/packages/locale/locales/ja/erp.po b/packages/locale/locales/ja/erp.po
index 24da7dd6ce..472057abe2 100644
--- a/packages/locale/locales/ja/erp.po
+++ b/packages/locale/locales/ja/erp.po
@@ -7259,6 +7259,9 @@ msgstr "形状"
msgid "Share"
msgstr "共有"
+msgid "Share a branded portal link so customers can track their orders and documents."
+msgstr ""
+
msgid "Share Link"
msgstr "リンクを共有"
diff --git a/packages/locale/locales/pl/erp.po b/packages/locale/locales/pl/erp.po
index 2d440098a0..b133b9f5a5 100644
--- a/packages/locale/locales/pl/erp.po
+++ b/packages/locale/locales/pl/erp.po
@@ -7259,6 +7259,9 @@ msgstr "Kształty"
msgid "Share"
msgstr "Udostępnij"
+msgid "Share a branded portal link so customers can track their orders and documents."
+msgstr ""
+
msgid "Share Link"
msgstr "Udostępnij Link"
diff --git a/packages/locale/locales/pt/erp.po b/packages/locale/locales/pt/erp.po
index 6cc4c54da1..e06afa0455 100644
--- a/packages/locale/locales/pt/erp.po
+++ b/packages/locale/locales/pt/erp.po
@@ -7259,6 +7259,9 @@ msgstr "Formas"
msgid "Share"
msgstr "Partilhar"
+msgid "Share a branded portal link so customers can track their orders and documents."
+msgstr ""
+
msgid "Share Link"
msgstr "Compartilhar Link"
diff --git a/packages/locale/locales/ru/erp.po b/packages/locale/locales/ru/erp.po
index 89a46b4bdc..86023b4a44 100644
--- a/packages/locale/locales/ru/erp.po
+++ b/packages/locale/locales/ru/erp.po
@@ -7259,6 +7259,9 @@ msgstr "Формы"
msgid "Share"
msgstr "Поделиться"
+msgid "Share a branded portal link so customers can track their orders and documents."
+msgstr ""
+
msgid "Share Link"
msgstr "Поделиться ссылкой"
diff --git a/packages/locale/locales/zh/erp.po b/packages/locale/locales/zh/erp.po
index 4f6b3e2739..45c2d7f5db 100644
--- a/packages/locale/locales/zh/erp.po
+++ b/packages/locale/locales/zh/erp.po
@@ -7259,6 +7259,9 @@ msgstr "形状"
msgid "Share"
msgstr "分享"
+msgid "Share a branded portal link so customers can track their orders and documents."
+msgstr ""
+
msgid "Share Link"
msgstr "分享链接"