fixed delete option

This commit is contained in:
u-e 2019-04-14 14:44:31 +03:00
parent 738f24786c
commit 81a8653ccf
2 changed files with 8 additions and 9 deletions

View File

@ -23,9 +23,9 @@ export const getDrafts = data => new Promise((resolve, reject) => {
* @params username
* @params draftID
*/
export const removeDraft = data => new Promise((resolve, reject) => {
export const removeDraft = (username, id) => new Promise((resolve, reject) => {
api
.delete(`/drafts/${data.username}/${data.draftId}`)
.delete(`/drafts/${username}/${id}`)
.then((res) => {
resolve(res.data);
})
@ -238,16 +238,16 @@ export const schedule = (
})
.then(resp => resp.data);
export const getSchedules = user => api.get(`/schedules/${user}`).then(resp => resp.data);
export const getSchedules = username => api.get(`/schedules/${username}`).then(resp => resp.data);
export const removeSchedule = (user, id) => api.delete(`/schedules/${user}/${id}`);
export const removeSchedule = (username, id) => api.delete(`/schedules/${username}/${id}`);
export const moveSchedule = (id, user) => api.put(`/schedules/${user}/${id}`);
export const moveSchedule = (id, username) => api.put(`/schedules/${username}/${id}`);
// Old image service
// Images
export const getImages = user => api.get(`api/images/${user}`).then(resp => resp.data);
export const getImages = username => api.get(`api/images/${username}`).then(resp => resp.data);
export const addMyImage = (user, url) => api.post('/image', { username: user, image_url: url });

View File

@ -74,7 +74,7 @@ class DraftsContainer extends Component {
_removeDraft = (id) => {
const { currentAccount, intl } = this.props;
removeDraft({ username: currentAccount.name, draftId: id })
removeDraft(currentAccount.name, id)
.then(() => {
const { drafts } = this.state;
const newDrafts = [...drafts].filter(draft => draft._id !== id);
@ -88,9 +88,8 @@ class DraftsContainer extends Component {
_removeSchedule = (id) => {
const { currentAccount, intl } = this.props;
console.log(id);
removeSchedule({ username: currentAccount.name, draftId: id })
removeSchedule(currentAccount.name, id)
.then((res) => {
const { schedules } = this.state;
const newSchedules = [...schedules].filter(schedule => schedule._id !== id);