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

Star Destroyer
0 stars 2 forks source link

Weapons delete Axios.delete #29

Closed Nikababy01 closed 4 years ago

Nikababy01 commented 4 years ago

USER STORY

As a user, I should be able to delete a Weapon.

AC

WHEN the page loads I should see all weapons THEN click a button to delete AND can see that it deleted

WIREFRAMES

image

image

DEV NOTES


1. Create a bootstrap button
const completelyRemoveWeapon = (weaponId) => new Promise((resolve, reject) => {
  weaponsData.deleteWeapon(weaponId)
    .then(() => {

      weaponsData.getWeaponsById(weaponId).then((weaponId) => {
         weapons.forEach((weapons) => {
        weaponsData.deleteweapons(weapon.id);
        });
        resolve();
      });
    })
    .catch((err) => reject(err));

2. const deleteWeapon = (weaponId) => axios.delete(`${baseUrl}/weapons/${weaponsId}.json`);
3.  In weapons.js
 const removeWeapons = (e) => {
  const weaponId = e.target.closest('.card').id;
  weaponsData.completelyRemoveWeapons(weaponsId)
    .then(() => {
      // eslint-disable-next-line no-use-before-define
      buildWeapons();
      utils.printToDom('single-weapon', '');
    })
    .catch((err) => console.error('could not delete weapon', err));
};

RELATED TICKETS

EX. #4