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 = () => ( ...@@ -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 => ( export const getEventById = id => (
async (dispatch) => { async (dispatch) => {
try { try {
...@@ -86,7 +100,7 @@ export const eventDate = (name, value) => ( ...@@ -86,7 +100,7 @@ export const eventDate = (name, value) => (
export const addEvent = ({ name, date }) => ( export const addEvent = ({ name, date }) => (
async (dispatch) => { async (dispatch) => {
try { try {
const response = await axios.post('/api/v1/events/', { const response = await axios.post('/api/v1/staff_events/', {
name, name,
date, date,
}); });
...@@ -108,7 +122,7 @@ export const addEvent = ({ name, date }) => ( ...@@ -108,7 +122,7 @@ export const addEvent = ({ name, date }) => (
export const deleteEvent = event => ( export const deleteEvent = event => (
async (dispatch) => { async (dispatch) => {
try { 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) { if (!response.data.id) {
alert('Sikeres törlés!'); alert('Sikeres törlés!');
dispatch({ dispatch({
......
...@@ -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, 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() { 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 ( 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, { getStudentEvents })(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) {
......
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