feat(rates): multi-tier distance band entry in last-mile rate form

- tierList field type in rule-engine form dialog (add/remove rows,
  overlap + open-ended validation, From km auto-continues)
- create submits one rate row per tier sequentially
- editing a band row keeps the single From/To/value form
This commit is contained in:
Hagernesh
2026-08-06 04:14:19 +00:00
parent ea9df4407e
commit 4716aa14c3
7 changed files with 304 additions and 6 deletions

View File

@@ -17,7 +17,7 @@ export type ColumnFormat =
| "entityLabel"
| "rateLabel";
export type FormFieldType = "text" | "number" | "boolean" | "date" | "email" | "select" | "multiselect" | "textarea" | "radio";
export type FormFieldType = "text" | "number" | "boolean" | "date" | "email" | "select" | "multiselect" | "textarea" | "radio" | "tierList";
export interface ResourceColumn {
id: string;
@@ -1022,6 +1022,19 @@ export const RULE_ENGINE_RESOURCES: RuleEngineResourceConfig[] = [
showWhen: { field: "appliesTo", equals: ["LAST_MILE"] },
getInitialValue: (record) => String(record.currency ?? "ETB"),
},
// ── Distance tiers (create only — the page swaps this for the single
// From/To/value fields when editing an existing band row). Each tier
// becomes its own rate row, so every band keeps edit/delete/approval. ──
{
name: "tiers",
label: "Distance tiers",
type: "tierList",
required: true,
description:
"One rate per distance range. To km is exclusive (030 then 30+); leave the last tier's To km empty for no upper limit.",
showIf: (v) =>
v.appliesTo === "LAST_MILE" && v.lastMileMode === "CONTAINER",
},
// ── Container type — Container freight, container-kind intercity, and
// the empty-container return surcharge (20ft vs 40ft price differently) ─
{