Closed christopherjohnson1 closed 4 years ago
as a user I should be able to edit a weapon
WHEN the user logs in THEN there should be an edit button on all weapon cards AND you should be able to update any weapon item with a modal form
<div>
id="edit-weapon-modal"
id="add-new-weapon-modal"
buildWeaponCards
class="edit-weapon-btn"
editWeaponForm
weaponsData
utils
id="submit-weapon-edit"
editWeaponItem
weapons.js
weaponsData.js
updateWeapon
axios.put(weaponId, editedWeaponItem)
editedWeaponItem
key:value
.then()
buildAllWeapons
.catch()
User Story
as a user I should be able to edit a weapon
AC
WHEN the user logs in THEN there should be an edit button on all weapon cards AND you should be able to update any weapon item with a modal form
Dev Notes
<div>
withid="edit-weapon-modal"
at the top of index.html, underid="add-new-weapon-modal"
and above everything elsebuildWeaponCards
functionclass="edit-weapon-btn"
editWeaponForm
functioneditWeaponForm
editWeaponForm
functionweaponsData
utils
id="submit-weapon-edit"
editWeaponItem
which lives inweapons.js
weaponsData.js
make a new function calledupdateWeapon
that usesaxios.put(weaponId, editedWeaponItem)
methodeditedWeaponItem
that has thekey:value
pairs the same as the original seed data objectsupdateWeapon
ineditWeaponItem
.then()
callsbuildAllWeapons
.catch()
should console.error a comment and the error