As a logged in user I can edit my own comments so that I can amend and update my thoughts
Acceptance Criteria
An edit icon should appear next to any comments owned by the currently logged in user
Clicking on the edit icon should pre-populate a text field with the existing comment
Clicking on the submit button should update the comment and these amendments should be immediately visible to the user
There should be an option to cancel the update if the user changes their mind
Tasks
[x] Create the CommentEditForm page in src/pages/comments
[x] De-structure props that have been passed in (id, content, setShowEditForm, setComments)
[x] Use the content variable to pre-populate the text field form input. Use this as a default value for formContent. The text area form input rendered in the return statement should have value set to formContent. So it will default to the existing comment and then be updated via a handleChange function as the user types.
[x] In the Comment component, show the EditDelete component if the user owns the comment. Clicking on the edit icon should run setShowEditForm with True passed as an argument.
[x] Write a handleChange function that sets formContent as the form input value changes.
[x] Write handleSubmit function that makes a put request to the comments API endpoint, specifying a specific comment id.
[x] On successful submission, the updated_at field of the associated comment should be set as "now" and setShowEditForm should be passed a value of False so the comment update form is hidden.
EPIC: #15
As a logged in user I can edit my own comments so that I can amend and update my thoughts
Acceptance Criteria
Tasks
content
variable to pre-populate the text field form input. Use this as a default value for formContent. The text area form input rendered in the return statement should have value set toformContent
. So it will default to the existing comment and then be updated via a handleChange function as the user types.True
passed as an argument.formContent
as the form input value changes.False
so the comment update form is hidden.