Skip to content
This repository has been archived by the owner on Feb 9, 2022. It is now read-only.

Commit

Permalink
Feature/summit speakers page 2 (#84)
Browse files Browse the repository at this point in the history
* New layout, page and templates for summit speakers

* Adjusting filters and email

Signed-off-by: Tomás Castillo <[email protected]>

* Adjust terms for filter, remove edit on click

Signed-off-by: Tomás Castillo <[email protected]>

* Fixes and tweaks

Signed-off-by: smarcet <[email protected]>

Co-authored-by: Tomás Castillo <[email protected]>
  • Loading branch information
smarcet and tomrndom committed Jun 28, 2022
1 parent 4843018 commit bbd450a
Show file tree
Hide file tree
Showing 11 changed files with 1,004 additions and 10 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,14 @@
"react-select": "^2.1.2",
"react-star-ratings": "^2.3.0",
"react-switch": "^6.0.0",
"react-tooltip": "^3.11.6",
"react-tooltip": "^4.2.21",
"redux": "^3.7.2",
"redux-persist": "^5.10.0",
"redux-thunk": "^2.3.0",
"sass-loader": "^6.0.7",
"segmented-control": "^0.1.12",
"style-loader": "^0.19.1",
"superagent": "^6.1.0",
"sweetalert2": "^8.15.2",
"urijs": "^1.19.1",
"url-loader": "^0.6.2",
Expand All @@ -93,7 +94,6 @@
"webpack-cli": "^3.3.12",
"webpack-dev-server": "^3.11.0",
"webpack-merge": "^4.2.1",
"xlsx": "^0.17.0",
"superagent": "^6.1.0"
"xlsx": "^0.17.0"
}
}
279 changes: 278 additions & 1 deletion src/actions/speaker-actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,14 @@ export const FEATURED_SPEAKER_DELETED = 'FEATURED_SPEAKER_DELETED';
export const FEATURED_SPEAKER_ADDED = 'FEATURED_SPEAKER_ADDED';
export const FEATURED_SPEAKER_ORDER_UPDATED = 'FEATURED_SPEAKER_ORDER_UPDATED';

export const REQUEST_SPEAKERS_BY_SUMMIT = 'REQUEST_SPEAKERS_BY_SUMMIT';
export const RECEIVE_SPEAKERS_BY_SUMMIT = 'RECEIVE_SPEAKERS_BY_SUMMIT';
export const SELECT_SUMMIT_SPEAKER = 'SELECT_SUMMIT_SPEAKER';
export const UNSELECT_SUMMIT_SPEAKER = 'UNSELECT_SUMMIT_SPEAKER';
export const SELECT_ALL_SUMMIT_SPEAKERS = 'SELECT_ALL_SUMMIT_SPEAKERS';
export const UNSELECT_ALL_SUMMIT_SPEAKERS = 'UNSELECT_ALL_SUMMIT_SPEAKERS';
export const SEND_SPEAKERS_EMAILS = 'SEND_SPEAKERS_EMAILS';
export const SET_SPEAKERS_CURRENT_FLOW_EVENT= 'SET_SPEAKERS_CURRENT_FLOW_EVENT';

export const getSpeakers = ( term = null, page = 1, perPage = 10, order = 'id', orderDir = 1 ) => (dispatch, getState) => {

Expand Down Expand Up @@ -675,4 +683,273 @@ export const removeFeaturedSpeaker = (speakerId) => (dispatch, getState) => {
dispatch(stopLoading());
}
);
};
};

/****************************************************************************************************/
/* SPEAKERS BY SUMMIT */
/****************************************************************************************************/

export const getSpeakersBySummit = (term = null, page = 1, perPage = 10, order = 'full_name', orderDir = 1, filters = {}) => (dispatch, getState) => {

const { loggedUserState, currentSummitState } = getState();
const { accessToken } = loggedUserState;
const { currentSummit } = currentSummitState;

const filter = parseFilters(filters);

dispatch(startLoading());

if(term) {
const escapedTerm = escapeFilterValue(term);
filter.push(
[
`full_name@@${escapedTerm}`,
`email=@${escapedTerm}`,
`presentations_title=@${escapedTerm}`,
`presentations_abstract=@${escapedTerm}`,
`presentations_submitter_full_name@@${escapedTerm}`,
`presentations_submitter_email=@${escapedTerm}`
].join(',')
);
}

const params = {
page : page,
per_page : perPage,
access_token : accessToken,
expand : 'accepted_presentations,alternate_presentations,rejected_presentations',
relations : 'accepted_presentations,alternate_presentations,rejected_presentations',
};

if(filter.length > 0){
params['filter[]']= filter;
}

// order
if(order != null && orderDir != null){
if(order == '') order = 'full_name';
const orderDirSign = (orderDir === 1) ? '+' : '-';
params['order']= `${orderDirSign}${order}`;
}

return getRequest(
createAction(REQUEST_SPEAKERS_BY_SUMMIT),
createAction(RECEIVE_SPEAKERS_BY_SUMMIT),
`${window.API_BASE_URL}/api/v1/summits/${currentSummit.id}/speakers`,
authErrorHandler,
{order, orderDir, page, perPage, term, ...filters, currentSummitId: currentSummit.id}
)(params)(dispatch).then(() => {
dispatch(stopLoading());
}
);
}

