Unmatching Users and Adding the Like Button: Day 99 of #100DaysOfCode

ยท

2 min read

Day 99 of #100DaysOfCode: Today was all about completing the unmatching functionality for both sides of users. I created a new function inside useEffect with a dependency for the unmatched users, ensuring they don't show up in the swipe cards.

Tomorrow, I'll shift my focus to adding the functionality for the like button. It's essentially the same as a swipe up action, but triggered by a button click instead.

(Yes, I'm aware that my variable and constant names may not be the most creative, but hey, they get the job done! ๐Ÿ˜„)

useEffect(() => {
  async function getUnmatchedClients() {
      const response = await axios.get('/getUnmatchedClients', {
        params: { userId },
      })
      setUnmatchedClients(response.data)
      console.log('unmatchedClientsinCustomer', response.data)
    } 
  if (userId) {
    getUnmatchedClients();
  }
}, [userId])

 const notLikedClients = clients?.filter(
    (person) =>
      !likedClientIds.includes(person.client_user_id) &&
      isNotInSwipedCards(person) &&
      !updatedConnects.some(
        (connect) => connect.user_id === person.client_user_id
      )
  );

  const filteredNotLikedClients = notLikedClients?.filter(
    (notLikedClient) =>
      !unmatchedClients.some(
        (unmatchedClient) =>
          unmatchedClient.user_id === notLikedClient.client_user_id
      )
  );
//   getting all the unmatched freelancers

app.get('/getUnmatchedFreelancers', async (req, res) => {
    const { userId } = req.query;

    try {
        const client = await Client.findOne({ client_user_id: userId })
        const unmatchedFreelancers = client.unmatched;
        res.send(unmatchedFreelancers)
    } catch (error) {
        console.log(error)
    }
})

// getting all the unmatched clients

app.get('/getUnmatchedClients', async (req, res) => {
    const { userId } = req.query;

    try {
        const freelancer = await User.findOne({ user_id: userId })
        const unmatchedClients = freelancer.unmatched;
        res.send(unmatchedClients)
    } catch (error) {
        console.log(error)
    }
})
ย