mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-29 22:18:12 +00:00
fix
This commit is contained in:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user