Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/pages/Story.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,11 @@ const Story = (props) => {
document.body.removeChild(dummy)
}

const deleteStory = async () => {
await userStory.deleteStory(storyId)
navigate('/')
}

const hashtagsArray = ['EOS', 'userstory']
const title = 'EOS User Story - POST Stories. GET Features.'

Expand Down Expand Up @@ -173,6 +178,13 @@ const Story = (props) => {
>
Edit
</Button>
<Button
className='btn btn-default'
data-cy='btn-delete'
onClick={deleteStory}
>
Delete
</Button>
</>
) : (
''
Expand Down
4 changes: 2 additions & 2 deletions src/services/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ apiClient.interceptors.response.use(
}
)

function apiCall(url, data) {
function apiCall(url, data, _method = 'post') {
return apiClient.request({
url,
method: 'post',
method: _method,
data,
...config
})
Expand Down
3 changes: 3 additions & 0 deletions src/services/user_story.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ const userStory = {
createStory: (data) => {
return apiCall('/user-stories', data)
},
deleteStory: (storyId) => {
return apiCall(`/user-stories/${storyId}`, null, 'delete')
},
checkAuthor: (userId, storyId) => {
return apiCall('/checkAuthor', {
id: userId,
Expand Down