|
1 | 1 | import React from "react"; |
2 | | -import { Button, Text, useDisclosure } from "webiny/admin/ui"; |
3 | | -import { ElementInputs, useElementInputs } from "webiny/admin/website-builder/page/editor"; |
4 | | -import { ConditionRulesDialog } from "../components/ConditionRulesDialog"; |
| 2 | +import { ElementInputs } from "webiny/admin/website-builder/page/editor"; |
5 | 3 | import { StepsList } from "../stepper/StepsList.js"; |
6 | | -import type { FunnelModelDto } from "../../models/FunnelModel"; |
7 | | -import type { FunnelContainerInputs } from "../types"; |
8 | 4 |
|
9 | 5 | export const ContainerElementInputsDecorator = ElementInputs.createDecorator(Original => { |
10 | 6 | return function ContainerElementSettings(props) { |
11 | 7 | const { element } = props; |
12 | | - const { inputs, updateInputs } = useElementInputs(element.id); |
13 | | - |
14 | | - const { |
15 | | - open: showConditionRulesDialog, |
16 | | - close: hideConditionRulesDialog, |
17 | | - isOpen: isConditionRulesDialogOpen, |
18 | | - data: conditionRulesData |
19 | | - } = useDisclosure<FunnelModelDto>(); |
20 | 8 |
|
21 | 9 | if (element.component.name !== "Fub/Container") { |
22 | 10 | return <Original {...props} />; |
23 | 11 | } |
24 | 12 |
|
25 | | - /* Container element: open condition rules using the current containerData. */ |
26 | | - const handleClick = () => { |
27 | | - const { containerData } = inputs as unknown as FunnelContainerInputs; |
28 | | - showConditionRulesDialog(containerData); |
29 | | - }; |
30 | | - |
31 | | - const handleSubmit = (data: FunnelModelDto) => { |
32 | | - updateInputs(current => { |
33 | | - (current as unknown as FunnelContainerInputs).containerData = data; |
34 | | - }); |
35 | | - hideConditionRulesDialog(); |
36 | | - }; |
37 | | - |
38 | 13 | return ( |
39 | 14 | <div className={"flex flex-col gap-xl"}> |
40 | 15 | <div className={"flex flex-col gap-sm"}> |
41 | 16 | <div className={"font-bold text-sm text-neutral-primary"}>Steps</div> |
42 | 17 | <StepsList /> |
43 | 18 | </div> |
44 | | - <div className={"flex flex-col gap-sm"}> |
45 | | - <div className={"font-bold text-sm mb-sm text-neutral-primary"}> |
46 | | - Condition Rules |
47 | | - </div> |
48 | | - <Button |
49 | | - variant={"primary"} |
50 | | - text={"Edit Condition Rules"} |
51 | | - className={"w-full"} |
52 | | - onClick={handleClick} |
53 | | - /> |
54 | | - </div> |
55 | | - <ConditionRulesDialog |
56 | | - open={isConditionRulesDialogOpen} |
57 | | - data={conditionRulesData!} |
58 | | - onClose={hideConditionRulesDialog} |
59 | | - onSubmit={handleSubmit} |
60 | | - /> |
61 | 19 | </div> |
62 | 20 | ); |
63 | 21 | }; |
|
0 commit comments