nss-evening-cohort-11 / nutshell-ewoks-droids

Star Destroyer
0 stars 2 forks source link

Delete Mission Weapons #119

Open kenymc1 opened 4 years ago

kenymc1 commented 4 years ago

USER STORY

As a user, when I am on the mission view of the website, there should be some way to delete the mission weapons

AC

WHEN the page loads I should see a mission and on that mission board there should be able to delete mission weapons with a button. THEN click on that weapon delete button AND then weapon deletes

DEV NOTES


•Inside the mission folder on the mission.js file import the missionComponent file that contains the mission domString import missionComponent from './missionComponent'; •add this icon on the mission domString in the missionComponent with an Id of mission-weapons-delete-btn

<i class="fas fa-times-circle"></i>

•create a delete function that will delete weapons. call it

missionWeaponsDelete

const missionWeaponsDelete = (e) => { const selectedMissionWeaponsId = e.target.closest('.user-card').id; missionData.missionWeaponsDelete (selectedMissionWeaponsId ) .then(() => { // eslint-disable-next-line no-use-before-define printMission(); }) // eslint-disable-next-line no-console .catch((err) => console.err('cannot remove mission weapons', err)); };

•create a click event for the function in the mission.js file

$('body').on('click', '.mission-weapons-delete-btn ', missionWeaponsDelete);

inside the mission authData.js add

missions.clickEvents();

•to the if statement

inside the missionData.js file add an axios call

const deleteMissionWeapons = (missionWeaponsId) => axios.delete(${baseUrl}/missionWeapons/${missionWeaponsId}.json);