import { DropResult } from 'react-beautiful-dnd' ; const reorder = ( list , startIndex , endIndex ) => { const [ removed ] = list . splice ( startIndex , 1 ) ; list . splice ( endIndex , 0 , removed ) ; return list ; } ; export const useGenericCardsListEffects = < ItemType > ( list ? , handleDrag ? ) => { const onCardDragEnd = async ( result ) => { if ( ! result . destination || ! list || ! handleDrag ) return ; const reorderedList = reorder ( list , result . source . index , result . destination . index ) ; await handleDrag ( reorderedList ) ; } ; return { onCardDragEnd } ; } ;