add more translations and resolve issues

This commit is contained in:
Mario
2020-12-14 13:50:44 +01:00
parent 7d1d2409e4
commit e5204bb4d5
20 changed files with 362 additions and 325 deletions
+20 -21
View File
@@ -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'));
}
});
+15 -15
View File
@@ -1,10 +1,10 @@
import { MYBADGES_DISCONNECT, TUTORIAL_PROGRESS, GET_TUTORIAL, GET_TUTORIALS, TUTORIAL_SUCCESS, TUTORIAL_ERROR, TUTORIAL_CHANGE, TUTORIAL_XML, TUTORIAL_ID, TUTORIAL_STEP } from './types';
import { MYBADGES_DISCONNECT, TUTORIAL_PROGRESS, GET_TUTORIAL, GET_TUTORIALS, TUTORIAL_SUCCESS, TUTORIAL_ERROR, TUTORIAL_CHANGE, TUTORIAL_XML, TUTORIAL_STEP } from './types';
import axios from 'axios';
import { returnErrors, returnSuccess } from './messageActions';
export const getTutorial = (id) => (dispatch, getState) => {
dispatch({type: TUTORIAL_PROGRESS});
dispatch({ type: TUTORIAL_PROGRESS });
axios.get(`${process.env.REACT_APP_BLOCKLY_API}/tutorial/${id}`)
.then(res => {
var tutorial = res.data.tutorial;
@@ -13,7 +13,7 @@ export const getTutorial = (id) => (dispatch, getState) => {
type: TUTORIAL_SUCCESS,
payload: status
});
dispatch({type: TUTORIAL_PROGRESS});
dispatch({ type: TUTORIAL_PROGRESS });
dispatch({
type: GET_TUTORIAL,
payload: tutorial
@@ -22,15 +22,15 @@ export const getTutorial = (id) => (dispatch, getState) => {
});
})
.catch(err => {
if(err.response){
if (err.response) {
dispatch(returnErrors(err.response.data.message, err.response.status, 'GET_TUTORIAL_FAIL'));
}
dispatch({type: TUTORIAL_PROGRESS});
dispatch({ type: TUTORIAL_PROGRESS });
});
};
export const getTutorials = () => (dispatch, getState) => {
dispatch({type: TUTORIAL_PROGRESS});
dispatch({ type: TUTORIAL_PROGRESS });
axios.get(`${process.env.REACT_APP_BLOCKLY_API}/tutorial`)
.then(res => {
var tutorials = res.data.tutorials;
@@ -44,15 +44,15 @@ export const getTutorials = () => (dispatch, getState) => {
type: GET_TUTORIALS,
payload: tutorials
});
dispatch({type: TUTORIAL_PROGRESS});
dispatch({ type: TUTORIAL_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_TUTORIALS_FAIL'));
}
dispatch({type: TUTORIAL_PROGRESS});
dispatch({ type: TUTORIAL_PROGRESS });
});
};
@@ -69,7 +69,7 @@ export const assigneBadge = (id) => (dispatch, getState) => {
dispatch(returnSuccess(badge, res.status, 'ASSIGNE_BADGE_SUCCESS'));
})
.catch(err => {
if(err.response){
if (err.response) {
dispatch(returnErrors(err.response.data.message, err.response.status, 'ASSIGNE_BADGE_FAIL'));
}
});
@@ -90,7 +90,7 @@ export const deleteTutorial = (id) => (dispatch, getState) => {
dispatch(returnSuccess(res.data.message, res.status, 'TUTORIAL_DELETE_SUCCESS'));
})
.catch(err => {
if(err.response){
if (err.response) {
dispatch(returnErrors(err.response.data.message, err.response.status, 'TUTORIAL_DELETE_FAIL'));
}
});
@@ -128,7 +128,7 @@ export const tutorialCheck = (status, step) => (dispatch, getState) => {
payload: tutorialsStatus
});
dispatch(tutorialChange());
dispatch(returnSuccess('','','TUTORIAL_CHECK_SUCCESS'));
dispatch(returnSuccess('', '', 'TUTORIAL_CHECK_SUCCESS'));
};
export const storeTutorialXml = (code) => (dispatch, getState) => {
@@ -161,9 +161,9 @@ export const tutorialStep = (step) => (dispatch) => {
};
const existingTutorials = (tutorials, status) => new Promise(function(resolve, reject){
const existingTutorials = (tutorials, status) => new Promise(function (resolve, reject) {
var newstatus;
new Promise(function(resolve, reject){
new Promise(function (resolve, reject) {
var existingTutorialIds = tutorials.map((tutorial, i) => {
existingTutorial(tutorial, status).then(status => {
newstatus = status;
@@ -180,7 +180,7 @@ const existingTutorials = (tutorials, status) => new Promise(function(resolve, r
});
});
const existingTutorial = (tutorial, status) => new Promise(function(resolve, reject){
const existingTutorial = (tutorial, status) => new Promise(function (resolve, reject) {
var tutorialsId = tutorial._id;
var statusIndex = status.findIndex(status => status._id === tutorialsId);
if (statusIndex > -1) {