ancasimon / travel-diary

This project is an online journal that allows users to keep track of destinations on their bucket list and then capture diary entries when they actually get to visit these sites. It was further practice with using data from multiple collections in a Firebase database.
https://traveldiary-78295.web.app/#
1 stars 0 forks source link

BONUS: Change destination card color once it has resulted in a diary entry #10

Closed ancasimon closed 4 years ago

ancasimon commented 4 years ago

User Story

Once a user has written about a place at least once, change the color of the card for that place.

AC

WHEN I go to the Travel Diary site and add a diary entry for a destination, THEN the background color of the destination card changes.

Dev Notes

ancasimon commented 4 years ago

smash function below:

const getDestinationsWithDiaryEntries = () => new Promise((resolve, reject) => {
  destinationData.getDestinations()
    .then((destinationResponse) => {
      diaryData.getDiaryEntries().then((diaryResponse) => {
        console.error('dest respo', destinationResponse);
        console.error('diary respo', diaryResponse);
        const finalDestinations = [];
        diaryResponse.forEach((diary) => {
          const selectedDestination = destinationResponse.find((x) => x.id === diary.destinationId);
          finalDestinations.push(selectedDestination);
          resolve(finalDestinations);
          console.error('final dest', finalDestinations);
        });
      });
    })
    .catch((error) => reject(error));
});