This commit is contained in:
Marshal
2026-07-17 13:57:59 +00:00
parent 3a697e12f2
commit 6467173c76
12 changed files with 642 additions and 46 deletions

View File

@@ -155,6 +155,37 @@ export const useContainerTypeOptions = (
select: (rows) => buildContainerTypeSelectOptions(rows, includeNone),
});
/** A yard option that remembers its country, so callers can filter by leg. */
export interface YardOption {
label: string;
value: string;
country: string;
}
/**
* Active yards for the rate form's origin/destination pickers. The country
* rides along on each option because which yards are legal depends on the
* rate's direction (import starts in Djibouti, export starts in Ethiopia).
*/
export const useYardOptions = (enabled = true) =>
useQuery({
queryKey: QUERY_KEYS.RULE_ENGINE.selectOptions("yards", { activeOnly: true }),
queryFn: () => ruleEngineService.listAll<RuleEngineRecord>("yards"),
enabled,
select: (rows): YardOption[] =>
rows
.filter((row) => row.id && row.isActive !== false)
.map((row) => {
const label = String(row.label ?? "").trim();
const code = String(row.code ?? "").trim();
return {
label: label && code ? `${label} (${code})` : label || code || String(row.id),
value: String(row.id),
country: String(row.country ?? ""),
};
}),
});
/**
* Active wagon-type options for the cargo-type / container-type "Wagon type"
* picker. The FK the selection sets drives train-scheduling wagon resolution.