Skip to content
Snippets Groups Projects
Commit 330fa3b4 authored by Chif Gergő's avatar Chif Gergő
Browse files

Handle status change in trainee reducer

parent f8eb8179
No related branches found
No related tags found
No related merge requests found
...@@ -8,7 +8,8 @@ import { ...@@ -8,7 +8,8 @@ import {
ADD_EVENT, ADD_EVENT,
DELETE_EVENT, DELETE_EVENT,
GET_PROFILES, GET_PROFILES,
GET_SELECTED_PROFILE GET_SELECTED_PROFILE,
SET_STATUS,
} from './types'; } from './types';
export const getEvents = () => ( export const getEvents = () => (
...@@ -143,6 +144,10 @@ export const setStatus = (id, status) => ( ...@@ -143,6 +144,10 @@ export const setStatus = (id, status) => (
role: status, role: status,
}); });
if (response.data.id) { if (response.data.id) {
dispatch({
type: SET_STATUS,
payload: response.data,
});
} }
} catch (e) { } catch (e) {
console.log(e); console.log(e);
......
...@@ -27,5 +27,5 @@ export const CLEAR_NOTE = 'clear_note'; ...@@ -27,5 +27,5 @@ export const CLEAR_NOTE = 'clear_note';
export const ADD_EVENT_NOTE = 'add_note'; export const ADD_EVENT_NOTE = 'add_note';
export const GET_PROFILES = 'get_profiles'; export const GET_PROFILES = 'get_profiles';
export const SET_STAFF = 'set_staff'; export const SET_STATUS = 'set_status';
export const GET_SELECTED_PROFILE = 'get_selected_profile'; export const GET_SELECTED_PROFILE = 'get_selected_profile';
...@@ -72,7 +72,7 @@ class Applications extends Component { ...@@ -72,7 +72,7 @@ class Applications extends Component {
<Table.Header> <Table.Header>
<Table.Row> <Table.Row>
<Table.HeaderCell>Jelentkezettek</Table.HeaderCell> <Table.HeaderCell>Jelentkezettek</Table.HeaderCell>
<Table.HeaderCell>Jelentkezés elfogadva:</Table.HeaderCell> <Table.HeaderCell textAlign='center'>Jelentkezés státusza:</Table.HeaderCell>
<Table.HeaderCell /> <Table.HeaderCell />
</Table.Row> </Table.Row>
</Table.Header> </Table.Header>
......
import { GET_TRAINEES, GET_PROFILES, GET_SELECTED_PROFILE } from '../actions/types'; import { GET_TRAINEES, GET_PROFILES, GET_SELECTED_PROFILE, SET_STATUS } from '../actions/types';
const INITIAL_STATE = { profiles: [], selectedProfile: {} }; const INITIAL_STATE = { profiles: [], selectedProfile: {} };
...@@ -10,6 +10,13 @@ export default (state = INITIAL_STATE, action) => { ...@@ -10,6 +10,13 @@ export default (state = INITIAL_STATE, action) => {
return { ...state, profiles: [...action.payload] }; return { ...state, profiles: [...action.payload] };
case GET_SELECTED_PROFILE: case GET_SELECTED_PROFILE:
return { ...state, selectedProfile: action.payload }; return { ...state, selectedProfile: action.payload };
case SET_STATUS:
const index = state.profiles.findIndex(item => item.id === action.payload.id);
state.profiles.splice(index, 1, action.payload);
if (action.payload.id === state.selectedProfile.id) {
return { ...state, selectedProfile: action.payload };
}
return { ...state, profiles: [...state.profiles] }
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