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

Add accordion to schedule page, add default values to reducers

parent 6e717a4e
No related branches found
No related tags found
No related merge requests found
...@@ -138,8 +138,7 @@ class EventDetail extends Component { ...@@ -138,8 +138,7 @@ class EventDetail extends Component {
</Table.Row> </Table.Row>
</Table.Header> </Table.Header>
<Table.Body> <Table.Body>
{ this.props.trainees && { this.props.selectedEvent ?
this.props.selectedEvent ?
this.renderTrainees() this.renderTrainees()
: :
'' ''
......
import React, { Component } from 'react'; import React, { Component } from 'react';
import { Container, Header, Segment } from 'semantic-ui-react'; import { Container, Accordion, Icon } from 'semantic-ui-react';
import { connect } from 'react-redux';
import moment from 'moment';
import { getEvents } from '../../actions/statistics';
class Schedule extends Component {
state = { activeIndex: 0 }
componentWillMount() {
this.props.getEvents();
}
handleClick = (e, titleProps) => {
const { index } = titleProps
const { activeIndex } = this.state
const newIndex = activeIndex === index ? -1 : index
this.setState({ activeIndex: newIndex })
}
export default class Schedule extends Component {
render() { render() {
const { activeIndex } = this.state
const events = this.props.events;
const panels = events.map(event => (
<>
<Accordion.Title
active={activeIndex === event.id}
index={event.id}
onClick={this.handleClick}
>
<h2>
<Icon name='transgender' color='blue' />
{event.name} {moment(event.date).format('LLL')}
</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.
</p>
</Accordion.Content>
</>
));
return ( return (
<div> <Container
<Segment inverted textAlign='center' vertical> textAlign='center'
<Container> style={{
<Header padding: '60px'
as='h1' }}
content='Ütemterv - Hamarosan' >
inverted <h2>Képzés alkalmak:</h2>
style={{ <Accordion
fontSize: '3em', fluid
fontWeight: 'normal', styled
marginBottom: 0, defaultActiveIndex={-1}
marginTop: '0.5em', panels={panels}
}} >
/> {panels}
</Container> </Accordion>
</Segment> <h2>Tábor:</h2>
</div> </Container>
); );
} }
} }
const mapStateToProps = ({ events: { events }, user }) => ({ events, user });
export default connect(mapStateToProps, { getEvents })(Schedule);
...@@ -7,7 +7,7 @@ import { ...@@ -7,7 +7,7 @@ import {
DELETE_EVENT, DELETE_EVENT,
} from '../actions/types'; } from '../actions/types';
const INITIAL_STATE = { newEvent: {} }; const INITIAL_STATE = { events: [], newEvent: {} };
export default (state = INITIAL_STATE, action) => { export default (state = INITIAL_STATE, action) => {
switch (action.type) { switch (action.type) {
......
import { GET_TRAINEES, GET_TRAINEE_BY_ID } from '../actions/types'; import { GET_TRAINEES, GET_TRAINEE_BY_ID } from '../actions/types';
const INITIAL_STATE = {}; const INITIAL_STATE = { trainees: [], selectedTrainee: {}};
export default (state = INITIAL_STATE, action) => { export default (state = INITIAL_STATE, action) => {
switch (action.type) { switch (action.type) {
......
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