From 40daca15158fa2be9431a51648cad6a1085fb806 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Chif=20Gerg=C5=91?= <chifgeri97@gmail.com> Date: Mon, 21 Jan 2019 22:16:44 +0100 Subject: [PATCH] Staffs can add more staffs --- src/actions/statistics.js | 16 ++++++++++++++++ src/actions/types.js | 1 + src/components/pages/Applications.js | 16 +++++++++++++--- 3 files changed, 30 insertions(+), 3 deletions(-) diff --git a/src/actions/statistics.js b/src/actions/statistics.js index 5f715ae..7d546bc 100644 --- a/src/actions/statistics.js +++ b/src/actions/statistics.js @@ -9,6 +9,7 @@ import { DELETE_EVENT, GET_TRAINEE_BY_ID, GET_PROFILES, + SET_STAFF, } from './types'; export const getEvents = () => ( @@ -149,3 +150,18 @@ export const getProfiles = () => ( } } ); + +export const setStaffStatus = id => ( + async (dispatch) => { + try { + const response = await axios.patch(`/api/v1/profiles/${id}/`, { + signed: true, + role: 'Staff', + }); + if (response.data.id) { + } + } catch (e) { + console.log(e); + } + } +); diff --git a/src/actions/types.js b/src/actions/types.js index e3986ff..0147481 100644 --- a/src/actions/types.js +++ b/src/actions/types.js @@ -28,3 +28,4 @@ export const CLEAR_NOTE = 'clear_note'; export const ADD_EVENT_NOTE = 'add_note'; export const GET_PROFILES = 'get_profiles'; +export const SET_STAFF = 'set_staff'; diff --git a/src/components/pages/Applications.js b/src/components/pages/Applications.js index b6ae600..47b12b7 100644 --- a/src/components/pages/Applications.js +++ b/src/components/pages/Applications.js @@ -1,9 +1,9 @@ import React, { Component } from 'react'; import moment from 'moment'; import { Link } from 'react-router-dom'; -import { Container, Table, Icon } from 'semantic-ui-react'; +import { Container, Table, Icon, Button } from 'semantic-ui-react'; import { connect } from 'react-redux'; -import { getProfiles } from '../../actions/statistics'; +import { getProfiles, setStaffStatus } from '../../actions/statistics'; class Applications extends Component { componentWillMount() { @@ -29,6 +29,15 @@ class Applications extends Component { <Icon color='red' name='cancel' /> } </Table.Cell> + <Table.Cell> + <Button + onClick={() => this.props.setStaffStatus(profile.id)} + color='blue' + size='tiny' + > + ADD STAFF STATUS + </Button> + </Table.Cell> </Table.Row> ); }); @@ -47,6 +56,7 @@ class Applications extends Component { <Table.Row> <Table.HeaderCell>Jelentkezettek</Table.HeaderCell> <Table.HeaderCell>JelentkezĂŠs elfogadva:</Table.HeaderCell> + <Table.HeaderCell /> </Table.Row> </Table.Header> @@ -61,4 +71,4 @@ class Applications extends Component { const mapStateToProps = ({ trainees: { profiles }, user }) => ({ profiles, user }); -export default connect(mapStateToProps, { getProfiles })(Applications); +export default connect(mapStateToProps, { getProfiles, setStaffStatus })(Applications); -- GitLab