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.

feat: banner to acknowledge carbon university

Brad Barbin56b095cfb6f6
diff --git a/apps/erp/app/components/Layout/Topbar/Topbar.tsx b/apps/erp/app/components/Layout/Topbar/Topbar.tsx
index f10d38c73d..eb715d04b9 100644
--- a/apps/erp/app/components/Layout/Topbar/Topbar.tsx
+++ b/apps/erp/app/components/Layout/Topbar/Topbar.tsx
@@ -1,13 +1,13 @@
import { HStack } from "@carbon/react";
+import { Agent } from "~/components/Agent/Agent";
import { usePermissions, useUser } from "~/hooks";
+import { useFlags } from "~/hooks/useFlags";
import AvatarMenu from "../../AvatarMenu";
import Breadcrumbs from "./Breadcrumbs";
import CreateMenu from "./CreateMenu";
import Feedback from "./Feedback";
import Notifications from "./Notifications";
import Search from "./Search";
-import { useFlags } from "~/hooks/useFlags";
-import { Agent } from "~/components/Agent/Agent";
const Topbar = () => {
const permissions = usePermissions();
@@ -17,7 +17,7 @@ const Topbar = () => {
const { isInternal } = useFlags();
return (
- <div className="grid grid-cols-[1fr_200px_1fr] bg-background text-foreground px-4 top-0 sticky z-10 items-center">
+ <div className="h-[49px] grid grid-cols-[1fr_200px_1fr] bg-background text-foreground px-4 top-0 sticky z-10 items-center">
<div className="flex-1">
<Breadcrumbs />
</div>
diff --git a/apps/erp/app/routes/x+/_layout.tsx b/apps/erp/app/routes/x+/_layout.tsx
index 398de1af5e..e7122df9ab 100644
--- a/apps/erp/app/routes/x+/_layout.tsx
+++ b/apps/erp/app/routes/x+/_layout.tsx
@@ -1,5 +1,10 @@
-import { TooltipProvider, useMount } from "@carbon/react";
-import { Outlet, useLoaderData, useNavigation } from "@remix-run/react";
+import { Button, IconButton, TooltipProvider, useMount } from "@carbon/react";
+import {
+ Outlet,
+ useFetcher,
+ useLoaderData,
+ useNavigation,
+} from "@remix-run/react";
import type { LoaderFunctionArgs } from "@vercel/remix";
import { json, redirect } from "@vercel/remix";
import NProgress from "nprogress";
@@ -25,7 +30,7 @@ import { path } from "~/utils/path";
import { getStripeCustomerByCompanyId } from "@carbon/lib/stripe.server";
import type { ShouldRevalidateFunction } from "@remix-run/react";
import posthog from "posthog-js";
-import { useUser } from "~/hooks";
+import { LuArrowUpRight, LuX } from "react-icons/lu";
import { getSavedViews } from "~/modules/shared/shared.service";
export const config = {
@@ -40,6 +45,7 @@ export const shouldRevalidate: ShouldRevalidateFunction = ({
currentUrl.pathname.startsWith("/x/settings") ||
currentUrl.pathname.startsWith("/x/users") ||
currentUrl.pathname.startsWith("/refresh-session") ||
+ currentUrl.pathname.startsWith("/x/acknowledge") ||
currentUrl.pathname.startsWith("/x/shared/views")
) {
return true;
@@ -117,11 +123,13 @@ export async function loader({ request }: LoaderFunctionArgs) {
}
export default function AuthenticatedRoute() {
- const { session } = useLoaderData<typeof loader>();
- const user = useUser();
+ const { session, user } = useLoaderData<typeof loader>();
+
const transition = useNavigation();
useMount(() => {
+ if (!user) return;
+
posthog.identify(user.id, {
email: user.email,
name: `${user.firstName} ${user.lastName}`,
@@ -146,6 +154,7 @@ export default function AuthenticatedRoute() {
<RealtimeDataProvider>
<TooltipProvider>
<div className="flex flex-col h-screen">
+ {user?.acknowledgedUniversity ? null : <UniversityBanner />}
<Topbar />
<div className="flex flex-1 h-[calc(100vh-49px)] relative">
<PrimaryNavigation />
@@ -160,3 +169,40 @@ export default function AuthenticatedRoute() {
</div>
);
}
+
+function UniversityBanner() {
+ const fetcher = useFetcher<{}>();
+
+ return (
+ <div className="fixed bottom-3 left-1/2 -translate-x-1/2 flex items-center justify-between gap-10 bg-[#212278] dark:bg-[#2f31ae] text-white py-1 px-2 rounded-lg z-50 shadow-md">
+ <div />
+ <fetcher.Form method="post" action={path.to.acknowledge}>
+ <input type="hidden" name="intent" value="university" />
+ <input
+ type="hidden"
+ name="redirectTo"
+ value="https://learn.carbonos.dev"
+ />
+ <Button
+ type="submit"
+ variant="ghost"
+ size="lg"
+ className="hover:bg-transparent text-white hover:text-white"
+ rightIcon={<LuArrowUpRight />}
+ >
+ <span>Introducing Carbon University</span>
+ </Button>
+ </fetcher.Form>
+ <fetcher.Form method="post" action={path.to.acknowledge}>
+ <input type="hidden" name="intent" value="university" />
+ <IconButton
+ type="submit"
+ aria-label="Close"
+ variant="ghost"
+ className="text-white dark:text-white hover:text-white"
+ icon={<LuX />}
+ />
+ </fetcher.Form>
+ </div>
+ );
+}
diff --git a/apps/erp/app/routes/x+/acknowledge.tsx b/apps/erp/app/routes/x+/acknowledge.tsx
new file mode 100644
index 0000000000..7f4ed36731
--- /dev/null
+++ b/apps/erp/app/routes/x+/acknowledge.tsx
@@ -0,0 +1,26 @@
+import { requirePermissions } from "@carbon/auth/auth.server";
+import type { ActionFunctionArgs } from "@vercel/remix";
+import { redirect } from "@vercel/remix";
+
+export async function action({ request }: ActionFunctionArgs) {
+ const { client, userId } = await requirePermissions(request, {});
+
+ const formData = await request.formData();
+ const intent = formData.get("intent") as string;
+ const redirectTo = formData.get("redirectTo") as string | null;
+
+ if (intent === "university") {
+ await client
+ .from("user")
+ .update({
+ acknowledgedUniversity: true,
+ })
+ .eq("id", userId);
+
+ if (redirectTo) {
+ throw redirect(redirectTo);
+ }
+ }
+
+ return null;
+}
diff --git a/apps/erp/app/utils/path.ts b/apps/erp/app/utils/path.ts
index 21271307ae..b712355872 100644
--- a/apps/erp/app/utils/path.ts
+++ b/apps/erp/app/utils/path.ts
@@ -277,6 +277,7 @@ export const path = {
user: `${onboarding}/user`,
},
authenticatedRoot: x,
+ acknowledge: `${x}/acknowledge`,
abilities: `${x}/resources/abilities`,
ability: (id: string) => generatePath(`${x}/resources/ability/${id}`),
account: `${x}/account`,
diff --git a/packages/database/src/types.ts b/packages/database/src/types.ts
index 88ad2957d0..ba7537883b 100644
--- a/packages/database/src/types.ts
+++ b/packages/database/src/types.ts
@@ -33362,6 +33362,7 @@ export type Database = {
user: {
Row: {
about: string
+ acknowledgedUniversity: boolean
active: boolean | null
admin: boolean | null
avatarUrl: string | null
@@ -33376,6 +33377,7 @@ export type Database = {
}
Insert: {
about?: string
+ acknowledgedUniversity?: boolean
active?: boolean | null
admin?: boolean | null
avatarUrl?: string | null
@@ -33390,6 +33392,7 @@ export type Database = {
}
Update: {
about?: string
+ acknowledgedUniversity?: boolean
active?: boolean | null
admin?: boolean | null
avatarUrl?: string | null
@@ -39851,14 +39854,14 @@ export type Database = {
Relationships: [
{
foreignKeyName: "address_countryCode_fkey"
- columns: ["supplierCountryCode"]
+ columns: ["customerCountryCode"]
isOneToOne: false
referencedRelation: "country"
referencedColumns: ["alpha2"]
},
{
foreignKeyName: "address_countryCode_fkey"
- columns: ["customerCountryCode"]
+ columns: ["supplierCountryCode"]
isOneToOne: false
referencedRelation: "country"
referencedColumns: ["alpha2"]
@@ -42093,14 +42096,14 @@ export type Database = {
Relationships: [
{
foreignKeyName: "address_countryCode_fkey"
- columns: ["customerCountryCode"]
+ columns: ["invoiceCountryCode"]
isOneToOne: false
referencedRelation: "country"
referencedColumns: ["alpha2"]
},
{
foreignKeyName: "address_countryCode_fkey"
- columns: ["invoiceCountryCode"]
+ columns: ["customerCountryCode"]
isOneToOne: false
referencedRelation: "country"
referencedColumns: ["alpha2"]
diff --git a/packages/database/supabase/functions/lib/types.ts b/packages/database/supabase/functions/lib/types.ts
index 88ad2957d0..ba7537883b 100644
--- a/packages/database/supabase/functions/lib/types.ts
+++ b/packages/database/supabase/functions/lib/types.ts
@@ -33362,6 +33362,7 @@ export type Database = {
user: {
Row: {
about: string
+ acknowledgedUniversity: boolean
active: boolean | null
admin: boolean | null
avatarUrl: string | null
@@ -33376,6 +33377,7 @@ export type Database = {
}
Insert: {
about?: string
+ acknowledgedUniversity?: boolean
active?: boolean | null
admin?: boolean | null
avatarUrl?: string | null
@@ -33390,6 +33392,7 @@ export type Database = {
}
Update: {
about?: string
+ acknowledgedUniversity?: boolean
active?: boolean | null
admin?: boolean | null
avatarUrl?: string | null
@@ -39851,14 +39854,14 @@ export type Database = {
Relationships: [
{
foreignKeyName: "address_countryCode_fkey"
- columns: ["supplierCountryCode"]
+ columns: ["customerCountryCode"]
isOneToOne: false
referencedRelation: "country"
referencedColumns: ["alpha2"]
},
{
foreignKeyName: "address_countryCode_fkey"
- columns: ["customerCountryCode"]
+ columns: ["supplierCountryCode"]
isOneToOne: false
referencedRelation: "country"
referencedColumns: ["alpha2"]
@@ -42093,14 +42096,14 @@ export type Database = {
Relationships: [
{
foreignKeyName: "address_countryCode_fkey"
- columns: ["customerCountryCode"]
+ columns: ["invoiceCountryCode"]
isOneToOne: false
referencedRelation: "country"
referencedColumns: ["alpha2"]
},
{
foreignKeyName: "address_countryCode_fkey"
- columns: ["invoiceCountryCode"]
+ columns: ["customerCountryCode"]
isOneToOne: false
referencedRelation: "country"
referencedColumns: ["alpha2"]
diff --git a/packages/database/supabase/migrations/20250619100940_billing.sql b/packages/database/supabase/migrations/20250619100940_billing.sql
index da040f0b30..ebf4e1557c 100644
--- a/packages/database/supabase/migrations/20250619100940_billing.sql
+++ b/packages/database/supabase/migrations/20250619100940_billing.sql
@@ -1,6 +1,7 @@
ALTER TABLE "company" ADD COLUMN "ownerId" TEXT;
ALTER TABLE "user" ALTER COLUMN "firstName" SET DEFAULT '';
ALTER TABLE "user" ALTER COLUMN "lastName" SET DEFAULT '';
+ALTER TABLE "user" ADD COLUMN "acknowledgedUniversity" BOOLEAN NOT NULL DEFAULT FALSE;
ALTER POLICY "Users can view other users from their same company" ON "user" USING (
id = auth.uid()::text OR