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

Add action to get all profile, display who was accepted

parent 2b20f4fb
No related branches found
No related tags found
No related merge requests found
...@@ -8,6 +8,7 @@ import { ...@@ -8,6 +8,7 @@ import {
ADD_EVENT, ADD_EVENT,
DELETE_EVENT, DELETE_EVENT,
GET_TRAINEE_BY_ID, GET_TRAINEE_BY_ID,
GET_PROFILES,
} from './types'; } from './types';
export const getEvents = () => ( export const getEvents = () => (
...@@ -134,3 +135,17 @@ export const deleteEvent = event => ( ...@@ -134,3 +135,17 @@ export const deleteEvent = event => (
console.log(e); console.log(e);
} }
}); });
export const getProfiles = () => (
async (dispatch) => {
try {
const response = await axios.get('/api/v1/profiles/');
dispatch({
type: GET_PROFILES,
payload: response.data,
});
} catch (e) {
console.log(e);
}
}
);
...@@ -26,3 +26,5 @@ export const DELETE_EVENT = 'delete_event'; ...@@ -26,3 +26,5 @@ export const DELETE_EVENT = 'delete_event';
export const WRITE_NOTE = 'write_note'; export const WRITE_NOTE = 'write_note';
export const CLEAR_NOTE = 'clear_note'; 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';
import React, { Component } from 'react'; import React, { Component } from 'react';
import moment from 'moment'; import moment from 'moment';
import { Link } from 'react-router-dom'; import { Link } from 'react-router-dom';
import { Container, Table, Button } from 'semantic-ui-react'; import { Container, Table, Icon } from 'semantic-ui-react';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { getTrainees } from '../../actions/statistics'; import { getProfiles } from '../../actions/statistics';
class Applications extends Component { class Applications extends Component {
componentWillMount() { componentWillMount() {
this.props.getTrainees(); this.props.getProfiles();
} }
renderApplicants() { renderApplicants() {
return this.props.trainees.map((trainee) => return this.props.profiles.map((profile) =>
{ return ( { return (
<Table.Row> <Table.Row>
<Table.Cell> <Table.Cell>
<Link to={`trainee/${trainee.id}`}> <Link to={`profile/${profile.id}`}>
{trainee.full_name} {profile.full_name}
</Link> </Link>
</Table.Cell> </Table.Cell>
<Table.Cell> <Table.Cell textAlign='center'>
{ profile.role === 'Student' ?
<Icon color='green' name='checkmark' />
:
profile.role === 'Staff' ?
<strong>Staff</strong>
:
<Icon color='red' name='cancel' />
}
</Table.Cell> </Table.Cell>
</Table.Row> </Table.Row>
); );
...@@ -43,7 +51,7 @@ class Applications extends Component { ...@@ -43,7 +51,7 @@ class Applications extends Component {
</Table.Header> </Table.Header>
<Table.Body> <Table.Body>
{this.props.trainees ? this.renderApplicants() : 'Nincs még alaklom beírva'} {this.renderApplicants()}
</Table.Body> </Table.Body>
</Table> </Table>
</Container> </Container>
...@@ -51,6 +59,6 @@ class Applications extends Component { ...@@ -51,6 +59,6 @@ class Applications extends Component {
} }
} }
const mapStateToProps = ({ trainees: { trainees }, user }) => ({ trainees, user }); const mapStateToProps = ({ trainees: { profiles }, user }) => ({ profiles, user });
export default connect(mapStateToProps, { getTrainees })(Applications); export default connect(mapStateToProps, { getProfiles })(Applications);
import { GET_TRAINEES, GET_TRAINEE_BY_ID } from '../actions/types'; import { GET_TRAINEES, GET_TRAINEE_BY_ID, GET_PROFILES } from '../actions/types';
const INITIAL_STATE = {}; const INITIAL_STATE = { profiles: [] };
export default (state = INITIAL_STATE, action) => { export default (state = INITIAL_STATE, action) => {
switch (action.type) { switch (action.type) {
...@@ -8,6 +8,8 @@ export default (state = INITIAL_STATE, action) => { ...@@ -8,6 +8,8 @@ export default (state = INITIAL_STATE, action) => {
return { ...state, trainees: [...action.payload] }; return { ...state, trainees: [...action.payload] };
case GET_TRAINEE_BY_ID: case GET_TRAINEE_BY_ID:
return { ...state, selectedTrainee: action.payload }; return { ...state, selectedTrainee: action.payload };
case GET_PROFILES:
return { ...state, profiles: [...action.payload] };
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