1
0
Fork 0
polaris-task-force/src/lib/base/productionDefaults.ts
2026-09-20 02:43:23 -04:00

20 lines
803 B
TypeScript

import type { Structure } from "@/payload-types";
export type ProductionDefaults = {
readonly productionInputs: NonNullable<Structure["productionInputs"]>;
readonly productionOutputs: NonNullable<Structure["productionOutputs"]>;
};
export function productionDefaultsFromBlueprint(blueprint: Structure): ProductionDefaults {
return {
productionInputs: (blueprint.productionInputs ?? []).map((input) => ({
resource:
typeof input.resource === "object" ? input.resource.id : input.resource,
amountPerHour: input.amountPerHour ?? 0,
})),
productionOutputs: (blueprint.productionOutputs ?? []).map((output) => ({
resource: typeof output.resource === "object" ? output.resource.id : output.resource,
amountPerHour: output.amountPerHour ?? 0,
})),
};
}