2 コミット 3bb1e64b74 ... 50784bf19c

作者 SHA1 メッセージ 日付
  Tanya Sashyna 50784bf19c the profile page is finished 5 年 前
  Tanya Sashyna 8766f08b4a added filter on the gallery page 5 年 前

+ 2 - 2
src/actions/photogalaryActions.js

@@ -44,10 +44,10 @@ const getPhotogalaryRequestFail = payload => ({
 	payload
 });
 
-export const getPhotogalary = () => dispatch => {
+export const getPhotogalary = (title = 'All events') => dispatch => {
 	dispatch(getPhotogalaryRequest());
 	return axios
-		.get(photogalaryURL)
+		.get(title !== 'All events' ? `${photogalaryURL}/?eventTitle=${title}` : photogalaryURL)
 		.then(res => dispatch(getPhotogalaryRequestSuccess(res)))
 		.catch(err => dispatch(getPhotogalaryRequestFail(err)));
 };

+ 1 - 1
src/components/eventInfoShort/EventInfoShort.js

@@ -6,7 +6,7 @@ import './eventInfoShort.scss';
 export class EventInfoShort extends React.Component {
     render() {
         const { title, country, city, eventDate, imgSrc, id } = this.props;
-        const dateArr = new Date(eventDate).toDateString().split(' ');
+        const dateArr = new Date(eventDate).toDateString().split(' '); //date
         return (
             <div className="event-item">
                 <Link to={`/events/${id}`}>

+ 1 - 1
src/components/filtersEvents/FiltersEvents.js

@@ -9,7 +9,6 @@ let FiltersEvents = props => {
     const { handleSubmit, getRequest, eventTypes, labelType } = props;
 
     const submit = value => {
-        //console.log(value);
         getRequest(value.eventType);
     };
 
@@ -17,6 +16,7 @@ let FiltersEvents = props => {
         <form className="form-filter" onSubmit={handleSubmit(submit)}>
             <div>
                 <Field name="eventType" label={labelType} component={customSelect}>
+                    <option value="All events">All events</option>
                     {eventTypes.map( (elem,ind) => <option key={ind} value={elem}>{elem}</option>)}
                 </Field>
             </div>

+ 1 - 2
src/components/filtersReviews/filtersReviews.js

@@ -9,7 +9,6 @@ let FiltersReviews = props => {
     const { handleSubmit, getRequest, eventTypes, labelType } = props;
 
     const submit = value => {
-        //console.log(value);
         getRequest(value.eventType);
     };
 
@@ -17,7 +16,7 @@ let FiltersReviews = props => {
         <form className="form-filter" onSubmit={handleSubmit(submit)}>
             <div>
                 <Field name="eventType" label={labelType} component={customSelect}>
-                    <option>All events</option>
+                    <option value="All events">All events</option>
                     {eventTypes.map( elem => <option key={elem.id} value={elem.id}>{elem.title}</option>)}
                 </Field>
             </div>

+ 0 - 2
src/components/login-form/LoginForm.js

@@ -1,8 +1,6 @@
 import React from 'react'
 import { Field, reduxForm } from 'redux-form';
 
-import './login.scss';
-
 import { customInput } from "../customFields/customInput/customInput";
 import { validationForms } from "../../utils/validationForms";
 

+ 0 - 1
src/components/login-form/login.scss

@@ -1 +0,0 @@
-@import "../../styles/variables";

+ 0 - 3
src/components/reg-form-event/RegFormEvent.js

@@ -1,8 +1,6 @@
 import React from 'react'
 import { Field, reduxForm } from 'redux-form';
 
-import './reg-form-event.scss';
-
 import { customSelect } from "../customFields/customSelect/customSelect";
 import { customInput } from "../customFields/customInput/customInput";
 import { validationForms } from "../../utils/validationForms";
@@ -13,7 +11,6 @@ let RegFormEvent = props => {
 
     const submit = value => {
         value.event = eventId;
-        //console.log('user-event', value);
         regEventSubmit(value);
         reset();
     };

+ 0 - 1
src/components/reg-form-event/reg-form-event.scss

@@ -1 +0,0 @@
-@import "../../styles/variables";

+ 0 - 4
src/components/registration-form/RegistrationForm.js

@@ -1,8 +1,6 @@
 import React from 'react'
 import { Field, reduxForm } from 'redux-form';
 
-import './registrationForm.scss';
-
 import { customInput } from "../customFields/customInput/customInput";
 import { validationForms } from "../../utils/validationForms";
 
@@ -10,10 +8,8 @@ let RegistrationForm = props => {
     const { handleSubmit, postCheckInSubmit, message } = props;
 
     const submit = value => {
-        //console.log(value);
         postCheckInSubmit(value);
         if(message !== 'User was successfully register'){
-            //console.log(message);
             props.history.push('/login');
         }
     };

+ 0 - 1
src/components/registration-form/registrationForm.scss

@@ -1 +0,0 @@
-@import "../../styles/variables";

+ 0 - 4
src/components/review-form/ReviewForm.js

@@ -1,8 +1,6 @@
 import React from 'react'
 import { Field, reduxForm } from 'redux-form';
 
-import './review-form.scss';
-
 import { customInput } from "../customFields/customInput/customInput";
 import { customTextarea } from "../customFields/customTextarea/customTextarea";
 import { customSelect } from "../customFields/customSelect/customSelect";
@@ -10,11 +8,9 @@ import { validationForms } from "../../utils/validationForms";
 
 let ReviewForm = props => {
     const { handleSubmit, postReviewSubmit, eventsArr, reset } = props;
-    //console.log(props);
 
     const submit = value => {
         value.date = new Date();
-        //console.log(value);
         postReviewSubmit(value);
         reset()
     };

+ 0 - 1
src/components/review-form/review-form.scss

@@ -1 +0,0 @@
-@import "../../styles/variables";

+ 2 - 2
src/components/sidebar/Sidebar.js

@@ -19,8 +19,8 @@ const siteMenu = [
         id: 1
     },
     {
-        text: 'Result',
-        href: '/result',
+        text: 'Results',
+        href: '/results',
         id: 2
     },
     {

+ 1 - 13
src/conteiners/eventCard/EventCard.js

@@ -17,8 +17,7 @@ export class EventCard extends React.Component {
 
     render() {
         const { event, regEventSubmit } = this.props;
-        const dateArr = new Date(event.eventDate).toDateString().split(' ');
-        //console.log(event);
+        const dateArr = new Date(event.eventDate).toDateString().split(' ');//date
         return (
             <>
                 <Sidebar />
@@ -60,21 +59,10 @@ export class EventCard extends React.Component {
                                 <div className="overview">
                                     <img src={event.mainBannerPicture} alt="banner" />
                                     <p>{event.overview}</p>
-                                    {/*{
-                                        event.contentVideo && <div className="event-video">
-                                            <video controls loop>
-                                                <source src={video} type="video/mp4" />
-                                                <source src={video} type="video/ogg" />
-                                                <source src={video} type="video/webm" />
-                                                Your browser does not support the video tag.
-                                            </video>
-                                        </div>
-                                    }*/}
                                 </div>
                                 
                                 {
                                     event.map && <div className="map-wrap">
-                                        {/*click open pop-up with map*/}
                                         <img src={event.map.toString()} alt="banner" />
                                     </div>
                                 }

+ 1 - 2
src/conteiners/events/Events.js

@@ -17,8 +17,7 @@ export class Events extends React.Component {
 
     render() {
         const { events, getAllEvents } = this.props;
-        const eventTypes = ['All events', 'Marathon', 'Triathlon', 'Cycling'];
-        //console.log(events);
+        const eventTypes = ['Marathon', 'Triathlon', 'Cycling'];
         return (
             <>
                 <Sidebar />

+ 16 - 7
src/conteiners/gallery/Gallery.js

@@ -2,20 +2,22 @@ import React from 'react';
 import { connect } from "react-redux";
 
 import { getPhotogalary } from "../../actions/photogalaryActions";
+import { getAllEvents } from "../../actions/getAllEvents";
 
 import './gallery.scss';
 
 import Sidebar from '../../components/sidebar/Sidebar';
 import Footer from '../../components/footer/Footer';
+import FiltersEvents from '../../components/filtersEvents/FiltersEvents';
 
 class Gallery extends React.Component {
     componentDidMount() {
-        this.props.getPhotogalary()
+        this.props.getPhotogalary();
+        this.props.getAllEvents();
     }
 
     render() {
-        const { gallery } = this.props;
-        //console.log('gallery', this.props.gallery);
+        const { gallery, eventsArrTitles, getPhotogalary } = this.props;
         return (
             <>
                 <Sidebar/>
@@ -25,9 +27,15 @@ class Gallery extends React.Component {
                     </div>
                 </div>
                 <div className="container-wrap">
+
+                    <div className="events-filters">
+                        <h4>Gallery filter</h4>
+                        <FiltersEvents labelType="Event Title" getRequest={getPhotogalary} eventTypes={eventsArrTitles} />
+                    </div>
+
                     <div className="gallery-wrap">
                         {
-                            gallery.map((item,ind) => 
+                            gallery.length !== 0 ? gallery.map((item,ind) => 
                                 <div className="gallery-item" key={ind}>
                                     <h3>{item.eventTitle}</h3>
                                     <h5>{item.eventType}</h5>
@@ -44,7 +52,7 @@ class Gallery extends React.Component {
                                         }
                                     </div>
                                 </div>
-                            )
+                            ) : <p className="not-found">Not found gallery</p>
                         }
                     </div>
                 </div>
@@ -56,11 +64,12 @@ class Gallery extends React.Component {
 
 const mapStateToProps = state => {
     return {
-        gallery: state.photogalaryReducer.gallery
+        gallery: state.photogalaryReducer.gallery,
+        eventsArrTitles: state.getEvents.eventsArrTitles
     };
 };
 
 export default connect(
     mapStateToProps,
-    { getPhotogalary }
+    { getPhotogalary, getAllEvents }
 )(Gallery);

+ 0 - 1
src/conteiners/login/Login.js

@@ -11,7 +11,6 @@ import LoginForm from '../../components/login-form/LoginForm';
 export class Login extends React.Component {
     render() {
         const { postLoginSubmit, message } = this.props;
-        console.log(message);
         return (
             <div className="login-page">
                 <div className="form-login">

+ 17 - 28
src/conteiners/profile/Profile.js

@@ -2,6 +2,7 @@ import React from 'react';
 import { connect } from "react-redux";
 
 import { getUserInfo } from "../../actions/getUserInfo";
+import { getResults } from "../../actions/getResults";
 
 import './profile.scss';
 
@@ -13,13 +14,12 @@ import Sidebar from '../../components/sidebar/Sidebar';
 export class Profile extends React.Component {
     componentDidMount() {
         this.props.getUserInfo(JSON.parse(localStorage.user).user._id)
+        this.props.getResults();
     }
 
     render() {
-        //console.log('profileUser',JSON.parse(localStorage.user).user._id);
-        //const user = JSON.parse(localStorage.user).user;
-        const { user } = this.props;
-        //console.log('user',user);
+        const { user, results } = this.props;
+        const userResult = results.filter(result => result.eventUser.email === user.email);
     
         return (
             <>
@@ -62,43 +62,31 @@ export class Profile extends React.Component {
                             <input id="tab1" type="radio" name="tabs" checked readOnly hidden/>
                             <label htmlFor="tab1" className="tab-label">History</label>
 
-                            {/*<input id="tab2" type="radio" name="tabs" readOnly hidden/>
-                            <label htmlFor="tab2" className="tab-label">Settings</label>*/}
-
                             <div className="tab-item" id="content1">
                                <div className="history">
-                                   {/* название ивента, дистанция, время, место */}
                                    <table>
                                        <thead>
                                            <tr>
                                                <th>Event</th>
                                                <th>Distance</th>
                                                <th>Time</th>
-                                               <th>Rating</th>
+                                               <th>Event type</th>
                                            </tr>
                                        </thead>
                                        <tbody>
-                                           <tr>
-                                               <td>ULTRA MARATHON OF THE ATLANTIC 2019</td>
-                                               <td>marathone</td>
-                                               <td>3h40</td>
-                                               <td>39</td>
-                                           </tr>
-                                           <tr>
-                                               <td>CORFU HALF MARATHON</td>
-                                               <td>Half marathone</td>
-                                               <td>2h30</td>
-                                               <td>30</td>
-                                           </tr>
+                                           {
+                                                userResult.length !== 0 ? userResult.map(result => <tr key={result._id}>
+                                                        <td>{result.event.title}</td>
+                                                        <td>{result.eventUser.distance}</td>
+                                                        <td>{result.time}</td>
+                                                        <td>{result.event.eventType}</td>
+                                                    </tr>
+                                                ) : <tr><td colSpan="5"><p className="not-found">Not found results</p></td></tr>
+                                           }
                                        </tbody>
                                    </table>
                                </div>
                             </div>
-
-                            {/*<div className="tab-item" id="content2">
-                                <div className="settings">
-                                </div>
-                            </div>*/}
                         </div>
                     </div>
                 </div>
@@ -109,11 +97,12 @@ export class Profile extends React.Component {
 
 const mapStateToProps = state => {
     return {
-        user: state.userInfo.userProfile
+        user: state.userInfo.userProfile,
+        results: state.results.results
     };
 };
 
 export default connect(
     mapStateToProps,
-    { getUserInfo }
+    { getUserInfo, getResults }
 )(Profile);

+ 2 - 3
src/conteiners/result/Result.js

@@ -17,19 +17,18 @@ export class Result extends React.Component {
     }
     render() {
         const {marathone, halfMarathone, getResults, eventsArr} = this.props;
-        //console.log('result page',marathone);
         return (
             <>
                 <Sidebar/>
                 <div className="container-wrap events">
                     <div className="caption-page">
-                        <h2>Result page</h2>
+                        <h2>Results page</h2>
                     </div>
                 </div>
 
                 <div className="container-wrap">
                     <div className="events-filters">
-                        <h4>Events filter</h4>
+                        <h4>Result filter</h4>
                         <FiltersReviews labelType="Event Title" getRequest={getResults} eventTypes={eventsArr} />
                     </div>
 

+ 2 - 2
src/conteiners/reviews/Reviews.js

@@ -31,7 +31,7 @@ export class Reviews extends React.Component {
                 <div className="container-wrap">
 
                     <div className="events-filters">
-                        <h4>Events filter</h4>
+                        <h4>Reviews filter</h4>
                         <FiltersReviews labelType="Event Title" getRequest={getAllReviews} eventTypes={eventsArr} />
                     </div>
 
@@ -43,7 +43,7 @@ export class Reviews extends React.Component {
                                         <div className="reviews-name">{reviewer.name}</div>
                                         <div className="reviews-date">
                                             <i className="fa fa-calendar-o" aria-hidden="true"></i>
-                                        { new Date(reviewer.date).toDateString().slice(4) }
+                                        { new Date(reviewer.date).toDateString().slice(4) } {/*date */}
                                         </div>
                                         <div className="reviews-text">{reviewer.text}</div>
                                     </div>

+ 6 - 3
src/reducers/getAllEvents.js

@@ -2,6 +2,7 @@ import * as types from "../actionTypes/actionTypes";
 
 const initialState = {
     events: [],
+    eventsArrTitles: [],
     eventsArrShort: []
 }
 
@@ -11,10 +12,11 @@ export default (state = initialState, action) => {
             return state;
         }
 
-        case types.GET_REQUEST_SUCCESS_EVENTS: {
-            //console.log('events',action.payload.events);
-            
+        case types.GET_REQUEST_SUCCESS_EVENTS: {            
             const allEvents = action.payload.events;
+
+            const eventsTitles = allEvents.map(event => event.title); 
+
             const eventsArr = allEvents.map(event => ({
                 title: event.title,
                 id: event._id
@@ -23,6 +25,7 @@ export default (state = initialState, action) => {
             return {
                 ...state,
                 events: allEvents,
+                eventsArrTitles: eventsTitles,
                 eventsArrShort: eventsArr
             };
         }

+ 0 - 1
src/reducers/getRequestEvent.js

@@ -11,7 +11,6 @@ export default (state = initialState, action) => {
         }
 
         case types.GET_REQUEST_SUCCESS_EVENT_CARD: {
-            //console.log('event', action.payload.events[0]);
             return {
                 ...state,
                 event: action.payload.events[0]

+ 2 - 7
src/reducers/getResults.js

@@ -12,16 +12,11 @@ export default (state = initialState, action) => {
             return state;
         }
 
-        case types.GET_RESULT_SUCCESS: {
-            //console.log('results',action.payload.results);
-            
-            //отфильтровать по рейтингу - ?
-            
+        case types.GET_RESULT_SUCCESS: {            
             const resultsArr = action.payload.results;
             const marathoneResultsArr = resultsArr.filter( elem => elem.eventUser.distance === "Marathone" );
-            //console.log('marathoneResults',marathoneResultsArr);
+            
             const halfMarathoneResultsArr = resultsArr.filter( elem => elem.eventUser.distance === "Half marathone" );
-            //console.log('halfMarathoneResults',halfMarathoneResultsArr);
 
             return {
                 ...state,

+ 1 - 3
src/reducers/getUserInfo.js

@@ -10,9 +10,7 @@ export default (state = initialState, action) => {
             return state;
         }
 
-        case types.GET_USERS_INFO_SUCCESS: {
-            //console.log('userprofile',action.payload.user);
-            
+        case types.GET_USERS_INFO_SUCCESS: {            
             return {
                 ...state,
                 userProfile: action.payload.user

+ 5 - 4
src/reducers/login.js

@@ -11,8 +11,7 @@ export default (state = initialState, action) => {
             return state;
         }
 
-        case types.POST_REQUEST_SUCCESS_LOGIN: {   
-            console.log('action.payload.message',action.payload.message);
+        case types.POST_REQUEST_SUCCESS_LOGIN: {
             return {
                 ...state,
                 user: action.payload.user,
@@ -21,8 +20,10 @@ export default (state = initialState, action) => {
         }
 
         case types.POST_REQUEST_ERROR_LOGIN: {
-            console.log('error', action.payload.message);
-            return state;
+            return {
+                ...state,
+                message: action.payload.message
+            };
         }
 
         default:

+ 1 - 3
src/reducers/logout.js

@@ -10,13 +10,11 @@ export default (state = initialState, action) => {
             return state;
         }
 
-        case types.GET_LOGOUT_USER_SUCCESS: {
-            //console.log('logout',action.payload.logOut);            
+        case types.GET_LOGOUT_USER_SUCCESS: {   
             return state
         }
 
         case types.GET_LOGOUT_USER_ERROR: {
-            console.log('error');
             return state;
         }
 

+ 4 - 3
src/reducers/registration.js

@@ -11,7 +11,6 @@ export default (state = initialState, action) => {
         }
 
         case types.POST_REQUEST_SUCCESS_CHECKIN: {
-            console.log('some', action.payload.message );
             return {
                 ...state,
                 message: action.payload.message
@@ -19,8 +18,10 @@ export default (state = initialState, action) => {
         }
 
         case types.POST_REQUEST_ERROR_CHECKIN: {
-            console.log('error');
-            return state;
+            return {
+                ...state,
+                message: action.payload.message
+            };
         }
 
         default:

+ 0 - 2
src/reducers/registrationEvent.js

@@ -11,12 +11,10 @@ export default (state = initialState, action) => {
         }
 
         case types.POST_REGISTRATION_EVENT_SUCCESS: {
-            console.log('regEventUser', action.payload );
             return state;
         }
 
         case types.POST_REGISTRATION_EVENT_ERROR: {
-            console.log('error');
             return state;
         }
 

+ 10 - 7
src/reducers/reviews.js

@@ -1,7 +1,8 @@
 import * as types from "../actionTypes/actionTypes";
 
 const initialState = {
-    reviews: []
+    reviews: [],
+    message: ''
 }
 
 export default (state = initialState, action) => {
@@ -11,7 +12,6 @@ export default (state = initialState, action) => {
         }
 
         case types.GET_REQUEST_SUCCESS_REVIEWS: {
-            //console.log('reviews', action.payload);
             return {
                 ...state,
                 reviews: action.payload.results
@@ -19,8 +19,10 @@ export default (state = initialState, action) => {
         }
 
         case types.GET_REQUEST_ERROR_REVIEWS: {
-            console.log('error reviews', action.payload.message);
-            return state;
+            return {
+                ...state,
+                message: action.payload.message
+            };
         }
 
         case types.POST_REQUEST_REVIEW: {
@@ -28,13 +30,14 @@ export default (state = initialState, action) => {
         }
 
         case types.POST_REQUEST_SUCCESS_REVIEW: {
-            //console.log('review', action.payload);
             return state;
         }
 
         case types.POST_REQUEST_ERROR_REVIEW: {
-            console.log('error reviews', action.payload.message);
-            return state;
+            return {
+                ...state,
+                message: action.payload.message
+            };
         }
 
         default:

+ 1 - 1
src/router.js

@@ -46,7 +46,7 @@ const route = [
 	{
 		id: 4,
 		exact: true,
-		path: "/result",
+		path: "/results",
 		protected: false,
 		component: Result
 	},

+ 1 - 5
src/styles/custom.scss

@@ -1,10 +1,6 @@
-/*html {
-    min-height: 100vh;
+html, body, #root {
     height: 100%;
 }
-body, #root {
-    height: 100vh;
-}*/
 
 .button-position-bottom {
 	max-width: 1000px;