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

0 stars 0 forks source link

DELETE - excursions #79

Open denzelb5 opened 4 years ago

denzelb5 commented 4 years ago

User Story

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

AC

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

DEV Notes

In the excursions folder Make a function called deleteExcursion() E.preventdefault() Create variable called excursionCardId. Use the split method to target the specific id of the excursion card to be deleted. Pass in excursion data Then call printExcursionCards() Catch any errors


const deleteExcursion = (e) => { e.preventDefault(); const excursionCardId = e.target.id.split('excursionCard-')[1]; crewData.deleteExcursion(excursionCardId) .then(() => { // eslint-disable-next-line no-use-before-define printExcursionCards(); }) .catch((error) => console.error(error)); };


In the printExcursionCard function, create a click event listener that will target the div id called excursionDiv. Call the deleteExcursion function and have the class for the delete link as .delete-excursion $('#excursionDiv').on('click', '.delete-excursion', deleteExcursion);

In the excursionsData file Make axios.delete in excursionData file and pass the excursion card id. const deleteExcursion= (excursionCardId) => axios.delete(${baseUrl}/excursions/${excursionCardId}.json);

gregkorte commented 4 years ago

In dev notes: No need for a uid.

phillipsja97 commented 4 years ago

Updated the ticket taking out the uid in the function and the DevNotes.