This commit is contained in:
2023-02-14 02:02:48 +01:00
parent 9595344e85
commit 36f9bc68b2

View File

@ -29,7 +29,17 @@ const useStyles = createStyles((theme) => ({
}));
export interface DndListProps {
data: {
data: TData
}
export interface IProps
{
dragEndHandler: (p: any) => void;
dataprops: DndListProps;
}
export type TData =
{
id: string;
name: string;
@ -39,16 +49,9 @@ export interface DndListProps {
// mass: number;
// symbol: string;
// name: string;
}[];
}
}[]
export interface IProps
{
dragEndHandler: (p: any) => void;
dataprops: DndListProps;
}
const reorder = ({ from, to }: { from: number; to: number })
const reorder = ({current, from, to }: {current: TData; from: number; to: number }) =>
{
const cloned = [...current];
const item = current[from];
@ -92,7 +95,13 @@ export interface DndListProps {
{
handlers.reorder({ from: source.index, to: destination?.index || 0 });
console.log(state);
dragEndHandler(state);
dragEndHandler(
reorder(
{
current:state,
from: source.index,
to: destination!.index
} ));
}
}
>