export const exportSummitSpeakers = (term = null, order = 'id', orderDir = 1, filters = {}) => (dispatch, getState) => {

const { loggedUserState, currentSummitState } = getState();
const { accessToken } = loggedUserState;
const { currentSummit } = currentSummitState;
const filename = currentSummit.name + '-Speakers.csv';
const params = {
access_token : accessToken
};

const filter = parseFilters(filters);

if(term) {
const escapedTerm = escapeFilterValue(term);
filter.push(
[
`full_name@@${escapedTerm}`,
`email=@${escapedTerm}`,
`presentations_title=@${escapedTerm}`,
`presentations_abstract=@${escapedTerm}`,
`presentations_submitter_full_name@@${escapedTerm}`,
`presentations_submitter_email=@${escapedTerm}`
].join(',')
);
}

if(filter.length > 0){
params['filter[]']= filter;
}

// order
if(order != null && orderDir != null){
const orderDirSign = (orderDir === 1) ? '+' : '-';
params['order']= `${orderDirSign}${order}`;
}

dispatch(getCSV(`${window.API_BASE_URL}/api/v1/summits/${currentSummit.id}/speakers/csv`, params, filename));
}

export const sendSpeakerEmails = (currentFlowEvent,
selectedAll = false ,
selectedIds = [],
testRecipient = '',
excerptRecipient= '',
term = '',
filters = {}
) => (dispatch, getState) => {

const { loggedUserState, currentSummitState } = getState();
const { accessToken } = loggedUserState;
const { currentSummit } = currentSummitState;

const params = {
access_token : accessToken,
};

const filter = parseFilters(filters);

if(term) {
const escapedTerm = escapeFilterValue(term);
filter.push(
[
`full_name@@${escapedTerm}`,
`email=@${escapedTerm}`,
`presentations_title=@${escapedTerm}`,
`presentations_abstract=@${escapedTerm}`,
`presentations_submitter_full_name@@${escapedTerm}`,
`presentations_submitter_email=@${escapedTerm}`
].join(',')
);
}

if (filter.length > 0) {
params['filter[]'] = filter;
}

const payload = {
email_flow_event : currentFlowEvent
};

if(!selectedAll && selectedIds.length > 0){
payload['speaker_ids'] = selectedIds;
}

if(testRecipient) {
payload['test_email_recipient'] = testRecipient;
}

if(excerptRecipient){
payload['outcome_email_recipient'] = excerptRecipient
}

dispatch(startLoading());

const success_message = {
title: T.translate("general.done"),
html: T.translate("summit_speakers_list.resend_done"),
type: 'success'
};

return putRequest(
null,
createAction(SEND_SPEAKERS_EMAILS),
`${window.API_BASE_URL}/api/v1/summits/${currentSummit.id}/speakers/all/send`,
payload,
authErrorHandler
)(params)(dispatch)
.then((payload) => {
dispatch(showMessage(
success_message,
));
dispatch(stopLoading());
return payload;
});
};

export const selectSummitSpeaker = (speakerId) => (dispatch, getState) => {
dispatch(createAction(SELECT_SUMMIT_SPEAKER)(speakerId));
};

export const unselectSummitSpeaker = (speakerId) => (dispatch, getState) => {
dispatch(createAction(UNSELECT_SUMMIT_SPEAKER)(speakerId));
};

export const selectAllSummitSpeakers = () => (dispatch, getState) => {
dispatch(createAction(SELECT_ALL_SUMMIT_SPEAKERS)());
}

export const unselectAllSummitSpeakers = () => (dispatch, getState) => {
dispatch(createAction(UNSELECT_ALL_SUMMIT_SPEAKERS)());
}

export const setCurrentFlowEvent = (value) => (dispatch) => {
dispatch(createAction(SET_SPEAKERS_CURRENT_FLOW_EVENT)(value));
};

