parent
c42de5b2ae
commit
a8570bdb22
1 changed files with 8 additions and 1 deletions
|
@ -1,5 +1,7 @@
|
||||||
import * as ActionTypes from '../../../constants';
|
import * as ActionTypes from '../../../constants';
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
|
import { setPreviousPath } from './ide';
|
||||||
|
import { resetProject } from './project';
|
||||||
import { showAuthenticationError } from './ide';
|
import { showAuthenticationError } from './ide';
|
||||||
|
|
||||||
const ROOT_URL = location.href.indexOf('localhost') > 0 ? 'http://localhost:8000/api' : '/api';
|
const ROOT_URL = location.href.indexOf('localhost') > 0 ? 'http://localhost:8000/api' : '/api';
|
||||||
|
@ -27,9 +29,14 @@ export function getProjects(username) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function deleteProject(id) {
|
export function deleteProject(id) {
|
||||||
return (dispatch) => {
|
return (dispatch, getState) => {
|
||||||
axios.delete(`${ROOT_URL}/projects/${id}`, { withCredentials: true })
|
axios.delete(`${ROOT_URL}/projects/${id}`, { withCredentials: true })
|
||||||
.then(() => {
|
.then(() => {
|
||||||
|
const state = getState();
|
||||||
|
if (id === state.project.id) {
|
||||||
|
dispatch(resetProject());
|
||||||
|
dispatch(setPreviousPath('/'));
|
||||||
|
}
|
||||||
dispatch({
|
dispatch({
|
||||||
type: ActionTypes.DELETE_PROJECT,
|
type: ActionTypes.DELETE_PROJECT,
|
||||||
id
|
id
|
||||||
|
|
Loading…
Reference in a new issue