change price logic on the ,rule engine ui, auto generate the contrat

This commit is contained in:
marshal
2026-06-08 10:04:23 +03:00
parent 4993453993
commit 88df20be6b
76 changed files with 4907 additions and 225 deletions

View File

@@ -20,6 +20,7 @@ import {
type FormFieldDef,
} from "@/pages/ruleEngine/config/resources";
import type { RuleEngineRecord } from "@/types/rule-engine";
import { RULE_ENGINE_POSITION_END } from "./ruleEngineOrder.utils";
export interface RuleEngineFormDialogProps {
open: boolean;
@@ -30,6 +31,8 @@ export interface RuleEngineFormDialogProps {
initialRecord?: RuleEngineRecord | null;
isSubmitting: boolean;
selectOptionsLoading?: boolean;
positionOptions?: { label: string; value: string }[];
positionLoading?: boolean;
onSubmit: (values: Record<string, unknown>) => void;
}
@@ -146,15 +149,19 @@ const RuleEngineFormDialog = ({
initialRecord,
isSubmitting,
selectOptionsLoading = false,
positionOptions,
positionLoading = false,
onSubmit,
}: RuleEngineFormDialogProps) => {
const [values, setValues] = useState<Record<string, unknown>>(() =>
buildInitialValues(fields, initialRecord),
);
const [position, setPosition] = useState(RULE_ENGINE_POSITION_END);
useEffect(() => {
if (open) {
setValues(buildInitialValues(fields, initialRecord));
setPosition(RULE_ENGINE_POSITION_END);
}
}, [open, fields, initialRecord]);
@@ -192,6 +199,10 @@ const RuleEngineFormDialog = ({
payload.code = String(payload.code).toUpperCase();
}
if (!initialRecord && positionOptions && position !== RULE_ENGINE_POSITION_END) {
payload.insertAfterId = position;
}
onSubmit(payload);
};
@@ -315,6 +326,23 @@ const RuleEngineFormDialog = ({
<Stack gap="lg">
<Box style={{ maxHeight: "calc(65vh - 120px)", overflowY: "auto", paddingRight: 4 }}>
<Stack gap="md">
{!initialRecord && positionOptions ? (
<Select
label="Position"
description="New items are appended to the end by default."
value={position}
onChange={(value) => setPosition(value ?? RULE_ENGINE_POSITION_END)}
data={[
{ label: "At end (default)", value: RULE_ENGINE_POSITION_END },
...positionOptions,
]}
searchable
disabled={positionLoading}
size="md"
radius="md"
styles={inputStyles}
/>
) : null}
{formRows.map((row) =>
row.kind === "pair" ? (
<SimpleGrid key={`${row.fields[0].name}-${row.fields[1].name}`} cols={2} spacing="md">