Skip to content

Commit

Permalink
refactor: now the resequencing of collection is reflecting in the UI.
Browse files Browse the repository at this point in the history
  • Loading branch information
sanjaikumar-bruno committed Jan 9, 2025
1 parent 91557e5 commit 9270f01
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,6 @@ const Collections = () => {
</StyledWrapper>
);
}

const sortedCollections = collections.toSorted((a, b) => a.seq - b.seq);

return (
<StyledWrapper>
Expand Down Expand Up @@ -114,8 +112,8 @@ const Collections = () => {
</div>

<div className="mt-4 flex flex-col overflow-hidden hover:overflow-y-auto absolute top-32 bottom-10 left-0 right-0">
{sortedCollections && sortedCollections.length
? sortedCollections.map((c) => {
{collections && collections.length
? collections.map((c) => {
return (
<Collection searchText={searchText} collection={c} key={c.uid} />
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,11 @@ export const collectionsSlice = createSlice({
},
resequenceCollection: (state, action) => {
const { draggedItem, targetItem } = action.payload;
console.log('draggedItem', draggedItem);
console.log('targetItem', targetItem);

state.collections = state.collections.sort((a, b) => a.seq - b.seq);
state.collections = filter(state.collections, (i) => i.uid !== draggedItem.uid);
let targetItemIndex = findIndex(state.collections, (i) => i.uid === targetItem.uid);
state.collections.splice(targetItemIndex + 1, 0, draggedItem);
},
state.collections.sort((a, b) => a.seq - b.seq);
state.collections = state.collections.filter(i => i.uid !== draggedItem.uid);
const targetItemIndex = state.collections.findIndex(i => i.uid === targetItem.uid);
state.collections.splice(targetItemIndex, 0, draggedItem);
},
updateLastAction: (state, action) => {
const { collectionUid, lastAction } = action.payload;
const collection = findCollectionByUid(state.collections, collectionUid);
Expand Down

0 comments on commit 9270f01

Please sign in to comment.