diff --git a/src/actions/auth.js b/src/actions/auth.js index c831784601ee443516825cedc9eb14db12de2e35..111210ac3d8de62ef7b5c201cf90e6ee389327ca 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 f6891993f91473e63639fbcf6456ea863cdec3be..1e9da26b22120e378854d0578be9fe10a773ca93 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 607f6dca0c0b9c4bfc67cdd7bf5d4b25c0e3ef0e..839a47eb435192c9bbac2d2f7a23c134a3bcaed6 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; }