Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add sponser section in event detail page and code refactoring for better understanding. #261

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions client/src/actions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ export const getEvents = events => ({
events,
});

export const getCurrentEvent = event => ({
export const getEventDetail = event => ({
type: FETCH_EVENT_DETAIL,
event,
});
Expand Down Expand Up @@ -184,12 +184,12 @@ export const fetchUserProfile = userId => async (dispatch, getState) => {
dispatch(triggerFailure(FETCH_USER, e.message));
}
};
export const fetchCurrentEvent = eventId => async (dispatch, getState) => {
export const fetchEventDetail = eventId => async (dispatch, getState) => {
dispatch(triggerRequest(FETCH_EVENT_DETAIL));
try {
const event = await EventService.getCurrentEvent(eventId);
const event = await EventService.getEventDetail(eventId);
const camelCaseKeys = humps.camelizeKeys(event);
dispatch(getCurrentEvent(normalize(camelCaseKeys, eventSchema)));
dispatch(getEventDetail(normalize(camelCaseKeys, eventSchema)));
dispatch(endRequest(FETCH_EVENT_DETAIL));
} catch (e) {
dispatch(triggerFailure(FETCH_EVENT_DETAIL, e));
Expand Down Expand Up @@ -258,7 +258,7 @@ export const addComment = (comment, eventID) => (dispatch, getState) => {
return EventService.addComment(comment, eventID)
.then(comment => {
dispatch(postComment(comment));
dispatch(fetchCurrentEvent(eventID));
dispatch(fetchEventDetail(eventID));
dispatch(endRequest(POST_COMMENT));
})
.catch(err => {
Expand Down
4 changes: 2 additions & 2 deletions client/src/containers/App/routes/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import Events from '../../Events/Events';
import ForgotPassword from '../../ForgotPassword/ForgotPassword';
import Organisation from '../../Organisation/Organisation';
import EMNavbar from '../../../components/EMNavbar';
import CurrentEvent from '../../CurrentEvent/CurrentEvent';
import EventDetail from '../../EventDetail/EventDetail';
import UserProfile from '../../UserProfile/UserProfile';

// private routes
Expand All @@ -22,7 +22,7 @@ const Routes = () => (
<Switch>
<Route exact path="/" component={BaseRedirection} />
<Route exact path="/events" component={Events} />
<Route path="/events/:event_id" component={CurrentEvent} />
<Route path="/events/:event_id" component={EventDetail} />
<Route path="/organisations/:organisation_id" component={Organisation} />
<Route exact path="/users/:user_id" component={UserProfile} />
<Route path="/login" component={Login} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,29 +13,29 @@ import {
import MetaTagsComponent from '../../components/SocialShare/MetaTagsComponent';
import SummaryContainer from '../../components/SummaryContainer/SummaryContainer';
import { connect } from 'react-redux';
import { fetchCurrentEvent } from '../../actions';
import { fetchEventDetail } from '../../actions';
import ContentHeader from '../../components/ContentHeader/ContentHeader';
import moment from 'moment';
import DescriptionContainer from '../../components/DescriptionContainer/DescriptionContainer';
import { Link } from 'react-router-dom';
import { AttendeeType } from '../../types/attendee-types';
import './CurrentEvent.css';
import './EventDetail.css';
import GoogleMap from '../../components/GoogleMap/GoogleMap';
import CommentsBlock from '../../components/Comments/CommentsBlock';

const DATE_FORMAT = 'LLLL';

class CurrentEvent extends Component<Props> {
class EventDetail extends Component<Props> {
eventId;
componentDidMount() {
this.getCurrentEvent();
this.getEventDetail();
}

getCurrentEvent = () => {
getEventDetail = () => {
const eventId = this.props.match.params.event_id;
this.eventId = eventId;
const { dispatch } = this.props;
dispatch(fetchCurrentEvent(eventId));
dispatch(fetchEventDetail(eventId));
};

getAttendeesProfiles = (attendees: Array<AttendeeType>) => {
Expand Down Expand Up @@ -68,7 +68,7 @@ class CurrentEvent extends Component<Props> {
};

render() {
const { event } = this.props.currentEvent;
const { event } = this.props.eventDetail;

return (
<div className="main-container">
Expand Down Expand Up @@ -107,9 +107,19 @@ class CurrentEvent extends Component<Props> {
logo={event.organisation.logo}
/>
</Row>

<ContentHeader heading="Sponsers" />
<Row className="block-content">
{event.sponsers.map((sponser, index) => (
<SummaryContainer
key={index}
iconName="fa fa-clock-o fa-2x"
url={null}
logo={sponser.logo}
content={sponser.name}
/>
))}
</Row>
<DescriptionContainer description={event.description} />

{event.attendees && event.attendees.length ? (
<div>
<ContentHeader heading="Attendees" />
Expand Down Expand Up @@ -173,11 +183,11 @@ class CurrentEvent extends Component<Props> {
}

const mapStateToProps = state => {
const { currentEvent } = state;
return { currentEvent };
const { eventDetail } = state;
return { eventDetail };
};

export default connect(
mapStateToProps,
null
)(CurrentEvent);
)(EventDetail);
4 changes: 2 additions & 2 deletions client/src/reducers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ const events = (state = defaultEventState, action) => {
return state;
};

const currentEvent = (state = defaultEventState, action) => {
const eventDetail = (state = defaultEventState, action) => {
if (action.event) {
return {
event: { ...Object.values(action.event.entities.events)[0] },
Expand Down Expand Up @@ -220,7 +220,7 @@ const reducer = combineReducers({
userState,
resetPasswordState,
events,
currentEvent,
eventDetail,
currentOrganisation,
userProfile,
organisations: organisationsState,
Expand Down
2 changes: 1 addition & 1 deletion client/src/services/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export default {
});
},

getCurrentEvent: eventId => {
getEventDetail: eventId => {
return makeRequest(`${baseUri}${eventId}/`);
},

Expand Down