fix: move donation modal from end of challenge to before a challenge.
parent
108884cbba
commit
e4affac93a
|
@ -23,8 +23,6 @@ import {
|
|||
import {
|
||||
userSelector,
|
||||
isSignedInSelector,
|
||||
openDonationModal,
|
||||
showDonationSelector,
|
||||
submitComplete,
|
||||
updateComplete,
|
||||
updateFailed
|
||||
|
@ -126,19 +124,13 @@ const submitters = {
|
|||
'project.backEnd': submitProject
|
||||
};
|
||||
|
||||
function shouldShowDonate(state) {
|
||||
return showDonationSelector(state) ? of(openDonationModal()) : empty();
|
||||
}
|
||||
|
||||
export default function completionEpic(action$, state$) {
|
||||
return action$.pipe(
|
||||
ofType(types.submitChallenge),
|
||||
switchMap(({ type }) => {
|
||||
const state = state$.value;
|
||||
const meta = challengeMetaSelector(state);
|
||||
const { isDonating } = userSelector(state);
|
||||
const { nextChallengePath, introPath, challengeType } = meta;
|
||||
const showDonate = isDonating ? empty() : shouldShowDonate(state);
|
||||
const closeChallengeModal = of(closeModal('completion'));
|
||||
let submitter = () => of({ type: 'no-user-signed-in' });
|
||||
if (
|
||||
|
@ -157,7 +149,6 @@ export default function completionEpic(action$, state$) {
|
|||
return submitter(type, state).pipe(
|
||||
tap(() => navigate(introPath ? introPath : nextChallengePath)),
|
||||
concat(closeChallengeModal),
|
||||
concat(showDonate),
|
||||
filter(Boolean)
|
||||
);
|
||||
})
|
||||
|
|
|
@ -3,8 +3,11 @@ import { put, select, call, takeEvery } from 'redux-saga/effects';
|
|||
import {
|
||||
isSignedInSelector,
|
||||
currentChallengeIdSelector,
|
||||
openDonationModal,
|
||||
showDonationSelector,
|
||||
updateComplete,
|
||||
updateFailed
|
||||
updateFailed,
|
||||
userSelector
|
||||
} from '../../../redux';
|
||||
|
||||
import { post } from '../../../utils/ajax';
|
||||
|
@ -35,9 +38,18 @@ function* updateSuccessMessageSaga() {
|
|||
yield put(updateSuccessMessage(randomCompliment()));
|
||||
}
|
||||
|
||||
function* showDonateModalSaga() {
|
||||
let { isDonating } = yield select(userSelector);
|
||||
let shouldShowDonate = yield select(showDonationSelector);
|
||||
if (!isDonating && shouldShowDonate) {
|
||||
yield put(openDonationModal());
|
||||
}
|
||||
}
|
||||
|
||||
export function createCurrentChallengeSaga(types) {
|
||||
return [
|
||||
takeEvery(types.challengeMounted, currentChallengeSaga),
|
||||
takeEvery(types.challengeMounted, updateSuccessMessageSaga)
|
||||
takeEvery(types.challengeMounted, updateSuccessMessageSaga),
|
||||
takeEvery(types.challengeMounted, showDonateModalSaga)
|
||||
];
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue