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

Resolve merge conflict in Trainee Reducer

parents cd8e6994 7fe4859b
No related branches found
No related tags found
No related merge requests found
......@@ -26,6 +26,20 @@ export const getStaffEvents = () => (
}
);
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 {
......@@ -86,7 +100,7 @@ export const eventDate = (name, value) => (
export const addEvent = ({ name, date }) => (
async (dispatch) => {
try {
const response = await axios.post('/api/v1/events/', {
const response = await axios.post('/api/v1/staff_events/', {
name,
date,
});
......@@ -108,7 +122,7 @@ export const addEvent = ({ name, date }) => (
export const deleteEvent = event => (
async (dispatch) => {
try {
const response = await axios.delete(`/api/v1/events/${event.id}/`);
const response = await axios.delete(`/api/v1/staff_events/${event.id}/`);
if (!response.data.id) {
alert('Sikeres törlés!');
dispatch({
......
......@@ -138,8 +138,7 @@ class EventDetail extends Component {
</Table.Row>
</Table.Header>
<Table.Body>
{ this.props.trainees &&
this.props.selectedEvent ?
{ this.props.selectedEvent ?
this.renderTrainees()
:
''
......
import React, { Component } from 'react';
import { Container, Header, Segment } from 'semantic-ui-react';
import { Container, Accordion, Icon, Grid } from 'semantic-ui-react';
import { connect } from 'react-redux';
import moment from 'moment';
import { getStudentEvents } from '../../actions/statistics';
class Schedule extends Component {
state = { activeIndex: 0 }
componentWillMount() {
this.props.getStudentEvents();
}
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() {
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>
<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).locale('hu').format('LLLL')}
</Grid.Column>
</Grid>
</h2>
</Accordion.Title>
<Accordion.Content active={activeIndex === event.id}>
<p>
{event.description}
</p>
</Accordion.Content>
</>
));
return (
<div>
<Segment inverted textAlign='center' vertical>
<Container>
<Header
as='h1'
content='Ütemterv - Hamarosan'
inverted
style={{
fontSize: '3em',
fontWeight: 'normal',
marginBottom: 0,
marginTop: '0.5em',
}}
/>
</Container>
</Segment>
</div>
<Container
textAlign='center'
style={{
padding: '60px'
}}
>
<h2>Képzés alkalmak:</h2>
<Accordion
fluid
styled
defaultActiveIndex={-1}
panels={panels}
>
{panels}
</Accordion>
<h2>Tábor:</h2>
</Container>
);
}
}
const mapStateToProps = ({ events: { events }, user }) => ({ events, user });
export default connect(mapStateToProps, { getStudentEvents })(Schedule);
......@@ -7,7 +7,7 @@ import {
DELETE_EVENT,
} from '../actions/types';
const INITIAL_STATE = { newEvent: {} };
const INITIAL_STATE = { events: [], newEvent: {} };
export default (state = INITIAL_STATE, action) => {
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