- added stats to dashboard;

- improved form builder;
This commit is contained in:
Vitalii Kiiko
2024-10-14 16:17:30 +02:00
parent 7751e3a745
commit 49765c98e6
10 changed files with 177 additions and 28 deletions

View File

@@ -2,6 +2,7 @@ import React, { useRef } from 'react'
import { useDrag } from 'react-dnd'
import { ItemTypes } from '../ItemTypes';
import uniqid from '../../../../helpers/uniqid';
import { storeSet } from '../../../../store';
const BuilderElementItem = ({ dbId, name, label, description = '' }) => {
@@ -10,12 +11,20 @@ const BuilderElementItem = ({ dbId, name, label, description = '' }) => {
const [{ isDragging }, drag] = useDrag(() => ({
type: ItemTypes.FIELD,
item: () => {
return { name, dbId, id: uniqid(), index: -1 }
const newId = uniqid();
storeSet.main.draggingElementId(newId);
return { name, dbId, id: newId, index: -1 }
},
end: (item, monitor) => {
const dropResult = monitor.getDropResult()
if (item && dropResult) {
return item;
if (monitor.didDrop()) {
if (item && dropResult) {
return item;
}
} else {
storeSet.main.removeElement(item.id);
storeSet.main.draggingElementId(0);
}
},
collect: (monitor) => ({