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.

style: add employee avatar group to estimates vs actuals

Brad Barbinf5e548f091e9
diff --git a/apps/carbon/app/components/EmployeeAvatarGroup.tsx b/apps/carbon/app/components/EmployeeAvatarGroup.tsx
index 625b3c2f01..09d936a0fd 100644
--- a/apps/carbon/app/components/EmployeeAvatarGroup.tsx
+++ b/apps/carbon/app/components/EmployeeAvatarGroup.tsx
@@ -9,11 +9,13 @@ import Avatar from "./Avatar";
type EmployeeAvatarProps = AvatarProps & {
employeeIds: string[];
+ limit?: number;
};
const EmployeeAvatarGroup = ({
employeeIds,
size,
+ limit = 5,
...props
}: EmployeeAvatarProps) => {
const [people] = usePeople();
@@ -25,7 +27,7 @@ const EmployeeAvatarGroup = ({
}
return (
- <AvatarGroup size={size ?? "xs"} limit={5}>
+ <AvatarGroup size={size ?? "xs"} limit={limit}>
<AvatarGroupList>
{employees.map((employee, index: number) => (
<Avatar
diff --git a/apps/carbon/app/modules/production/ui/Jobs/JobEstimatesVsActuals.tsx b/apps/carbon/app/modules/production/ui/Jobs/JobEstimatesVsActuals.tsx
index 0f22ff1362..9a355c7456 100644
--- a/apps/carbon/app/modules/production/ui/Jobs/JobEstimatesVsActuals.tsx
+++ b/apps/carbon/app/modules/production/ui/Jobs/JobEstimatesVsActuals.tsx
@@ -32,6 +32,7 @@ import {
toZoned,
} from "@internationalized/date";
import { LuExternalLink } from "react-icons/lu";
+import { EmployeeAvatarGroup } from "~/components";
import { usePercentFormatter } from "~/hooks";
import { makeDurations } from "~/utils/duration";
import { path } from "~/utils/path";
@@ -128,6 +129,22 @@ const JobEstimatesVsActuals = ({
return quantity ?? 0;
};
+ const getEmployeeIds = (
+ operation: Operation,
+ type: "Setup" | "Labor" | "Machine"
+ ) => {
+ const operationEvents = productionEvents.filter(
+ (pe) => pe.jobOperationId === operation.id && pe.type === type
+ );
+ const employeeIds = operationEvents.reduce((acc, pe) => {
+ if (pe.employeeId) {
+ acc.add(pe.employeeId);
+ }
+ return acc;
+ }, new Set<string>());
+ return Array.from(employeeIds);
+ };
+
return (
<Card>
<HStack className="justify-between items-start">
@@ -234,12 +251,22 @@ const JobEstimatesVsActuals = ({
) {
return null;
}
+ const employeeIds = getEmployeeIds(operation, type);
return (
<Tr key={type} className="border-b border-border">
<Td className="border-r border-border pl-10">
- <HStack>
- <TimeTypeIcon type={type} />
- <span>{type}</span>
+ <HStack className="justify-between w-full">
+ <HStack>
+ <TimeTypeIcon type={type} />
+ <span>{type}</span>
+ </HStack>
+ {employeeIds.length > 0 && (
+ <EmployeeAvatarGroup
+ employeeIds={employeeIds}
+ size="xs"
+ limit={3}
+ />
+ )}
</HStack>
</Td>
<Td>
diff --git a/packages/utils/src/color.ts b/packages/utils/src/color.ts
index 4666725f8e..2e586a2b53 100644
--- a/packages/utils/src/color.ts
+++ b/packages/utils/src/color.ts
@@ -18,7 +18,7 @@ const colorIndex = {
export type Color = keyof typeof colorIndex;
const colors = [
- { background: "#e3e2e080", color: "#32302c" },
+ { background: "#a6a5a5", color: "#32302c" },
{ background: "#e3e2e0", color: "#32302c" },
{ background: "#eee0da", color: "#442a1e" },
{ background: "#fadec9", color: "#49290e" },