mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-28 03:10:54 +00:00
32 lines
1.1 KiB
TypeScript
32 lines
1.1 KiB
TypeScript
import { WagonReadiness, type ScheduleTradeDirection } from '@edr/types';
|
|
|
|
/** @deprecated Replaced by yard-based fleet filtering via `currentYardId`. */
|
|
export function requiredWagonReadiness(
|
|
direction: ScheduleTradeDirection | string | null | undefined,
|
|
): WagonReadiness | null {
|
|
if (direction === 'IMPORT') return WagonReadiness.ImportReady;
|
|
if (direction === 'EXPORT') return WagonReadiness.ExportReady;
|
|
return null;
|
|
}
|
|
|
|
/** @deprecated Replaced by `wagon.currentYardId === originYardId` checks. */
|
|
export function wagonReadinessMatchesSchedule(
|
|
wagonReadiness: WagonReadiness | string,
|
|
direction: ScheduleTradeDirection | string | null | undefined,
|
|
): boolean {
|
|
const required = requiredWagonReadiness(direction);
|
|
if (!required) return true;
|
|
return wagonReadiness === required;
|
|
}
|
|
|
|
/**
|
|
* @deprecated Replaced by setting `currentYardId = schedule.destinationStationId` on arrival.
|
|
*/
|
|
export function flipReadiness(
|
|
readiness: WagonReadiness | string,
|
|
): WagonReadiness {
|
|
return readiness === WagonReadiness.ImportReady
|
|
? WagonReadiness.ExportReady
|
|
: WagonReadiness.ImportReady;
|
|
}
|