Completing the #100DaysOfCode Challenge: Reflections and Next Steps

Completing the #100DaysOfCode Challenge: Reflections and Next Steps

Hey everyone, I'm excited to share that I've reached Day 100 of my #100DaysOfCode challenge! 🎉 It's been an incredible journey, and I'm ready to embark on my next challenge, #365DaysOfCode. Get ready for more coding adventures!

First and foremost, I want to express my gratitude to everyone who supported me throughout this challenge. Your encouragement and positive energy kept me motivated, even when things got tough. This journey wasn't always easy, but I persevered and grew both as a programmer and as an individual (yes, I know it sounds cliché).

As I move forward, I've decided to focus more on achieving significant milestones before sharing updates on my current project. This means diving deeper into the development process, refining my skills, and delivering high-quality results. While building in public has been an excellent extrinsic motivator, I've discovered that I'm more intrinsically driven. So, instead of daily updates, I'll be sharing my progress when significant breakthroughs happen.

Speaking of projects, the one I've been working on, my first significant endeavor, is still in progress. I started it with the primary goal of sharpening my programming skills, and I'm determined to see it through completion. Along the way, I'll continue to tackle other exciting projects, each one pushing me to learn and grow. Rest assured, I'll keep sharing my journey and projects with all of you, my wonderful audience.

Thank you once again for joining me on this #100DaysOfCode adventure. It's been an honor to have you by my side.

Today, I worked on and completed the like, dislike, and undo buttons. Here's some of the code I wrote today:


  // dislike button clicked

  useEffect(() => {
    if (dislikeClicked) {
      async function handleDislike() {
        try {
          if (!activeSwipe) return;

          const likedFreelancerIds =
            filteredNotLikedFreelancers[currentIndex]?.user_id;
          setLastDirection('down');
          updateCurrentIndex(currentIndex - 1);
          setSwipedCards((prevSwipedCards) =>[
            ...prevSwipedCards, 
            { index: currentIndex, freelancerId: likedFreelancerIds }
          ])
        } catch (error) {
          console.log(error);
        }
      }
      handleDislike();
      setDislikeClicked(false);
    }
  }, [dislikeClicked]);

  // like button clicked

  useEffect(() =>{
    if(likeClicked) {
      async function handleLike() {
        try {
          if (!activeSwipe) return;

          const likedFreelancerIds = filteredNotLikedFreelancers[currentIndex]?.user_id;
          await functionLikeFreelancer(likedFreelancerIds);
          setLastDirection('up');
          updateCurrentIndex(currentIndex - 1);
          setSwipedCards((prevSwipedCards) => [
            ...prevSwipedCards, 
            { index: currentIndex, freelancerId: likedFreelancerIds }
          ])

        } catch(error) {
          console.log(error)
        }
      }

      handleLike();
      setLikeClicked(false);
    }
  }, [likeClicked])


  // the undo button is clicked

  useEffect(() => {
    if (undoClicked) {
      async function undo() {
        try {
          if (!activeUndo || swipedCards.length === 0) return;

          const lastSwipedCard = swipedCards[swipedCards.length - 1];
          setSwipedCards(swipedCards.slice(0, -1));
          updateCurrentIndex(lastSwipedCard.index);

          const response = await axios.patch("/removeLikedFreelancers", {
            userId,
            freelancerId: lastSwipedCard.freelancerId,
          });
          const updatedUserConnects = response.data.client_connects;
          setUpdatedConnects(updatedUserConnects);
          window.location.reload();
        } catch (err) {
          console.log("err", err);
        }
      }
      undo();
      setUndoClicked(false);
    }
  }, [undoClicked, swipedCards]);