88 | {accept === FormItemTypes.CONTAINER ? (
89 | <>
90 |
94 |
106 |
107 | >
108 | ) : null}
109 |
110 | {accept === FormItemTypes.CONTROL ? (
111 | <>
112 |
{
114 | if (selectControl) {
115 | selectControl(layout);
116 | }
117 | }}
118 | className="container-header d-flex justify-content-between py-3 mb-3"
119 | style={{
120 | borderBottom: "1px solid rgba(0,0,0,0.1)",
121 | cursor: "pointer",
122 | }}
123 | >
124 |
Step {(index as number) + 1}
125 |
129 |
130 |
131 |
132 |
133 |
134 |
135 |
136 |
137 |
138 |
{(layout as FormLayoutComponentContainerType)?.heading}
139 |
{(layout as FormLayoutComponentContainerType)?.subHeading}
140 |
144 | {childrenComponents?.length === 0 ? (
145 | <>
146 |
147 |
148 |
149 |
150 | Drop Field
151 |
152 | >
153 | ) : (
154 | <>
155 | {childrenComponents?.map((component, ind) => {
156 | return (
157 |
{
161 | if (deleteControl) {
162 | deleteControl(controlId, containerId);
163 | }
164 | }}
165 | selectControl={(layout) => {
166 | if (selectControl) {
167 | selectControl(layout);
168 | }
169 | }}
170 | selectedControl={selectedControl}
171 | containerId={layout?.id as string}
172 | index={ind}
173 | moveControl={(
174 | item,
175 | dragIndex,
176 | hoverIndex,
177 | containerId
178 | ) => {
179 | if (moveControl) {
180 | moveControl(
181 | item,
182 | dragIndex,
183 | hoverIndex,
184 | containerId
185 | );
186 | }
187 | }}
188 | />
189 | );
190 | })}
191 | >
192 | )}
193 |
194 | {/*
195 | selectControl(layout)}>
196 |
197 |
198 | deleteContainer(layout.id)}>
199 |
*/}
200 | >
201 | ) : null}
202 |
203 | >
204 | );
205 | }
206 |
207 | export default DropContainerComponent;
--------------------------------------------------------------------------------
/src/components/FormBuilder/hooks/useFormBuilder.ts:
--------------------------------------------------------------------------------
1 | import { useEffect, useState } from "react";
2 | import {
3 | TemplateType,
4 | FormLayoutComponentsType,
5 | FormLayoutComponentChildrenType,
6 | FormLayoutComponentContainerType,
7 | } from "../../../types/FormTemplateTypes";
8 | import { FormItemTypes, FormPublishStatus } from "../../../utils/formBuilderUtils";
9 | import { generateID } from "../../../utils/common";
10 | import { useAppDispatch } from "../../../redux/hooks";
11 | import { openModal } from "../../../redux/uireducers/modalstrip";
12 | import moment from "moment";
13 | import { saveTemplate } from "../../../redux/entities/formBuilderEntity";
14 | import useModalStrip from "../../../global-hooks/useModalStrip";
15 |
16 |
17 | interface useFormBuilderProps{
18 | template: TemplateType
19 | }
20 |
21 | const useFormBuilder = (props: useFormBuilderProps) => {
22 | const [selectedTemplate, setSelectedTemplate] = useState