mirror of
https://github.com/Sea-Haven-Industries/shoc-frontend-new.git
synced 2026-10-02 02:43:12 +00:00
19 lines
722 B
TypeScript
19 lines
722 B
TypeScript
import type { WorkOrderTablePatch } from "@/domain/work-orders/types/work-order-table-row";
|
|
|
|
export function serviceIdentityPatch(
|
|
currentServiceId: string | number | null | undefined,
|
|
currentName: string,
|
|
nextName: string,
|
|
nextServiceId: string | number | null | undefined,
|
|
): Pick<WorkOrderTablePatch, "pm" | "serviceId"> {
|
|
const sameIdentity =
|
|
currentServiceId != null &&
|
|
nextServiceId != null &&
|
|
String(currentServiceId) === String(nextServiceId);
|
|
if (sameIdentity) return {};
|
|
|
|
if (nextServiceId != null) return { pm: nextName, serviceId: nextServiceId };
|
|
if (currentServiceId != null) return { pm: nextName, serviceId: null };
|
|
|
|
return nextName === currentName ? {} : { pm: nextName };
|
|
}
|