Implement portfolio admin management
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
export function moveArrayItem<T>(items: T[], fromIndex: number, toIndex: number) {
|
||||
if (
|
||||
fromIndex < 0 ||
|
||||
toIndex < 0 ||
|
||||
fromIndex >= items.length ||
|
||||
toIndex >= items.length ||
|
||||
fromIndex === toIndex
|
||||
) {
|
||||
return items;
|
||||
}
|
||||
|
||||
const nextItems = [...items];
|
||||
const [movedItem] = nextItems.splice(fromIndex, 1);
|
||||
|
||||
nextItems.splice(toIndex, 0, movedItem);
|
||||
|
||||
return nextItems;
|
||||
}
|
||||
Reference in New Issue
Block a user