import { useEffect, useState } from "react"; import {Button, Checkbox, Dropdown} from "antd"; import {SettingOutlined} from "@ant-design/icons"; import {DragDropContext, Draggable, Droppable} from "react-beautiful-dnd"; export const TableSettings = ({orderColumns}) => { const [columnsList, setColumnsList] = useState(orderColumns.order); useEffect(() => { setColumnsList(orderColumns.order); }, [orderColumns]); const handleDrop = (droppedItem) => { // Ignore drop outside droppable container if (!droppedItem.destination) return; var updatedList = [...columnsList]; // Remove dragged item const [reorderedItem] = updatedList.splice(droppedItem.source.index, 1); // Add dropped item updatedList.splice(droppedItem.destination.index, 0, reorderedItem); // Update State setColumnsList(updatedList); orderColumns.setOrder(updatedList); }; const hideColumn = (columnIndex) => { const updatedList = columnsList.map((item, index) => { if (columnIndex === index) return {...item, show: !item.show}; return item; }); setColumnsList(updatedList); orderColumns.setOrder(updatedList); } const columnsListRender = () => { return (
e.stopPropagation()} className='z-10 bg-white-background rounded-xl p-3 space-y-3' style={{ maxHeight: "80vh", overflowY: "scroll", margin: "24px 0 24px" }}> {(provided) => (
{columnsList.map((item, index) => { const num = item.position; if (!orderColumns.defaultColumns[num]) return; return ( {(provided) => (
hideColumn(index)} checked={item.show} />

{ orderColumns.defaultColumns[num].name || orderColumns.defaultColumns[num].title }

)}
); })} {provided.placeholder}
)}
) } return ( columnsListRender()} > ); };