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.
TypeScript ai-agentsbill-of-materialserpinventory-managementleanmanufacturingmanufacturing-execution-systemmcp-servermesmrpopen-source-erppostgresqlproduction-planningqmsquality-management-systemreact-routerself-hostedsupabasetraceabilitytypescript
fix: company switcher in mes
Brad Barbinb9e6930a03a7
diff --git a/apps/mes/app/components/AppSidebar.tsx b/apps/mes/app/components/AppSidebar.tsxindex 9987829544..6050084e43 100644--- a/apps/mes/app/components/AppSidebar.tsx+++ b/apps/mes/app/components/AppSidebar.tsx@@ -143,12 +143,22 @@ export function TeamSwitcher({{companies.map((c, index) => {const logo = mode === "dark" ? c.logoDarkIcon : c.logoLightIcon;return (- <DropdownMenuItem key={c.name} className="gap-2 p-2">- <div className="flex size-6 items-center justify-center rounded-sm border">- <Avatar src={logo ?? undefined} name={c.name ?? ""} />- </div>- {c.name}- </DropdownMenuItem>+ <Form+ key={c.companyId}+ method="post"+ action={path.to.companySwitch(c.companyId!)}+ >+ <DropdownMenuItem key={c.name} className="gap-2 p-2" asChild>+ <button type="submit">+ <Avatar+ src={logo ?? undefined}+ name={c.name ?? ""}+ className="rounded-md"+ />+ {c.name}+ </button>+ </DropdownMenuItem>+ </Form>);})}</DropdownMenuContent>diff --git a/apps/mes/app/routes/x+/company.switch.$companyId.tsx b/apps/mes/app/routes/x+/company.switch.$companyId.tsxindex 72da1a99b7..d9325f92e3 100644--- a/apps/mes/app/routes/x+/company.switch.$companyId.tsx+++ b/apps/mes/app/routes/x+/company.switch.$companyId.tsx@@ -11,9 +11,12 @@ import { getLocation, setLocation } from "~/services/location.server";import { path, requestReferrer } from "~/utils/path";export async function action({ request, params }: ActionFunctionArgs) {+ console.log("company switch");const { client, userId } = await requirePermissions(request, {});const companies = await getCompanies(client, userId);+ console.log("companies", companies);+if (companies.error) {throw redirect(requestReferrer(request) ?? path.to.authenticatedRoot,@@ -33,6 +36,8 @@ export async function action({ request, params }: ActionFunctionArgs) {await destroyAuthSession(request);}+ console.log("companyId", companyId);+const sessionCookie = await updateCompanySession(request, companyId!);const companyIdCookie = setCompanyId(companyId!);const storedLocations = await getLocation(request, client, {@@ -40,6 +45,8 @@ export async function action({ request, params }: ActionFunctionArgs) {companyId: companyId!,});+ console.log("storedLocations", storedLocations);+if (storedLocations.updated) {const locationCookie = await setLocation(companyId!,diff --git a/apps/mes/app/utils/path.ts b/apps/mes/app/utils/path.tsindex 12458a5f5d..658d7e9498 100644--- a/apps/mes/app/utils/path.ts+++ b/apps/mes/app/utils/path.ts@@ -22,6 +22,8 @@ export const path = {assigned: `${x}/assigned`,authenticatedRoot: x,callback: "/callback",+ companySwitch: (companyId: string) =>+ generatePath(`${x}/company/switch/${companyId}`),complete: `${x}/complete`,endShift: `${x}/end-shift`,feedback: `${x}/feedback`,