mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-09-07 18:55:42 +00:00
implement priority
This commit is contained in:
@@ -317,7 +317,7 @@ const App = () => {
|
|||||||
|
|
||||||
<Route
|
<Route
|
||||||
path="rules"
|
path="rules"
|
||||||
element={<Navigate to="/dashboard/rules/priority-rules" replace />}
|
element={<Navigate to="/dashboard/rules/priority-configs" replace />}
|
||||||
/>
|
/>
|
||||||
<Route path="rules/:resource" element={<RuleEngineResourcePage />} />
|
<Route path="rules/:resource" element={<RuleEngineResourcePage />} />
|
||||||
|
|
||||||
|
|||||||
@@ -212,8 +212,8 @@ export const URL_CONSTANTS = {
|
|||||||
WAGON_TYPES: "/wagon-types",
|
WAGON_TYPES: "/wagon-types",
|
||||||
WAGON_TYPE_BY_ID: (id: string) => `/wagon-types/${id}`,
|
WAGON_TYPE_BY_ID: (id: string) => `/wagon-types/${id}`,
|
||||||
|
|
||||||
PRIORITY_RULES: "/priority-rules",
|
PRIORITY_CONFIGS: "/priority-configs",
|
||||||
PRIORITY_RULE_BY_ID: (id: string) => `/priority-rules/${id}`,
|
PRIORITY_CONFIG_BY_ID: (id: string) => `/priority-configs/${id}`,
|
||||||
|
|
||||||
SERVICE_TYPES: "/service-types",
|
SERVICE_TYPES: "/service-types",
|
||||||
SERVICE_TYPE_BY_ID: (id: string) => `/service-types/${id}`,
|
SERVICE_TYPE_BY_ID: (id: string) => `/service-types/${id}`,
|
||||||
|
|||||||
@@ -110,7 +110,15 @@ const RATE_UNITS = ["PER_WAGON", "PER_TON", "PER_CONTAINER", "PER_KM", "FLAT"].m
|
|||||||
value: v,
|
value: v,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
const CURRENCIES = [{ label: "USD", value: "USD" }];
|
const CURRENCIES = [
|
||||||
|
{ label: "USD", value: "USD" },
|
||||||
|
{ label: "ETB", value: "ETB" },
|
||||||
|
];
|
||||||
|
|
||||||
|
const PRIORITY_CONFIG_TYPES = [
|
||||||
|
{ label: "Wagon count", value: "WAGON" },
|
||||||
|
{ label: "Payment currency", value: "CURRENCY" },
|
||||||
|
];
|
||||||
|
|
||||||
const codeColumn = (key: string, header = "Code"): ResourceColumn => ({
|
const codeColumn = (key: string, header = "Code"): ResourceColumn => ({
|
||||||
id: key,
|
id: key,
|
||||||
@@ -226,29 +234,42 @@ export const RULE_ENGINE_RESOURCES: RuleEngineResourceConfig[] = [
|
|||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
slug: "priority-rules",
|
slug: "priority-configs",
|
||||||
label: "Priority Rules",
|
label: "Priority Rules",
|
||||||
category: "rules",
|
category: "rules",
|
||||||
subtitle: "Booking priority scoring rules",
|
subtitle: "Wagon-count and payment-currency scoring rules",
|
||||||
searchPlaceholder: "Search priority rules...",
|
searchPlaceholder: "Search priority rules...",
|
||||||
|
orderConfig: { field: "displayOrder", label: "Display order" },
|
||||||
columns: [
|
columns: [
|
||||||
codeColumn("code"),
|
|
||||||
{ id: "label", header: "Label", accessorKey: "label" },
|
{ id: "label", header: "Label", accessorKey: "label" },
|
||||||
{ id: "score", header: "Score", accessorKey: "score", format: "number" },
|
{ id: "type", header: "Type", accessorKey: "type" },
|
||||||
{ id: "conditionCurrency", header: "Currency", accessorKey: "conditionCurrency" },
|
{ id: "currency", header: "Currency", accessorKey: "currency" },
|
||||||
|
{ id: "minWagonCount", header: "Min wagons", accessorKey: "minWagonCount", format: "number" },
|
||||||
|
{ id: "maxWagonCount", header: "Max wagons", accessorKey: "maxWagonCount", format: "number" },
|
||||||
|
{ id: "scorePoints", header: "Points", accessorKey: "scorePoints", format: "number" },
|
||||||
activeColumn,
|
activeColumn,
|
||||||
],
|
],
|
||||||
formFields: [
|
formFields: [
|
||||||
{ name: "label", label: "Label", type: "text", required: true },
|
{ name: "label", label: "Label", type: "text", required: true },
|
||||||
{ name: "score", label: "Score", type: "number", required: true },
|
|
||||||
{
|
{
|
||||||
name: "conditionCurrency",
|
name: "type",
|
||||||
label: "Condition currency",
|
label: "Type",
|
||||||
|
type: "select",
|
||||||
|
required: true,
|
||||||
|
options: PRIORITY_CONFIG_TYPES,
|
||||||
|
placeholder: "Wagon count or payment currency",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "currency",
|
||||||
|
label: "Currency (required for Payment currency type)",
|
||||||
type: "select",
|
type: "select",
|
||||||
optional: true,
|
optional: true,
|
||||||
options: [{ label: "Any", value: RULE_ENGINE_SELECT_NONE }, ...CURRENCIES],
|
options: [{ label: "None", value: RULE_ENGINE_SELECT_NONE }, ...CURRENCIES],
|
||||||
placeholder: "Any currency (optional)",
|
placeholder: "Leave as None for Wagon count rules",
|
||||||
},
|
},
|
||||||
|
{ name: "minWagonCount", label: "Min wagon count", type: "number", required: true },
|
||||||
|
{ name: "maxWagonCount", label: "Max wagon count", type: "number", required: true },
|
||||||
|
{ name: "scorePoints", label: "Score points", type: "number", required: true },
|
||||||
{ name: "isActive", label: "Active", type: "boolean" },
|
{ name: "isActive", label: "Active", type: "boolean" },
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
@@ -500,7 +521,7 @@ export const getCategorySidebarChildren = (
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
export const DEFAULT_CONFIGURATION_SLUG: RuleEngineResourceSlug = "cargo-types";
|
export const DEFAULT_CONFIGURATION_SLUG: RuleEngineResourceSlug = "cargo-types";
|
||||||
export const DEFAULT_RULES_SLUG: RuleEngineResourceSlug = "priority-rules";
|
export const DEFAULT_RULES_SLUG: RuleEngineResourceSlug = "priority-configs";
|
||||||
|
|
||||||
/** @deprecated Use DEFAULT_CONFIGURATION_SLUG */
|
/** @deprecated Use DEFAULT_CONFIGURATION_SLUG */
|
||||||
export const DEFAULT_RULE_ENGINE_SLUG = DEFAULT_CONFIGURATION_SLUG;
|
export const DEFAULT_RULE_ENGINE_SLUG = DEFAULT_CONFIGURATION_SLUG;
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ const RESOURCE_BASE: Record<RuleEngineResourceSlug, string> = {
|
|||||||
"cargo-types": URL_CONSTANTS.RULE_ENGINE.CARGO_TYPES,
|
"cargo-types": URL_CONSTANTS.RULE_ENGINE.CARGO_TYPES,
|
||||||
"container-types": URL_CONSTANTS.RULE_ENGINE.CONTAINER_TYPES,
|
"container-types": URL_CONSTANTS.RULE_ENGINE.CONTAINER_TYPES,
|
||||||
"wagon-types": URL_CONSTANTS.RULE_ENGINE.WAGON_TYPES,
|
"wagon-types": URL_CONSTANTS.RULE_ENGINE.WAGON_TYPES,
|
||||||
"priority-rules": URL_CONSTANTS.RULE_ENGINE.PRIORITY_RULES,
|
"priority-configs": URL_CONSTANTS.RULE_ENGINE.PRIORITY_CONFIGS,
|
||||||
"service-types": URL_CONSTANTS.RULE_ENGINE.SERVICE_TYPES,
|
"service-types": URL_CONSTANTS.RULE_ENGINE.SERVICE_TYPES,
|
||||||
"surcharge-types": URL_CONSTANTS.RULE_ENGINE.SURCHARGE_TYPES,
|
"surcharge-types": URL_CONSTANTS.RULE_ENGINE.SURCHARGE_TYPES,
|
||||||
"weight-limit-rules": URL_CONSTANTS.RULE_ENGINE.WEIGHT_LIMIT_RULES,
|
"weight-limit-rules": URL_CONSTANTS.RULE_ENGINE.WEIGHT_LIMIT_RULES,
|
||||||
@@ -46,8 +46,8 @@ const byIdPath = (resource: RuleEngineResourceSlug, id: string): string => {
|
|||||||
return URL_CONSTANTS.RULE_ENGINE.CONTAINER_TYPE_BY_ID(id);
|
return URL_CONSTANTS.RULE_ENGINE.CONTAINER_TYPE_BY_ID(id);
|
||||||
case "wagon-types":
|
case "wagon-types":
|
||||||
return URL_CONSTANTS.RULE_ENGINE.WAGON_TYPE_BY_ID(id);
|
return URL_CONSTANTS.RULE_ENGINE.WAGON_TYPE_BY_ID(id);
|
||||||
case "priority-rules":
|
case "priority-configs":
|
||||||
return URL_CONSTANTS.RULE_ENGINE.PRIORITY_RULE_BY_ID(id);
|
return URL_CONSTANTS.RULE_ENGINE.PRIORITY_CONFIG_BY_ID(id);
|
||||||
case "service-types":
|
case "service-types":
|
||||||
return URL_CONSTANTS.RULE_ENGINE.SERVICE_TYPE_BY_ID(id);
|
return URL_CONSTANTS.RULE_ENGINE.SERVICE_TYPE_BY_ID(id);
|
||||||
case "surcharge-types":
|
case "surcharge-types":
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ export type RuleEngineResourceSlug =
|
|||||||
| "cargo-types"
|
| "cargo-types"
|
||||||
| "container-types"
|
| "container-types"
|
||||||
| "wagon-types"
|
| "wagon-types"
|
||||||
| "priority-rules"
|
| "priority-configs"
|
||||||
| "service-types"
|
| "service-types"
|
||||||
| "surcharge-types"
|
| "surcharge-types"
|
||||||
| "weight-limit-rules"
|
| "weight-limit-rules"
|
||||||
|
|||||||
Reference in New Issue
Block a user