nss-evening-cohort-10 / nutshell-star-destroyer

0 stars 1 forks source link

Sectors: Delete #20

Closed mariabrock closed 4 years ago

mariabrock commented 4 years ago

User Story

As a user, I should be able to delete a Planetary Sector.

AC

WHEN a user is logged in THEN they should have the option to click a button to delete an entry *AND* a modal will pop up prompting them to verify that they want to delete an entry AND*** the user will have to click the Confirm button to completely delete the entry

Dev Notes

  1. Wireframes

    • see the wireframe below for the basic structure of the modal
  2. Modal *use a bootstrap modal and button as confirmation that a user wants to delete selected entry

*for styling please reference the Imperial style guide below

  1. Deleting Data
    • when the Delete button is clicked, a function named deleteSector should run in sectors.js
mariabrock commented 4 years ago

Button: https://getbootstrap.com/docs/4.3/components/buttons/#examples Modal: https://getbootstrap.com/docs/4.3/components/modal/#modal-components

mariabrock commented 4 years ago

update-delete-entry-wireframe

mariabrock commented 4 years ago

confirm-modal-wireframe

ConnorSullivan10 commented 4 years ago
  1. create function in sectorData.js to delete a sector based on the id selected, and export it:
const deleteSector= (sectorID) => axios.delete(`${baseUrl}/sectors/${sectorID}.json`);

export default { deleteSector };
  1. import deleteSector into sectors.js file in Sectors component and write a function that will be attached to an event listener which will target the Sector by id attached to it's "Close" button, and pass deleteSector and then reprint the cards after the info has been deleted from firebase. Should look something along the lines of:
const deleteSector = (e) => {
  e.preventDefault();
  sectorData.deleteSector(e.target.id)
    .then(() => {
    // eslint-disable-next-line no-use-before-define
      displayAllSectors();
    })
    .catch((error) => console.error(error));
};
  1. write event listener at the end of displayAllSectors that calls deleteSector on click of the id attached to the "Close" button on each sector card. Should look similar to: $(document.body).on('click', '.delete-sector', deleteSector);