From 9893786a40639c9a111c145061d443e1b9206fc3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Tam=C3=A1s=20Szab=C3=B3?= <tamas@szaboo.com>
Date: Mon, 5 Feb 2018 20:12:34 +0100
Subject: [PATCH] motivation with three questions

---
 src/actions/auth.js         | 22 +++++++++++++++-------
 src/actions/types.js        |  2 --
 src/reducers/UserReducer.js |  3 ---
 3 files changed, 15 insertions(+), 12 deletions(-)

diff --git a/src/actions/auth.js b/src/actions/auth.js
index c831784..111210a 100644
--- a/src/actions/auth.js
+++ b/src/actions/auth.js
@@ -1,7 +1,7 @@
 // TODO: Separate actions
 
 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({
   xsrfCookieName: 'csrftoken',
@@ -12,12 +12,15 @@ export const getUserData = () => (
   async (dispatch) => {
     const user = await axios.get('/api/v1/profiles/me');
     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;
-    const motivationJSON = JSON.parse(motivation);
-    const motivationAbout = motivationJSON.first;
-    const motivationProfession = motivationJSON.second;
-    const motivationExercise = motivationJSON.third;
     dispatch({
       type: GET_USERDATA,
       payload: {
@@ -55,7 +58,12 @@ export const submitRegistration = ({
 }) => (
   async (dispatch) => {
     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) {
       alert('Sikeres mentĂŠs!');
diff --git a/src/actions/types.js b/src/actions/types.js
index f689199..1e9da26 100644
--- a/src/actions/types.js
+++ b/src/actions/types.js
@@ -3,5 +3,3 @@ export const GET_NEWS = 'get_news';
 
 export const PROFILE_CHANGE = 'profile_change';
 export const GROUP_CHANGE = 'group_change';
-
-export const LOGOUT = 'logout';
diff --git a/src/reducers/UserReducer.js b/src/reducers/UserReducer.js
index 607f6dc..839a47e 100644
--- a/src/reducers/UserReducer.js
+++ b/src/reducers/UserReducer.js
@@ -2,7 +2,6 @@ import {
   GET_USERDATA,
   PROFILE_CHANGE,
   GROUP_CHANGE,
-  LOGOUT,
 } from '../actions/types';
 
 const INITIAL_STATE = {
@@ -16,8 +15,6 @@ export default (state = INITIAL_STATE, action) => {
       return { ...state, [action.target]: action.payload };
     case GROUP_CHANGE:
       return { ...state, groups: action.payload };
-    case LOGOUT:
-      return INITIAL_STATE;
     default:
       return state;
   }
-- 
GitLab