|
@@ -2,6 +2,8 @@ import React from 'react'
|
|
|
import { Switch, Route } from "react-router-dom";
|
|
|
import { connect } from "react-redux";
|
|
|
|
|
|
+import { getAllEvents } from "./actions/getAllEvents";
|
|
|
+
|
|
|
import AdminMainPage from './conteiners/adminMainPage/adminMainPage';
|
|
|
import AdminAddEventPage from './conteiners/adminAddEventPage/adminAddEventPage';
|
|
|
import AdminMyEventsPage from './conteiners/adminMyEventsPage/adminMyEventsPage';
|
|
@@ -18,22 +20,32 @@ import EventCard from './conteiners/eventCard/EventCard';
|
|
|
import AdminAddPhotogalarytPage from "./conteiners/adminPhotogalaryPage/adminPhotogalaryPage"
|
|
|
|
|
|
export class Router extends React.Component {
|
|
|
+ componentDidMount() {
|
|
|
+ this.props.getAllEvents();
|
|
|
+ }
|
|
|
+
|
|
|
render() {
|
|
|
const { events } = this.props;
|
|
|
return(
|
|
|
<div className="container">
|
|
|
<Switch>
|
|
|
<Route exact path="/" component={Home} />
|
|
|
- <Route exact path="/events" component={Events} />
|
|
|
+
|
|
|
+ <Route exact path="/events" render={ props => (
|
|
|
+ <Events events={events} />
|
|
|
+ )} />
|
|
|
+
|
|
|
<Route exact path="/result" component={Result} />
|
|
|
<Route exact path="/gallery" component={Gallery} />
|
|
|
<Route exact path="/reviews" component={Reviews} />
|
|
|
|
|
|
{
|
|
|
events.map(event =>
|
|
|
- <Route exact path={`/events/${event._id}`} key={event._id} render={ props => (
|
|
|
- <EventCard event={event}/>
|
|
|
- )} />
|
|
|
+ <Route exact
|
|
|
+ path={`/events/${event._id}`}
|
|
|
+ key={event._id}
|
|
|
+ render={ props => (<EventCard event={event} />) }
|
|
|
+ />
|
|
|
)
|
|
|
}
|
|
|
|
|
@@ -59,5 +71,6 @@ const mapStateToProps = state => {
|
|
|
};
|
|
|
|
|
|
export default connect(
|
|
|
- mapStateToProps
|
|
|
+ mapStateToProps,
|
|
|
+ { getAllEvents }
|
|
|
)(Router);
|