add more translations and resolve issues
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
import { PROJECT_PROGRESS, GET_PROJECT, GET_PROJECTS, PROJECT_TYPE, PROJECT_DESCRIPTION } from './types';
|
||||
|
||||
import axios from 'axios';
|
||||
import { workspaceName } from './workspaceActions';
|
||||
import { returnErrors, returnSuccess } from './messageActions';
|
||||
|
||||
export const setType = (type) => (dispatch) => {
|
||||
@@ -19,13 +18,13 @@ export const setDescription = (description) => (dispatch) => {
|
||||
};
|
||||
|
||||
export const getProject = (type, id) => (dispatch) => {
|
||||
dispatch({type: PROJECT_PROGRESS});
|
||||
dispatch({ type: PROJECT_PROGRESS });
|
||||
dispatch(setType(type));
|
||||
axios.get(`${process.env.REACT_APP_BLOCKLY_API}/${type}/${id}`)
|
||||
.then(res => {
|
||||
var data = type === 'share' ? 'content' : type;
|
||||
var project = res.data[data];
|
||||
if(project){
|
||||
if (project) {
|
||||
dispatch({
|
||||
type: GET_PROJECT,
|
||||
payload: project
|
||||
@@ -34,24 +33,24 @@ export const getProject = (type, id) => (dispatch) => {
|
||||
type: PROJECT_DESCRIPTION,
|
||||
payload: project.description
|
||||
});
|
||||
dispatch({type: PROJECT_PROGRESS});
|
||||
dispatch({ type: PROJECT_PROGRESS });
|
||||
dispatch(returnSuccess(res.data.message, res.status, 'GET_PROJECT_SUCCESS'));
|
||||
}
|
||||
else{
|
||||
dispatch({type: PROJECT_PROGRESS});
|
||||
else {
|
||||
dispatch({ type: PROJECT_PROGRESS });
|
||||
dispatch(returnErrors(res.data.message, res.status, 'PROJECT_EMPTY'));
|
||||
}
|
||||
})
|
||||
.catch(err => {
|
||||
if(err.response){
|
||||
if (err.response) {
|
||||
dispatch(returnErrors(err.response.data.message, err.response.status, 'GET_PROJECT_FAIL'));
|
||||
}
|
||||
dispatch({type: PROJECT_PROGRESS});
|
||||
dispatch({ type: PROJECT_PROGRESS });
|
||||
});
|
||||
};
|
||||
|
||||
export const getProjects = (type) => (dispatch) => {
|
||||
dispatch({type: PROJECT_PROGRESS});
|
||||
dispatch({ type: PROJECT_PROGRESS });
|
||||
axios.get(`${process.env.REACT_APP_BLOCKLY_API}/${type}`)
|
||||
.then(res => {
|
||||
var data = type === 'project' ? 'projects' : 'galleries';
|
||||
@@ -60,14 +59,14 @@ export const getProjects = (type) => (dispatch) => {
|
||||
type: GET_PROJECTS,
|
||||
payload: projects
|
||||
});
|
||||
dispatch({type: PROJECT_PROGRESS});
|
||||
dispatch({ type: PROJECT_PROGRESS });
|
||||
dispatch(returnSuccess(res.data.message, res.status));
|
||||
})
|
||||
.catch(err => {
|
||||
if(err.response){
|
||||
if (err.response) {
|
||||
dispatch(returnErrors(err.response.data.message, err.response.status, 'GET_PROJECTS_FAIL'));
|
||||
}
|
||||
dispatch({type: PROJECT_PROGRESS});
|
||||
dispatch({ type: PROJECT_PROGRESS });
|
||||
});
|
||||
};
|
||||
|
||||
@@ -78,7 +77,7 @@ export const updateProject = (type, id) => (dispatch, getState) => {
|
||||
title: workspace.name
|
||||
};
|
||||
var project = getState().project;
|
||||
if(type==='gallery'){
|
||||
if (type === 'gallery') {
|
||||
body.description = project.description;
|
||||
}
|
||||
axios.put(`${process.env.REACT_APP_BLOCKLY_API}/${type}/${id}`, body)
|
||||
@@ -91,15 +90,15 @@ export const updateProject = (type, id) => (dispatch, getState) => {
|
||||
type: GET_PROJECTS,
|
||||
payload: projects
|
||||
});
|
||||
if(type === 'project'){
|
||||
if (type === 'project') {
|
||||
dispatch(returnSuccess(res.data.message, res.status, 'PROJECT_UPDATE_SUCCESS'));
|
||||
} else {
|
||||
dispatch(returnSuccess(res.data.message, res.status, 'GALLERY_UPDATE_SUCCESS'));
|
||||
}
|
||||
})
|
||||
.catch(err => {
|
||||
if(err.response){
|
||||
if(type === 'project'){
|
||||
if (err.response) {
|
||||
if (type === 'project') {
|
||||
dispatch(returnErrors(err.response.data.message, err.response.status, 'PROJECT_UPDATE_FAIL'));
|
||||
} else {
|
||||
dispatch(returnErrors(err.response.data.message, err.response.status, 'GALLERY_UPDATE_FAIL'));
|
||||
@@ -119,14 +118,14 @@ export const deleteProject = (type, id) => (dispatch, getState) => {
|
||||
type: GET_PROJECTS,
|
||||
payload: projects
|
||||
});
|
||||
if(type === 'project'){
|
||||
if (type === 'project') {
|
||||
dispatch(returnSuccess(res.data.message, res.status, 'PROJECT_DELETE_SUCCESS'));
|
||||
} else {
|
||||
dispatch(returnSuccess(res.data.message, res.status, 'GALLERY_DELETE_SUCCESS'));
|
||||
}
|
||||
})
|
||||
.catch(err => {
|
||||
if(err.response){
|
||||
if (err.response) {
|
||||
dispatch(returnErrors(err.response.data.message, err.response.status, 'PROJECT_DELETE_FAIL'));
|
||||
}
|
||||
});
|
||||
@@ -137,7 +136,7 @@ export const shareProject = (title, type, id) => (dispatch, getState) => {
|
||||
var body = {
|
||||
title: title
|
||||
};
|
||||
if(type === 'project'){
|
||||
if (type === 'project') {
|
||||
body.projectId = id;
|
||||
} else {
|
||||
body.xml = getState().workspace.code.xml;
|
||||
@@ -145,7 +144,7 @@ export const shareProject = (title, type, id) => (dispatch, getState) => {
|
||||
axios.post(`${process.env.REACT_APP_BLOCKLY_API}/share`, body)
|
||||
.then(res => {
|
||||
var shareContent = res.data.content;
|
||||
if(body.projectId){
|
||||
if (body.projectId) {
|
||||
var projects = getState().project.projects;
|
||||
var index = projects.findIndex(res => res._id === id);
|
||||
projects[index].shared = shareContent.expiresAt;
|
||||
@@ -157,7 +156,7 @@ export const shareProject = (title, type, id) => (dispatch, getState) => {
|
||||
dispatch(returnSuccess(res.data.message, shareContent._id, 'SHARE_SUCCESS'));
|
||||
})
|
||||
.catch(err => {
|
||||
if(err.response){
|
||||
if (err.response) {
|
||||
dispatch(returnErrors(err.response.data.message, err.response.status, 'SHARE_FAIL'));
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user