As a user, when the edit song page loads, I should able to edit songs in the list
AC
WHEN looking at the songs page
THEN I click on the edit song button
AND I am taken to the edit song page
AND I should be able to edit a song
Dev Notes
on Song page and SingleSong page
add a link that takes you to editSong page
on editSong page
in state create an object that is set to an empty string with the keys songTitlealbumTitleartistreleaseYear and albumImage
create componentDidMount()
on mount store editId in this.props.match.params.songId;
.then should return the response
store song in response.data
setState should be take new values of song.songTitlesong.albumTitlesong.artistsong.releaseYear and song.albumImage
create functions to reset the setState to e.target.value
the functions should be titleChangealbumChangeartistChangereleaseYearChange and albumImageChange
updateSong should store { songId } in this.props.match.params
it should get songTitlealbumTitleartistreleaseYear and albumImage from this.state
it should then build an updateSong object with the following keys titleChangealbumChangeartistChangereleaseYearChange and albumImageChange
then it should call putSong from itemsData and pass in songId and updatedSong
the .then should use this.props.history.push to take the user back to /songs page
the.catch should console.error unable to save song
the render() should retrieve songTitlealbumTitleartistreleaseYear and albumImage from this.state
the return should build a form with the following inputs
<input type="text" className="form-control" id="song-title" value={songTitle} onChange={this.titleChange} />
the bottom of the form should include a button
the button should have an onClick function that calls this.updateSong
User Story
As a user, when the edit song page loads, I should able to edit songs in the list
AC
WHEN looking at the songs page THEN I click on the edit song button AND I am taken to the edit song page AND I should be able to edit a song
Dev Notes
on
Song
page andSingleSong
pagelink
that takes you toeditSong
pageon
editSong
pagein
state
create an object that is set to an empty string with the keyssongTitle
albumTitle
artist
releaseYear
andalbumImage
create
componentDidMount()
on mount store
editId
in this.props.match.params.songId;.then
should return theresponse
store
song
inresponse.data
setState
should be take new values ofsong.songTitle
song.albumTitle
song.artist
song.releaseYear
andsong.albumImage
create functions to reset the
setState
toe.target.value
the functions should be
titleChange
albumChange
artistChange
releaseYearChange
andalbumImageChange
updateSong
should store{ songId }
inthis.props.match.params
it should get
songTitle
albumTitle
artist
releaseYear
andalbumImage
fromthis.state
it should then build an
updateSong
object with the following keystitleChange
albumChange
artistChange
releaseYearChange
andalbumImageChange
then it should call
putSong
fromitemsData
and pass insongId
andupdatedSong
the
.then
should usethis.props.history.push
to take the user back to/songs
pagethe
.catch
shouldconsole.error
unable to save songthe
render()
should retrievesongTitle
albumTitle
artist
releaseYear
andalbumImage
fromthis.state
the
return
should build a form with the following inputs<input type="text" className="form-control" id="song-title" value={songTitle} onChange={this.titleChange} />
the bottom of the form should include a
button
the button should have an
onClick
function that callsthis.updateSong