const parseFilters = (filters) => {

const filter = [];

if(filters.hasOwnProperty('selectionPlanFilter') && Array.isArray(filters.selectionPlanFilter)
&& filters.selectionPlanFilter.length > 0){
filter.push(filters.selectionPlanFilter.reduce(
(accumulator, sp) => accumulator +(accumulator !== '' ? ',':'') +`presentations_selection_plan_id==${sp}`,
''
));
}

if(filters.hasOwnProperty('trackFilter') && Array.isArray(filters.trackFilter)
&& filters.trackFilter.length > 0){
filter.push(filters.trackFilter.reduce(
(accumulator, t) => accumulator +(accumulator !== '' ? ',':'') +`presentations_track_id==${t}`,
''
));
}

if(filters.hasOwnProperty('activityTypeFilter') && Array.isArray(filters.activityTypeFilter)
&& filters.activityTypeFilter.length > 0){
filter.push(filters.activityTypeFilter.reduce(
(accumulator, at) => accumulator +(accumulator !== '' ? ',':'') +`presentations_type_id==${at}`,
''
));
}

if(filters.hasOwnProperty('selectionStatusFilter')
&& Array.isArray(filters.selectionStatusFilter)
&& filters.selectionStatusFilter.length > 0 ) {

// exclusive filters
if(filters.selectionStatusFilter.includes('only_rejected')){
filter.push('has_rejected_presentations==true');
filter.push('has_accepted_presentations==false');
filter.push('has_alternate_presentations==false');
}
else if(filters.selectionStatusFilter.includes('only_accepted')){
filter.push('has_rejected_presentations==false');
filter.push('has_accepted_presentations==true');
filter.push('has_alternate_presentations==false');
}
else if(filters.selectionStatusFilter.includes('only_alternate')){
filter.push('has_rejected_presentations==false');
filter.push('has_accepted_presentations==false');
filter.push('has_alternate_presentations==true');
}
else if(filters.selectionStatusFilter.includes('accepted_alternate')){
filter.push('has_rejected_presentations==false');
filter.push('has_accepted_presentations==true');
filter.push('has_alternate_presentations==true');
}
else if(filters.selectionStatusFilter.includes('accepted_rejected')){
filter.push('has_rejected_presentations==true');
filter.push('has_accepted_presentations==true');
filter.push('has_alternate_presentations==false');
}
else if(filters.selectionStatusFilter.includes('alternate_rejected')){
filter.push('has_rejected_presentations==true');
filter.push('has_accepted_presentations==false');
filter.push('has_alternate_presentations==true');
}
else {
filter.push(filters.selectionStatusFilter.reduce(
(accumulator, at) => accumulator + (accumulator !== '' ? ',' : '') + `has_${at}_presentations==true`,
''
));
}
}

return filter;
}
1 change: 1 addition & 0 deletions src/components/nav-menu/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ class NavMenu extends React.Component {
{
name: 'summit_speakers', iconClass: 'fa-users', accessRoute: 'events',
childs: [
{name:'speakers', iconClass: 'fa-users', linkUrl:`summits/${summit_id}/speakers`, accessRoute: 'speakers'},
{name:'speaker_attendance', iconClass: 'fa-users', linkUrl:`summits/${summit_id}/speaker-attendances`, accessRoute: 'speakers'},
{name:'featured_speakers', iconClass: 'fa-star', linkUrl:`summits/${summit_id}/featured-speakers`, accessRoute: 'speakers'},
]
Expand Down
19 changes: 19 additions & 0 deletions src/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -674,6 +674,25 @@
"rate": "Rate",
"actions": "Actions"
},
"summit_speakers_list": {
"summit_speakers_list": "Summit Speakers List",
"summit_speakers": "Summit Speakers",
"accepted": "Accepted",
"rejected": "Rejected",
"alternate": "Alternate",
"no_speakers": "There are no speakers for this search criteria.",
"send_emails": "Send",
"excerpt_email": "Excerpt Recipient",
"select_template": "Select a Email Template to perform the action.",
"select_items": "Select at least one speaker to perform the action.",
"send_email_warning": "Are you sure you want to send emails to the selected speakers",
"resend_done": "Emails sent successfully.",
"send_emails_title": "You are about to send an EMAIL BLAST to selected speakers !",
"placeholders": {
"search_speakers": "Search by Full Name, Email, Title Or Abstract",
"test_recipient": "Optional Test Recipient"
}
},
"speaker_attendance_list": {
"speaker_attendance_list": "Speaker Attendance List",
"speaker_attendances": "Speaker Attendances",
Expand Down
2 changes: 2 additions & 0 deletions src/layouts/summit-id-layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ import TrackChairListPage from "../pages/track_chairs/track-chair-list-page";
import ProgressFlagsPage from "../pages/track_chairs/progress-flags-page";
import SummitPresentationsVotesPage from "../pages/events/summit-presentations-votes-page";
import RegistrationCompaniesLayout from './registration-companies-layout';
import SummitSpeakersLayout from './summit-speakers-layout';

class SummitIdLayout extends React.Component {

Expand Down Expand Up @@ -113,6 +114,7 @@ class SummitIdLayout extends React.Component {
<Route path={`${match.url}/event-category-groups`} component={EventCategoryGroupLayout}/>
<Route path={`${match.url}/attendees`} component={AttendeeLayout}/>
<Route path={`${match.url}/speaker-attendances`} component={SpeakerAttendanceLayout}/>
<Route path={`${match.url}/speakers`} component={SummitSpeakersLayout}/>
<Route path={`${match.url}/featured-speakers`} component={FeaturedSpeakersPage}/>
<Route path={`${match.url}/locations`} component={LocationLayout}/>
<Route path={`${match.url}/rsvp-templates`} component={RsvpTemplateLayout}/>
Expand Down
Loading

0 comments on commit bbd450a

Please sign in to comment.