show assigned badge

This commit is contained in:
Delucse
2020-12-10 10:31:43 +01:00
parent 101dfc7692
commit 5430e783cc
3 changed files with 55 additions and 13 deletions
+2
View File
@@ -86,6 +86,7 @@ export const connectMyBadges = ({ username, password }) => (dispatch, getState)
.then(res => {
var user = getState().auth.user;
user.badge = res.data.account;
user.badges = res.data.badges;
dispatch({
type: MYBADGES_CONNECT,
payload: user
@@ -109,6 +110,7 @@ export const disconnectMyBadges = () => (dispatch, getState) => {
.then(res => {
var user = getState().auth.user;
user.badge = null;
user.badges = null;
dispatch({
type: MYBADGES_DISCONNECT,
payload: user
+8 -1
View File
@@ -1,4 +1,4 @@
import { 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_ID, TUTORIAL_STEP } from './types';
import axios from 'axios';
import { returnErrors, returnSuccess } from './messageActions';
@@ -60,6 +60,12 @@ export const assigneBadge = (id) => (dispatch, getState) => {
axios.put(`${process.env.REACT_APP_BLOCKLY_API}/user/badge/${id}`)
.then(res => {
var badge = res.data.badge;
var user = getState().auth.user;
user.badges.push(badge._id);
dispatch({
type: MYBADGES_DISCONNECT,
payload: user
});
dispatch(returnSuccess(badge, res.status, 'ASSIGNE_BADGE_SUCCESS'));
})
.catch(err => {
@@ -122,6 +128,7 @@ export const tutorialCheck = (status, step) => (dispatch, getState) => {
payload: tutorialsStatus
});
dispatch(tutorialChange());
dispatch(returnSuccess('','','TUTORIAL_CHECK_SUCCESS'));
};
export const storeTutorialXml = (code) => (dispatch, getState) => {