nss-evening-cohort-10 / nutshell-nautilus-explorer

0 stars 0 forks source link

Species All #33

Closed jbkey2015 closed 4 years ago

jbkey2015 commented 4 years ago

User Story

As a user, I should be able to see all the Species when I arrive at a destination.

AC

WHEN the user is logged in they will be on the homepage. When the user clicks on the species card then they will be able to see all of the species.

AND when the user clicks on the species a card will appear that gives a description of that species.

THEN the user can click on a button to go back to the species page.

DEV Notes

  1. Wireframe: see wireframe below for the way this page and its cards should appear

  2. Creating JSON data

    • [ ] create species.json seed data in the db folder of my project
    • [ ] create 6 species cards with the name, type, and if they are endangered
  3. Create Div

  1. Helpers/Data
    • [ ] In helpers, I will create a data file called speciesData.
    • [ ] Import axios
    • [ ] Import apiKeys in order to grab the data from firebase
    • [ ] Make a variable called baseURL that will contain the apikeys databae Url const baseUrl = apiKeys.firebaseKeys.databaseURL
    • [ ] Create function called getSpecies
      • make a new promise – use axios.get to retrieve data from firebase
      • EXAMPLE:
const getSpecies = (uid) => new Promise((resolve, reject) => {
  axios.get(`${baseUrl}/species.json?orderBy="id"&equalTo="${id}"`)
    .then((response) => {
      const nautSpecies = response.data;
      const speciesBoards = [];
      Object.keys(nautSpecies).forEach((fbId) => {
        nautSpecies[fbId].id = fbId;
        speciesBoards.push(nautSpecies[fbId]);
      });
      resolve(speciesBoards); 
    })
    .catch((error) => reject(error));
});
  1. speciesCard Component
  1. speciesBoard Component
const buildSpecies = (id) => {
  speciesData.getSpecies(id)
    .then((speciesBoards) => {
      console.log('the boards', speciesBoards);
      let domString = '<div id="boardSection" class="d-flex flex-wrap">';
      speciesBoards.forEach((speciesBoards) => {
        domString += speciesCard.makespeciesCard(board);
      });
      domString += '</div>';
      utilities.printToDom('speciesBoards', domString);
    })
    .catch((error) => console.error(error));
};

export default { buildSpecies};
  1. Auth Data
      speciesBoards.buildSpecies(user.id); 
  1. Main.js
jbkey2015 commented 4 years ago

image

jbkey2015 commented 4 years ago

image