fix schule issue and contianer type issue

This commit is contained in:
Marshal
2026-07-17 09:16:35 +00:00
parent 5a1e0dba4d
commit 7b7e7c3f62
39 changed files with 508 additions and 187 deletions

View File

@@ -1,20 +1,14 @@
/**
* Client mirror of the backend's contiguous-range rules for priority configs
* (see PriorityConfigsService.assertNoRangeCollision): ranges per type — per
* currency for CURRENCY — run 1..cap with no gaps and no overlaps, so the next
* range always starts at the lowest uncovered wagon count. The backend
* re-validates on submit AND on approval; this only drives the form prefill.
* currency for CURRENCY — run from 1 with no gaps and no overlaps, so the next
* range always starts at the lowest uncovered wagon count. There is no upper
* ceiling. The backend re-validates on submit AND on approval; this only
* drives the form prefill.
*/
export type PriorityRuleType = "WAGON" | "CURRENCY" | "CUSTOMS";
/** Hard ceiling of each type's chain — keep in sync with the API's RANGE_CAPS. */
export const PRIORITY_RANGE_CAPS: Record<PriorityRuleType, number> = {
WAGON: 50,
CURRENCY: 35,
CUSTOMS: 15,
};
export interface PriorityRangeRule {
id?: unknown;
type?: unknown;
@@ -23,10 +17,13 @@ export interface PriorityRangeRule {
maxWagonCount?: unknown;
}
const PRIORITY_RULE_TYPES: PriorityRuleType[] = ["WAGON", "CURRENCY", "CUSTOMS"];
/**
* Where the next range for `type` (+`currency`) must start, excluding
* `excludeId` (the rule being edited). Null when the chain already covers
* 1..cap — no further rule fits.
* `excludeId` (the rule being edited). Null only when `type` is not yet a
* known priority rule type — the chain itself is unbounded, so a next start
* always exists.
*/
export function nextPriorityRangeStart(
rules: PriorityRangeRule[],
@@ -34,8 +31,7 @@ export function nextPriorityRangeStart(
currency: string | null | undefined,
excludeId?: string,
): number | null {
const cap = PRIORITY_RANGE_CAPS[type as PriorityRuleType];
if (!cap) return null;
if (!PRIORITY_RULE_TYPES.includes(type as PriorityRuleType)) return null;
const scoped = rules
.filter(
@@ -56,5 +52,5 @@ export function nextPriorityRangeStart(
if (r.min > next) break; // gap before this rule — fill it first
next = Math.max(next, r.max + 1);
}
return next > cap ? null : next;
return next;
}