Skip to content
Snippets Groups Projects
Commit 9893786a authored by Tamás Szabó's avatar Tamás Szabó
Browse files

motivation with three questions

parent f8fddf01
No related branches found
No related tags found
No related merge requests found
// TODO: Separate actions // TODO: Separate actions
import ax from 'axios'; import ax from 'axios';
import { GET_USERDATA, PROFILE_CHANGE, GROUP_CHANGE, LOGOUT, GET_NEWS } from './types'; import { GET_USERDATA, PROFILE_CHANGE, GROUP_CHANGE, GET_NEWS } from './types';
const axios = ax.create({ const axios = ax.create({
xsrfCookieName: 'csrftoken', xsrfCookieName: 'csrftoken',
...@@ -12,12 +12,15 @@ export const getUserData = () => ( ...@@ -12,12 +12,15 @@ export const getUserData = () => (
async (dispatch) => { async (dispatch) => {
const user = await axios.get('/api/v1/profiles/me'); const user = await axios.get('/api/v1/profiles/me');
const { const {
id, join_date: joinDate, nick, motivation, signed, groups, id,
join_date: joinDate,
nick,
motivation_about: motivationAbout,
motivation_profession: motivationProfession,
motivation_exercise: motivationExercise,
signed,
groups,
} = user.data; } = user.data;
const motivationJSON = JSON.parse(motivation);
const motivationAbout = motivationJSON.first;
const motivationProfession = motivationJSON.second;
const motivationExercise = motivationJSON.third;
dispatch({ dispatch({
type: GET_USERDATA, type: GET_USERDATA,
payload: { payload: {
...@@ -55,7 +58,12 @@ export const submitRegistration = ({ ...@@ -55,7 +58,12 @@ export const submitRegistration = ({
}) => ( }) => (
async (dispatch) => { async (dispatch) => {
const response = await axios.patch(`/api/v1/profiles/${id}/`, { const response = await axios.patch(`/api/v1/profiles/${id}/`, {
nick, groups, signed, motivation: JSON.stringify({ first: motivationAbout, second: motivationProfession, third: motivationExercise }), nick,
groups,
signed,
motivation_about: motivationAbout,
motivation_profession: motivationProfession,
motivation_exercise: motivationExercise,
}); });
if (response.data.id === id) { if (response.data.id === id) {
alert('Sikeres mentés!'); alert('Sikeres mentés!');
......
...@@ -3,5 +3,3 @@ export const GET_NEWS = 'get_news'; ...@@ -3,5 +3,3 @@ export const GET_NEWS = 'get_news';
export const PROFILE_CHANGE = 'profile_change'; export const PROFILE_CHANGE = 'profile_change';
export const GROUP_CHANGE = 'group_change'; export const GROUP_CHANGE = 'group_change';
export const LOGOUT = 'logout';
...@@ -2,7 +2,6 @@ import { ...@@ -2,7 +2,6 @@ import {
GET_USERDATA, GET_USERDATA,
PROFILE_CHANGE, PROFILE_CHANGE,
GROUP_CHANGE, GROUP_CHANGE,
LOGOUT,
} from '../actions/types'; } from '../actions/types';
const INITIAL_STATE = { const INITIAL_STATE = {
...@@ -16,8 +15,6 @@ export default (state = INITIAL_STATE, action) => { ...@@ -16,8 +15,6 @@ export default (state = INITIAL_STATE, action) => {
return { ...state, [action.target]: action.payload }; return { ...state, [action.target]: action.payload };
case GROUP_CHANGE: case GROUP_CHANGE:
return { ...state, groups: action.payload }; return { ...state, groups: action.payload };
case LOGOUT:
return INITIAL_STATE;
default: default:
return state; return state;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment