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

Star Destroyer
0 stars 2 forks source link

Delete Mission Personnel #118

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 personnel

AC

WHEN the page loads I should see a mission and on that mission board there should be a delete button that allows the user to delete personnel from the mission THEN click on that delete button AND the person deletes from the mission

DEV NOTES


•Inside the mission folder on the mission.js file import the missionComponent file that contains the mission domString import missionComponent from './missionComponent'; import missionPersonnelData from './missionPersonnelData';

•add this icon on the mission domString in the missionPersonnelComponent with an Id of mission-personnel-delete-btn

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

•create a delete function that will delete the entire mission. call it

missionPersonnelDelete

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

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

$('body').on('click', '.mission-personnel-delete-btn', missionPersonnelDelete);

inside the mission authData.js add

missions.clickEvents();

•to the if statement

inside the missionData.js file add an axios call

const deleteMissionPersonnel = (missionPersonnelId) => axios.delete(${baseUrl}/mission/${missionPersonnelId}.json);