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: logos in mes and developers apps

Brad Barbind414ab1669a9
diff --git a/apps/developers/app/components/Topbar/Breadcrumbs.tsx b/apps/developers/app/components/Topbar/Breadcrumbs.tsx
index 1ac9f69e61..de00c09b7b 100644
--- a/apps/developers/app/components/Topbar/Breadcrumbs.tsx
+++ b/apps/developers/app/components/Topbar/Breadcrumbs.tsx
@@ -23,7 +23,7 @@ import {
Breadcrumbs as BreadcrumbsBase,
} from "~/components/Breadcrumbs";
-import { useRouteData } from "~/hooks";
+import { useMode, useRouteData } from "~/hooks";
import { path } from "~/utils/path";
export const BreadcrumbHandle = z.object({
@@ -83,6 +83,7 @@ const Breadcrumbs = () => {
};
function CompanyBreadcrumb() {
+ const mode = useMode();
const routeData = useRouteData<{ company: Company; companies: Company[] }>(
path.to.authenticatedRoot
);
@@ -116,32 +117,36 @@ function CompanyBreadcrumb() {
<DropdownMenuLabel>Companies</DropdownMenuLabel>
<DropdownMenuSeparator />
<DropdownMenuGroup>
- {routeData?.companies.map((c) => (
- <Form
- key={c.companyId}
- method="post"
- action={path.to.companySwitch(c.companyId!)}
- >
- <DropdownMenuItem
- className="flex items-center justify-between w-full"
- asChild
+ {routeData?.companies.map((c) => {
+ const logo =
+ mode === "dark" ? c.logoDarkIcon : c.logoLightIcon;
+ return (
+ <Form
+ key={c.companyId}
+ method="post"
+ action={path.to.companySwitch(c.companyId!)}
>
- <button type="submit">
- <HStack>
- <Avatar
- size="xs"
- name={c.name ?? undefined}
- src={c.logo ?? undefined}
- />
- <span>{c.name}</span>
- </HStack>
- <Badge variant="secondary" className="ml-2">
- {c.employeeType}
- </Badge>
- </button>
- </DropdownMenuItem>
- </Form>
- ))}
+ <DropdownMenuItem
+ className="flex items-center justify-between w-full"
+ asChild
+ >
+ <button type="submit">
+ <HStack>
+ <Avatar
+ size="xs"
+ name={c.name ?? undefined}
+ src={logo ?? undefined}
+ />
+ <span>{c.name}</span>
+ </HStack>
+ <Badge variant="secondary" className="ml-2">
+ {c.employeeType}
+ </Badge>
+ </button>
+ </DropdownMenuItem>
+ </Form>
+ );
+ })}
</DropdownMenuGroup>
</DropdownMenuContent>
</DropdownMenu>
diff --git a/apps/developers/app/hooks/useUser.tsx b/apps/developers/app/hooks/useUser.tsx
index 1de0128234..205021bbc4 100644
--- a/apps/developers/app/hooks/useUser.tsx
+++ b/apps/developers/app/hooks/useUser.tsx
@@ -12,7 +12,10 @@ type PersonalData = {
type Company = {
id: string;
name: string;
- logo: string | null;
+ logoLightIcon: string | null;
+ logoDarkIcon: string | null;
+ logoLight: string | null;
+ logoDark: string | null;
};
type User = PersonalData & {
@@ -47,7 +50,10 @@ function isCompany(value: any): value is Company {
return (
typeof value.id === "string" &&
typeof value.name === "string" &&
- (typeof value.logo === "string" || value.logo === null)
+ (typeof value.logoLightIcon === "string" || value.logoLightIcon === null) &&
+ (typeof value.logoDarkIcon === "string" || value.logoDarkIcon === null) &&
+ (typeof value.logoLight === "string" || value.logoLight === null) &&
+ (typeof value.logoDark === "string" || value.logoDark === null)
);
}
diff --git a/apps/mes/app/components/AvatarMenu.tsx b/apps/mes/app/components/AvatarMenu.tsx
index 9ed01f246b..d2bafc4001 100644
--- a/apps/mes/app/components/AvatarMenu.tsx
+++ b/apps/mes/app/components/AvatarMenu.tsx
@@ -52,6 +52,7 @@ const AvatarMenu = ({
const name = `${user.firstName} ${user.lastName}`;
const mode = useMode();
+ const logo = mode === "dark" ? company.logoDarkIcon : company.logoLightIcon;
const nextMode = mode === "dark" ? "light" : "dark";
const modeSubmitRef = useRef<HTMLButtonElement>(null);
@@ -127,7 +128,7 @@ const AvatarMenu = ({
<Avatar
size="xs"
name={c.name ?? undefined}
- src={c.logo ?? undefined}
+ src={logo ?? undefined}
/>
<span>{c.name}</span>
</HStack>
diff --git a/apps/mes/app/hooks/useUser.tsx b/apps/mes/app/hooks/useUser.tsx
index 1de0128234..34500d1c23 100644
--- a/apps/mes/app/hooks/useUser.tsx
+++ b/apps/mes/app/hooks/useUser.tsx
@@ -12,7 +12,10 @@ type PersonalData = {
type Company = {
id: string;
name: string;
- logo: string | null;
+ logoDarkIcon: string | null;
+ logoLightIcon: string | null;
+ logoDark: string | null;
+ logoLight: string | null;
};
type User = PersonalData & {
@@ -47,7 +50,10 @@ function isCompany(value: any): value is Company {
return (
typeof value.id === "string" &&
typeof value.name === "string" &&
- (typeof value.logo === "string" || value.logo === null)
+ (typeof value.logoDarkIcon === "string" || value.logoDarkIcon === null) &&
+ (typeof value.logoLightIcon === "string" || value.logoLightIcon === null) &&
+ (typeof value.logoDark === "string" || value.logoDark === null) &&
+ (typeof value.logoLight === "string" || value.logoLight === null)
);
}
diff --git a/apps/www/app/hooks/index.ts b/apps/www/app/hooks/index.ts
index a3062fc453..428077e48e 100644
--- a/apps/www/app/hooks/index.ts
+++ b/apps/www/app/hooks/index.ts
@@ -1,6 +1,5 @@
import { useMode } from "./useMode";
import { useOptimisticLocation } from "./useOptimisticLocation";
import { useRouteData } from "./useRouteData";
-import { useUser } from "./useUser";
-export { useMode, useOptimisticLocation, useRouteData, useUser };
+export { useMode, useOptimisticLocation, useRouteData };
diff --git a/apps/www/app/hooks/useUser.tsx b/apps/www/app/hooks/useUser.tsx
deleted file mode 100644
index 1de0128234..0000000000
--- a/apps/www/app/hooks/useUser.tsx
+++ /dev/null
@@ -1,62 +0,0 @@
-import { path } from "~/utils/path";
-import { useRouteData } from "./useRouteData";
-
-type PersonalData = {
- id: string;
- email: string;
- firstName: string;
- lastName: string;
- avatarUrl: string | null;
-};
-
-type Company = {
- id: string;
- name: string;
- logo: string | null;
-};
-
-type User = PersonalData & {
- company: Company;
-};
-
-export function useUser(): User {
- const data = useRouteData<{
- company: unknown;
- user: unknown;
- }>(path.to.authenticatedRoot);
-
- if (
- data?.company &&
- isCompany(data.company) &&
- data?.user &&
- isUser(data.user)
- ) {
- return {
- ...data.user,
- company: data.company,
- };
- }
-
- // TODO: force logout -- the likely cause is development changes
- throw new Error(
- "useUser must be used within an authenticated route. If you are seeing this error, you are likely in development and have changed the session variables. Try deleting the cookies."
- );
-}
-
-function isCompany(value: any): value is Company {
- return (
- typeof value.id === "string" &&
- typeof value.name === "string" &&
- (typeof value.logo === "string" || value.logo === null)
- );
-}
-
-function isUser(value: any): value is User {
- return (
- typeof value.id === "string" &&
- typeof value.email === "string" &&
- typeof value.firstName === "string" &&
- typeof value.lastName === "string" &&
- "avatarUrl" in value
- );
-}