From 33e0fc06d9445653377f7844e187a489da1ca576 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Chif=20Gerg=C5=91?= <chifgeri97@gmail.com> Date: Wed, 23 Jan 2019 11:56:40 +0100 Subject: [PATCH] Get student events in the Schedule page, align the event name and date --- src/actions/statistics.js | 14 ++++++++++++++ src/components/pages/Schedule.js | 21 +++++++++++++-------- 2 files changed, 27 insertions(+), 8 deletions(-) diff --git a/src/actions/statistics.js b/src/actions/statistics.js index 591057d..72581c7 100644 --- a/src/actions/statistics.js +++ b/src/actions/statistics.js @@ -24,6 +24,20 @@ export const getEvents = () => ( } ); +export const getStudentEvents = () => ( + async (dispatch) => { + try { + const response = await axios.get('/api/v1/student_events/'); + dispatch({ + type: GET_EVENTS, + payload: response.data, + }); + } catch (e) { + console.log(e); + } + } +); + export const getEventById = id => ( async (dispatch) => { try { diff --git a/src/components/pages/Schedule.js b/src/components/pages/Schedule.js index 971e0c9..098dd09 100644 --- a/src/components/pages/Schedule.js +++ b/src/components/pages/Schedule.js @@ -1,14 +1,14 @@ import React, { Component } from 'react'; -import { Container, Accordion, Icon } from 'semantic-ui-react'; +import { Container, Accordion, Icon, Grid } from 'semantic-ui-react'; import { connect } from 'react-redux'; import moment from 'moment'; -import { getEvents } from '../../actions/statistics'; +import { getStudentEvents } from '../../actions/statistics'; class Schedule extends Component { state = { activeIndex: 0 } componentWillMount() { - this.props.getEvents(); + this.props.getStudentEvents(); } handleClick = (e, titleProps) => { @@ -31,14 +31,19 @@ class Schedule extends Component { onClick={this.handleClick} > <h2> - <Icon name='transgender' color='blue' /> - {event.name} {moment(event.date).format('LLL')} + <Grid> + <Grid.Column floated='left' width={5} textAlign='left'> + <Icon name='quidditch' color='blue' />{event.name} + </Grid.Column> + <Grid.Column floated='right' width={8} textAlign='right'> + {moment(event.date).format('LLL')} + </Grid.Column> + </Grid> </h2> </Accordion.Title> <Accordion.Content active={activeIndex === event.id}> <p> - A dog is a type of domesticated animal. Known for its loyalty and faithfulness, it can - be found as a welcome guest in many households across the world. + {event.description} </p> </Accordion.Content> </> @@ -69,4 +74,4 @@ class Schedule extends Component { const mapStateToProps = ({ events: { events }, user }) => ({ events, user }); -export default connect(mapStateToProps, { getEvents })(Schedule); +export default connect(mapStateToProps, { getStudentEvents })(Schedule); -- GitLab