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

0 stars 0 forks source link

Species Delete #16

Closed jbkey2015 closed 4 years ago

jbkey2015 commented 5 years ago

User Story

As a user, I should be able to delete a species from the Nautilus.

AC

WHEN the user logs in, they should see a display of all species. AND when a user clicks on the delete link within the species card the card will then disappear.

DEV Notes

  1. In the speciesCard folder
    • [ ] Make a function called deleteSpecies
    • [ ] e.preventdefault()
    • [ ] Grab the id from firebase
    • [ ] Create variable called speciesId that will grab the target if which is speciesDelete and use the split method
    • [ ] Pass in species board data
    • [ ] Then call buildSpecies(id)
    • [ ] Catch any errors
const deleteSpecies = (e) => {
  e.preventDefault();
  const { id } = firebase.auth().currentUser;
  const boardId = e.target.id.split('board-')[1];
  speciesData.deleteSpecies(boardId)
    .then(() => {
      // eslint-disable-next-line no-use-before-define
      buildSpecies(id);
    })
    .catch((error) => console.error(error));
};

$('#speciesDiv').on('click', '.deletespecies', deleteSpecies);

  1. In my speciesData file

const deleteSpecies= (boardId) => axios.delete(`${baseUrl}/species/${boardId}.json`);