Skip to content

Commit

Permalink
#25 Add unfollowhelper in utils
Browse files Browse the repository at this point in the history
  • Loading branch information
SandraBergstrom committed Jun 29, 2023
1 parent f976313 commit 9d73d76
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/utils/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,15 @@ export const followHelper = (traveler, clickedTraveler, following_id) => {
// in users own, just return it unchanged
traveler;
};

export const unfollowHelper = (traveler, clickedTraveler) => {
return traveler.id === clickedTraveler.id
? {
...traveler,
followers_count: traveler.followers_count -1,
following_id: null,
}
: traveler.is_owner
? {...traveler, following_count: traveler.following_count -1 }
: traveler;
}

0 comments on commit 9d73d76

Please sign in to comment.