- added registartion page;

- implemented validation helper-functions;
- fixed form fields datepicker and datepicker range;
- updated routes logic;
- fixed FAQ items editing/submission;
This commit is contained in:
Vitalii Kiiko
2024-09-23 10:05:43 +02:00
parent cf149485e0
commit bbf117eb9b
58 changed files with 1238 additions and 392 deletions

View File

@@ -19,8 +19,8 @@ const nodeTypes = {
intermediateForm: NodeIntermediateForm
};
const FlowBuilder = ({ initialForm = 0, finalForm = 0 }) => {
const forms = useStore().main.flowForms();
const FlowBuilder = ({ initialForm = 0, finalForm = 0, mainField = '' }) => {
const flowForms = useStore().main.flowForms();
const [nodes, setNodes] = useState([]);
const [edges, setEdges] = useState([]);
@@ -33,13 +33,13 @@ const FlowBuilder = ({ initialForm = 0, finalForm = 0 }) => {
useEffect(() => {
if (
(forms.length === 2 && initialForm) ||
(forms.length > 2 && initialForm && finalForm)
(flowForms.length === 2 && initialForm) ||
(flowForms.length > 2 && initialForm && finalForm)
) {
const total = (forms.length - 2) * (200 - 90);
const total = (flowForms.length - 2) * (200 - 90);
let coordinates = range(total * -1, total, 200);
const initialNodes = forms.map(o => {
const initialNodes = flowForms.map(o => {
const formId = String(o.id);
let obj;
@@ -55,7 +55,7 @@ const FlowBuilder = ({ initialForm = 0, finalForm = 0 }) => {
id: formId,
type: 'output',
data: { label: o.label, id: formId },
position: { x: 0, y: forms.length === 2 ? 150 : 300 },
position: { x: 0, y: flowForms.length === 2 ? 150 : 300 },
}
} else {
const x = coordinates.splice(0, 1);
@@ -71,29 +71,53 @@ const FlowBuilder = ({ initialForm = 0, finalForm = 0 }) => {
let edges = [];
// eslint-disable-next-line
forms.map(o => {
flowForms.map(o => {
const formId = String(o.id);
if (formId !== String(initialForm) && formId !== String(finalForm)) {
edges.push({ id: `${initialForm}->${formId}`, source: String(initialForm), target: formId, type: 'smoothstep' });
edges.push({
id: `${initialForm}->${formId}`,
source: String(initialForm),
target: formId,
type: 'smoothstep'
});
}
if (formId !== String(initialForm) && formId !== String(finalForm) && String(finalForm) !== '0') {
edges.push({ id: `${formId}->${finalForm}`, source: formId, target: String(finalForm), type: 'smoothstep' });
edges.push({
id: `${formId}->${finalForm}`,
source: formId,
target: String(finalForm),
type: 'smoothstep'
});
}
});
if (forms.length === 2 && initialForm && finalForm) {
edges.push({ id: `${initialForm}->${finalForm}`, source: String(initialForm), target: String(finalForm), type: 'smoothstep' });
if (flowForms.length === 2 && initialForm && finalForm) {
edges.push({
id: `${initialForm}->${finalForm}`,
source: String(initialForm),
target: String(finalForm),
type: 'smoothstep'
});
}
setNodes(initialNodes);
setEdges(edges);
storeSet.main.flowEdges(edges);
if (!isEmpty(mainField)) {
const data = {
formId: String(initialForm),
chosenField: mainField,
chosenValue: ''
}
storeSet.main.addFlowData(data);
}
} else {
setNodes([]);
setEdges([]);
}
}, [initialForm, finalForm, forms]);
}, [initialForm, finalForm, flowForms, mainField]);
return (
!isEmpty(nodes) && !isEmpty(edges)