add more translations and resolve issues
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user