|
@@ -2,50 +2,28 @@ import React from 'react';
|
|
|
import { connect } from "react-redux";
|
|
|
|
|
|
import { getAllReviews, postReviewSubmit } from "../../actions/reviews";
|
|
|
+import { getAllEvents } from "../../actions/getAllEvents";
|
|
|
|
|
|
import './reviews.scss';
|
|
|
|
|
|
import Sidebar from '../../components/sidebar/Sidebar';
|
|
|
import Footer from '../../components/footer/Footer';
|
|
|
import ReviewForm from '../../components/review-form/ReviewForm';
|
|
|
-
|
|
|
-const reviewsInitial = [
|
|
|
- {
|
|
|
- name: "Unknown Raccoon",
|
|
|
- date: new Date("07-10-2019").toDateString().slice(4),
|
|
|
- text: "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."
|
|
|
- },
|
|
|
- {
|
|
|
- name: "Htoto Echo",
|
|
|
- date: new Date("07-29-2019").toDateString().slice(4),
|
|
|
- text: "Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat."
|
|
|
- },
|
|
|
- {
|
|
|
- name: "Vasya Petrovich",
|
|
|
- date: new Date("08-06-2019").toDateString().slice(4),
|
|
|
- text: "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."
|
|
|
- },
|
|
|
- {
|
|
|
- name: "Petya Petrov",
|
|
|
- date: new Date("08-07-2019").toDateString().slice(4),
|
|
|
- text: "Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat."
|
|
|
- },
|
|
|
- {
|
|
|
- name: "Tanya Sash",
|
|
|
- date: new Date("08-08-2019").toDateString().slice(4),
|
|
|
- text: "Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat."
|
|
|
- }
|
|
|
-]
|
|
|
+//import FiltersEvents from '../../components/filtersEvents/FiltersEvents';
|
|
|
|
|
|
export class Reviews extends React.Component {
|
|
|
componentDidMount() {
|
|
|
- this.props.getAllReviews()
|
|
|
+ this.props.getAllReviews();
|
|
|
+ this.props.getAllEvents();
|
|
|
}
|
|
|
|
|
|
render() {
|
|
|
- const { postReviewSubmit } = this.props;
|
|
|
- //const { reviews, postReviewSubmit } = this.props;
|
|
|
- //console.log(reviews);
|
|
|
+ const { postReviewSubmit, events, reviews } = this.props;
|
|
|
+ const eventsArr = events.map(event => ({
|
|
|
+ title: event.title,
|
|
|
+ id: event._id
|
|
|
+ }));
|
|
|
+ //console.log(Array.from(reviews).reverse());
|
|
|
return (
|
|
|
<>
|
|
|
<Sidebar/>
|
|
@@ -55,15 +33,21 @@ export class Reviews extends React.Component {
|
|
|
</div>
|
|
|
</div>
|
|
|
<div className="container-wrap">
|
|
|
+
|
|
|
+ {/*<div className="events-filters">
|
|
|
+ <h4>Events filter</h4>
|
|
|
+ <FiltersEvents labelType="Event Title" getRequest={getAllEvents} eventTypes={eventTypes} />
|
|
|
+ </div>*/}
|
|
|
+
|
|
|
<div className="reviews-wrap">
|
|
|
{
|
|
|
- reviewsInitial.reverse().map((reviewer, ind) => ind < 10 &&
|
|
|
+ Array.from(reviews).reverse().map((reviewer, ind) => ind < 10 &&
|
|
|
<div className="reviews-item" key={ind}>
|
|
|
- <div className="review-content">
|
|
|
+ <div className="review-content">
|
|
|
<div className="reviews-name">{reviewer.name}</div>
|
|
|
<div className="reviews-date">
|
|
|
<i className="fa fa-calendar-o" aria-hidden="true"></i>
|
|
|
- {reviewer.date}
|
|
|
+ { new Date(reviewer.date).toDateString().slice(4) }
|
|
|
</div>
|
|
|
<div className="reviews-text">{reviewer.text}</div>
|
|
|
</div>
|
|
@@ -73,7 +57,7 @@ export class Reviews extends React.Component {
|
|
|
</div>
|
|
|
<div className="reviews-wrap-add">
|
|
|
<h3>Send your reviews</h3>
|
|
|
- <ReviewForm postReviewSubmit={postReviewSubmit}/>
|
|
|
+ <ReviewForm postReviewSubmit={postReviewSubmit} eventsArr={eventsArr}/>
|
|
|
</div>
|
|
|
</div>
|
|
|
<Footer/>
|
|
@@ -84,11 +68,13 @@ export class Reviews extends React.Component {
|
|
|
|
|
|
const mapStateToProps = state => {
|
|
|
return {
|
|
|
- reviews: state.allReviews.reviews
|
|
|
+ reviews: state.allReviews.reviews,
|
|
|
+ events: state.getEvents.events,
|
|
|
+ reloadPage: state.allReviews.reloadPage
|
|
|
};
|
|
|
};
|
|
|
|
|
|
export default connect(
|
|
|
mapStateToProps,
|
|
|
- { getAllReviews, postReviewSubmit }
|
|
|
+ { getAllReviews, postReviewSubmit, getAllEvents }
|
|
|
)(Reviews);
|