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
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);
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
);