Skip to content
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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"email-validator": "^2.0.4",
"font-awesome": "^4.7.0",
"friendly-challenge": "^0.9.2",
"full-schedule-widget": "^1.1.45",
"full-schedule-widget": "^1.1.46",
"gatsby": "^2.32.13",
"gatsby-cli": "^2.11.5",
"gatsby-image": "^2.3.1",
Expand Down
21 changes: 15 additions & 6 deletions src/routes/authorization-callback-route.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ import URI from "urijs"
import { navigate } from '@reach/router'
import { connect } from 'react-redux';
import { AbstractAuthorizationCallbackRoute } from "openstack-uicore-foundation/lib/components";
import { getUserProfile} from '../actions/user-actions'
import {IDP_BASE_URL, OAUTH2_CLIENT_ID, getEnvVariable} from '../utils/envVariables'
import { getUserProfile, addToSchedule, removeFromSchedule } from '../actions/user-actions'
import { IDP_BASE_URL, OAUTH2_CLIENT_ID, getEnvVariable } from '../utils/envVariables'
import HeroComponent from "../components/HeroComponent";
import { getPendingAction } from '../utils/schedule';

class AuthorizationCallbackRoute extends AbstractAuthorizationCallbackRoute {

Expand All @@ -30,7 +31,13 @@ class AuthorizationCallbackRoute extends AbstractAuthorizationCallbackRoute {
this.props.getUserInfo(
'groups, all_affiliations, candidate_profile, election_applications, election_nominations, election_nominations.candidate',
'election_nominations.candidate.first_name, election_nominations.candidate.last_name'
).then(() => this.props.getUserProfile().then(() => navigate(URI.decode(backUrl))));
).then(() => this.props.getUserProfile().then(() => navigate(URI.decode(backUrl)))).then(() => {
const pendingAction = getPendingAction();
if (pendingAction) {
const { action, event } = pendingAction;
action === 'ADD_EVENT' ? this.props.addToSchedule(event) : this.props.removeFromSchedule(event);
}
});
}

_redirect2Error(error) {
Expand All @@ -39,8 +46,8 @@ class AuthorizationCallbackRoute extends AbstractAuthorizationCallbackRoute {
return null
}

_render(){
return <HeroComponent title={'Checking Credentials ...'}/>
_render() {
return <HeroComponent title={'Checking Credentials ...'} />
}
}

Expand All @@ -51,5 +58,7 @@ const mapStateToProps = ({ loggedUserState }) => ({
})

export default connect(mapStateToProps, {
getUserProfile
getUserProfile,
addToSchedule,
removeFromSchedule
})(AuthorizationCallbackRoute)
4 changes: 3 additions & 1 deletion src/utils/alerts.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import Swal from "sweetalert2";

import { doLogin } from 'openstack-uicore-foundation/lib/methods'
import URI from "urijs"
import { savePendingAction } from "./schedule";


export const alertPopup = (title, html, confirmLabel, confirmAction, cancelLabel = 'Dismiss') => {
Expand Down Expand Up @@ -30,12 +31,13 @@ export const alertPopup = (title, html, confirmLabel, confirmAction, cancelLabel
})
};

export const needsLogin = (msg = null) => {
export const needsLogin = (action, msg = null) => {
const defaultMessage = "Please login in order to build your schedule and add activities during the event";

const login = () => {
let backUrl = window?.location?.href ?? '/a/profile';
let encodedBackUrl = URI.encode(backUrl);
if (action) savePendingAction(action);
return doLogin(encodedBackUrl);
}

Expand Down
10 changes: 10 additions & 0 deletions src/utils/schedule.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,4 +182,14 @@ export const syncFilters = (newFilters, currentFilters) => {
}
});
return newFilters;
}

export const savePendingAction = (action) => {
window.localStorage.setItem('pendingAction', JSON.stringify(action));
}

export const getPendingAction = () => {
const pendingAction = JSON.parse(window.localStorage.getItem('pendingAction'));
window.localStorage.removeItem('pendingAction');
return pendingAction;
}
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -10512,10 +10512,10 @@ fstream@^1.0.0, fstream@^1.0.12:
mkdirp ">=0.5 0"
rimraf "2"

full-schedule-widget@^1.1.45:
version "1.1.45"
resolved "https://registry.yarnpkg.com/full-schedule-widget/-/full-schedule-widget-1.1.45.tgz#5298b159777a2dec8f5a50a714c9b85efa44876e"
integrity sha512-R0rm60xAQ54gpVJYZUQxQgs3GAPOLBc2JuRMpyM/E0dt2rDLPV+dldq7LbVrOTCMtgMOJrMAR+UjnON6mZETtQ==
full-schedule-widget@^1.1.46:
version "1.1.46"
resolved "https://registry.yarnpkg.com/full-schedule-widget/-/full-schedule-widget-1.1.46.tgz#7a85472fdaaf3951c299bbcfc287e38fd86e9bbe"
integrity sha512-FGCSRrb6AWKlkYWeiqqJmKVfK2nycDbcol19s9NSgKbWAh4QhqBFZOcQLltwDehfAtrlY3xM4BobPZNScNqmiQ==
dependencies:
pure-react-carousel "^1.27.4"

Expand Down