mirror of
https://github.com/Sea-Haven-Industries/shoc-frontend-new.git
synced 2026-10-04 23:02:07 +00:00
19 lines
570 B
TypeScript
19 lines
570 B
TypeScript
|
|
import type { WorkOrderUser } from "@/domain/work-orders/types/work-order";
|
||
|
|
|
||
|
|
/** Primary list wins on id collision (dispatcher lookup before directory). */
|
||
|
|
export function mergeWorkOrderUsers(
|
||
|
|
primary: WorkOrderUser[],
|
||
|
|
extra: WorkOrderUser[],
|
||
|
|
): WorkOrderUser[] {
|
||
|
|
const byId = new Map<string, WorkOrderUser>();
|
||
|
|
for (const user of primary) {
|
||
|
|
const key = String(user.id);
|
||
|
|
if (key) byId.set(key, user);
|
||
|
|
}
|
||
|
|
for (const user of extra) {
|
||
|
|
const key = String(user.id);
|
||
|
|
if (key && !byId.has(key)) byId.set(key, user);
|
||
|
|
}
|
||
|
|
return [...byId.values()];
|
||
|
|
}
|