From 79fc439508f2b98373702a21ea34fb4ac9e7f098 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Chif=20Gerg=C5=91?= <chifgeri97@gmail.com> Date: Fri, 25 Jan 2019 21:34:59 +0100 Subject: [PATCH] Use buttons instead of checkbox, get students not all profile in statistics --- src/actions/statistics.js | 7 ++++--- src/components/pages/TraineeTableRow.js | 22 +++++++++++++++++----- src/components/pages/Trainees.js | 6 +++++- 3 files changed, 26 insertions(+), 9 deletions(-) diff --git a/src/actions/statistics.js b/src/actions/statistics.js index ce574c2..24dae9f 100644 --- a/src/actions/statistics.js +++ b/src/actions/statistics.js @@ -59,7 +59,7 @@ export const getEventById = id => ( export const getTrainees = () => ( async (dispatch) => { try { - const response = await axios.get('/api/v1/profiles/'); + const response = await axios.get('/api/v1/profiles/', { params: { role: 'Student' } }); dispatch({ type: GET_TRAINEES, payload: response.data, @@ -82,11 +82,12 @@ export const visitorChange = ({ id, value }) => { } }; -export const submitVisitors = ({ id, visitors }) => ( +export const submitVisitors = ({ id, visitors, absent }) => ( async () => { try { const response = await axios.patch(`/api/v1/staff_events/${id}/`, { - visitors + visitors, + absent, }); } catch (e) { console.log(e); diff --git a/src/components/pages/TraineeTableRow.js b/src/components/pages/TraineeTableRow.js index 3a9ae4f..d7276eb 100644 --- a/src/components/pages/TraineeTableRow.js +++ b/src/components/pages/TraineeTableRow.js @@ -64,11 +64,23 @@ class TraineeTableRow extends Component { </Table.Cell> : <Table.Cell textAlign='center'> - <Dropdown - defaultValue={isVisitor ? 'Visitor' : isAbsent ? 'Absent' : 'No'} - selection - options={visitStates} - onChange={(_, v) => this.props.visitorChange({ id : trainee.id, value: v.value })} + <Button + compact + icon={<Icon color='green' name='checkmark' />} + color={isVisitor ? 'blue' : 'lightgrey'} + onClick={() => this.props.visitorChange({ id : trainee.id, value: 'Visitor' })} + /> + <Button + compact + icon={<Icon color='orange' name='minus' />} + color={isAbsent ? 'blue' : 'lightgrey'} + onClick={() => this.props.visitorChange({ id : trainee.id, value: 'Absent' })} + /> + <Button + compact + icon={<Icon color='red' name='cancel' />} + color={!isVisitor && !isAbsent ? 'blue' : 'lightgrey'} + onClick={() => this.props.visitorChange({ id : trainee.id, value: 'No' })} /> </Table.Cell> } diff --git a/src/components/pages/Trainees.js b/src/components/pages/Trainees.js index 804c801..e49cc33 100644 --- a/src/components/pages/Trainees.js +++ b/src/components/pages/Trainees.js @@ -19,7 +19,11 @@ class Trainees extends Component { } return ( <Table.Cell textAlign='center'> - <Icon color='red' name='cancel' /> + { event.absent.includes(trainee.id) ? + <Icon color='orange' name='minus' /> + : + <Icon color='red' name='cancel' /> + } </Table.Cell>); })); } -- GitLab