fix: order imports and remove circular dependencies (#41824)
* fix: remove circular dependency redux depended on templates/Challenges/redux and vice versa. This meant that import order mattered and confusing bugs could arise. (cherry picked from commit 7d67a4e70922bbb3051f2f9982dcc69e240d43dc) * feat: require imports to be in alphabetical order Import order generally does not matter, but there are edge cases (circular imports and css imports, for example) where changing order changes behaviour (cherry picked from commit b8d1393a91ec6e068caf8e8498a5c95df68c2b2c) * chore: order imports * fix: lift up challenge description + title comps This brings the classic Show closer to the others as they now all create the description and title components * fix: remove donation-saga/index circular import (cherry picked from commit 51a44ca668a700786d2744feffeae4fdba5fd207) * refactor: extract action-types from settings (cherry picked from commit 25e26124d691c84a0d0827d41dafb761c686fadd) * fix: lint errors * feat: prevent useless renames
This commit is contained in:
committed by
GitHub
parent
c7b27a53e7
commit
e118dda13a
@@ -1,10 +1,10 @@
|
||||
import { call, put, takeEvery } from 'redux-saga/effects';
|
||||
import { navigate } from 'gatsby';
|
||||
import { call, put, takeEvery } from 'redux-saga/effects';
|
||||
|
||||
import { acceptTermsComplete, acceptTermsError } from './';
|
||||
import { createFlashMessage } from '../components/Flash/redux';
|
||||
|
||||
import { putUserAcceptsTerms } from '../utils/ajax';
|
||||
import { acceptTermsComplete, acceptTermsError } from './';
|
||||
|
||||
function* acceptTermsSaga({ payload: quincyEmails }) {
|
||||
try {
|
||||
|
33
client/src/redux/action-types.js
Normal file
33
client/src/redux/action-types.js
Normal file
@@ -0,0 +1,33 @@
|
||||
import { createTypes, createAsyncTypes } from '../utils/create-types';
|
||||
|
||||
export const ns = 'app';
|
||||
|
||||
export const actionTypes = createTypes(
|
||||
[
|
||||
'appMount',
|
||||
'hardGoTo',
|
||||
'allowBlockDonationRequests',
|
||||
'closeDonationModal',
|
||||
'preventBlockDonationRequests',
|
||||
'preventProgressDonationRequests',
|
||||
'openDonationModal',
|
||||
'onlineStatusChange',
|
||||
'resetUserData',
|
||||
'tryToShowDonationModal',
|
||||
'executeGA',
|
||||
'submitComplete',
|
||||
'updateComplete',
|
||||
'updateCurrentChallengeId',
|
||||
'updateFailed',
|
||||
'updateDonationFormState',
|
||||
...createAsyncTypes('fetchUser'),
|
||||
...createAsyncTypes('addDonation'),
|
||||
...createAsyncTypes('createStripeSession'),
|
||||
...createAsyncTypes('postChargeStripe'),
|
||||
...createAsyncTypes('fetchProfileForUser'),
|
||||
...createAsyncTypes('acceptTerms'),
|
||||
...createAsyncTypes('showCert'),
|
||||
...createAsyncTypes('reportUser')
|
||||
],
|
||||
ns
|
||||
);
|
@@ -1,5 +1,5 @@
|
||||
import { put, takeEvery } from 'redux-saga/effects';
|
||||
import qs from 'query-string';
|
||||
import { put, takeEvery } from 'redux-saga/effects';
|
||||
import { createFlashMessage } from '../components/Flash/redux';
|
||||
|
||||
function* parseMessagesSaga() {
|
||||
|
@@ -1,15 +1,14 @@
|
||||
/* eslint-disable-next-line max-len */
|
||||
import { composeWithDevTools } from 'redux-devtools-extension/logOnlyInProduction';
|
||||
import { createStore as reduxCreateStore, applyMiddleware } from 'redux';
|
||||
import createSagaMiddleware from 'redux-saga';
|
||||
import { composeWithDevTools } from 'redux-devtools-extension/logOnlyInProduction';
|
||||
import { createEpicMiddleware } from 'redux-observable';
|
||||
import createSagaMiddleware from 'redux-saga';
|
||||
|
||||
import envData from '../../../config/env.json';
|
||||
import { isBrowser } from '../../utils';
|
||||
import rootEpic from './rootEpic';
|
||||
import rootReducer from './rootReducer';
|
||||
import rootSaga from './rootSaga';
|
||||
import { isBrowser } from '../../utils';
|
||||
|
||||
import envData from '../../../config/env.json';
|
||||
|
||||
const { environment } = envData;
|
||||
|
||||
|
@@ -1,4 +1,6 @@
|
||||
import { put, select, takeEvery, delay, call, take } from 'redux-saga/effects';
|
||||
import { addDonation } from '../utils/ajax';
|
||||
import { actionTypes as appTypes } from './action-types';
|
||||
|
||||
import {
|
||||
openDonationModal,
|
||||
@@ -7,12 +9,9 @@ import {
|
||||
preventProgressDonationRequests,
|
||||
recentlyClaimedBlockSelector,
|
||||
addDonationComplete,
|
||||
addDonationError,
|
||||
types as appTypes
|
||||
addDonationError
|
||||
} from './';
|
||||
|
||||
import { addDonation } from '../utils/ajax';
|
||||
|
||||
const defaultDonationError = `Something is not right. Please contact donors@freecodecamp.org`;
|
||||
|
||||
function* showDonateModalSaga() {
|
||||
|
@@ -1,10 +1,10 @@
|
||||
import { navigate } from 'gatsby';
|
||||
import { takeEvery, put } from 'redux-saga/effects';
|
||||
import { isError } from 'lodash-es';
|
||||
import { takeEvery, put } from 'redux-saga/effects';
|
||||
|
||||
import { createFlashMessage } from '../components/Flash/redux';
|
||||
import { isHandledError, unwrapHandledError } from '../utils/handled-error';
|
||||
import { reportClientSideError } from '../utils/report-error';
|
||||
import { createFlashMessage } from '../components/Flash/redux';
|
||||
import reportedErrorMessage from '../utils/reported-error-message';
|
||||
|
||||
const errorActionSelector = action => isError(action.payload);
|
||||
|
@@ -1,3 +1,4 @@
|
||||
import { ofType } from 'redux-observable';
|
||||
import { merge, empty } from 'rxjs';
|
||||
import {
|
||||
tap,
|
||||
@@ -7,19 +8,14 @@ import {
|
||||
switchMap,
|
||||
catchError
|
||||
} from 'rxjs/operators';
|
||||
import { ofType } from 'redux-observable';
|
||||
import store from 'store';
|
||||
import { v4 as uuid } from 'uuid';
|
||||
|
||||
import {
|
||||
types,
|
||||
onlineStatusChange,
|
||||
isOnlineSelector,
|
||||
isSignedInSelector
|
||||
} from './';
|
||||
import postUpdate$ from '../templates/Challenges/utils/postUpdate$';
|
||||
import { isGoodXHRStatus } from '../templates/Challenges/utils';
|
||||
import { backEndProject } from '../../utils/challengeTypes';
|
||||
import { isGoodXHRStatus } from '../templates/Challenges/utils';
|
||||
import postUpdate$ from '../templates/Challenges/utils/postUpdate$';
|
||||
import { actionTypes } from './action-types';
|
||||
import { onlineStatusChange, isOnlineSelector, isSignedInSelector } from './';
|
||||
|
||||
const key = 'fcc-failed-updates';
|
||||
|
||||
@@ -33,7 +29,7 @@ const isSubmitable = failure =>
|
||||
|
||||
function failedUpdateEpic(action$, state$) {
|
||||
const storeUpdates = action$.pipe(
|
||||
ofType(types.updateFailed),
|
||||
ofType(actionTypes.updateFailed),
|
||||
tap(({ payload = {} }) => {
|
||||
if ('endpoint' in payload && 'payload' in payload) {
|
||||
const failures = store.get(key) || [];
|
||||
@@ -45,7 +41,7 @@ function failedUpdateEpic(action$, state$) {
|
||||
);
|
||||
|
||||
const flushUpdates = action$.pipe(
|
||||
ofType(types.fetchUserComplete, types.updateComplete),
|
||||
ofType(actionTypes.fetchUserComplete, actionTypes.updateComplete),
|
||||
filter(() => isSignedInSelector(state$.value)),
|
||||
filter(() => store.get(key)),
|
||||
filter(() => isOnlineSelector(state$.value)),
|
||||
|
@@ -1,8 +1,8 @@
|
||||
import { Subject } from 'rxjs';
|
||||
import { ActionsObservable, StateObservable } from 'redux-observable';
|
||||
import failedUpdatesEpic from './failed-updates-epic';
|
||||
import { types } from './';
|
||||
import { Subject } from 'rxjs';
|
||||
import store from 'store';
|
||||
import { actionTypes } from './action-types';
|
||||
import failedUpdatesEpic from './failed-updates-epic';
|
||||
|
||||
jest.mock('../analytics');
|
||||
|
||||
@@ -13,7 +13,7 @@ describe('failed-updates-epic', () => {
|
||||
store.set(key, failedSubmissions);
|
||||
|
||||
const action$ = ActionsObservable.of({
|
||||
type: types.updateComplete
|
||||
type: actionTypes.updateComplete
|
||||
});
|
||||
const state$ = new StateObservable(new Subject(), initialState);
|
||||
const epic$ = failedUpdatesEpic(action$, state$);
|
||||
|
@@ -1,13 +1,13 @@
|
||||
import { call, put, takeEvery } from 'redux-saga/effects';
|
||||
|
||||
import { getSessionUser, getUserProfile } from '../utils/ajax';
|
||||
import { jwt } from './cookieValues';
|
||||
import {
|
||||
fetchUserComplete,
|
||||
fetchUserError,
|
||||
fetchProfileForUserError,
|
||||
fetchProfileForUserComplete
|
||||
} from './';
|
||||
import { getSessionUser, getUserProfile } from '../utils/ajax';
|
||||
import { jwt } from './cookieValues';
|
||||
|
||||
function* fetchSessionUser() {
|
||||
if (!jwt) {
|
||||
|
@@ -1,7 +1,7 @@
|
||||
import { types } from '.';
|
||||
import { createGaSaga } from './ga-saga';
|
||||
import ga from '../analytics';
|
||||
import { expectSaga } from 'redux-saga-test-plan';
|
||||
import ga from '../analytics';
|
||||
import { actionTypes } from './action-types';
|
||||
import { createGaSaga } from './ga-saga';
|
||||
|
||||
jest.mock('../analytics');
|
||||
|
||||
@@ -16,12 +16,12 @@ describe('ga-saga', () => {
|
||||
}
|
||||
};
|
||||
return (
|
||||
expectSaga(createGaSaga, types)
|
||||
expectSaga(createGaSaga, actionTypes)
|
||||
// Assert that the `call` with expected pramater will eventually happen.
|
||||
.call(GaTypes.event, mockEventPayload.data)
|
||||
|
||||
// Dispatch any actions that the saga will `take`.
|
||||
.dispatch({ type: types.executeGA, payload: mockEventPayload })
|
||||
.dispatch({ type: actionTypes.executeGA, payload: mockEventPayload })
|
||||
|
||||
// Start the test.
|
||||
.run()
|
||||
|
@@ -1,11 +1,11 @@
|
||||
import { ofType } from 'redux-observable';
|
||||
import { tap, ignoreElements } from 'rxjs/operators';
|
||||
|
||||
import { types } from './';
|
||||
import { actionTypes } from './action-types';
|
||||
|
||||
export default function hardGoToEpic(action$, _, { location }) {
|
||||
return action$.pipe(
|
||||
ofType(types.hardGoTo),
|
||||
ofType(actionTypes.hardGoTo),
|
||||
tap(({ payload }) => {
|
||||
location.href = payload;
|
||||
}),
|
||||
|
@@ -1,27 +1,26 @@
|
||||
import { createAction, handleActions } from 'redux-actions';
|
||||
import { uniqBy } from 'lodash-es';
|
||||
import { createAction, handleActions } from 'redux-actions';
|
||||
import store from 'store';
|
||||
|
||||
import { createTypes, createAsyncTypes } from '../utils/create-types';
|
||||
import { createFetchUserSaga } from './fetch-user-saga';
|
||||
import { actionTypes as challengeTypes } from '../templates/Challenges/redux/action-types';
|
||||
import { CURRENT_CHALLENGE_KEY } from '../templates/Challenges/redux/current-challenge-saga';
|
||||
import { createAcceptTermsSaga } from './accept-terms-saga';
|
||||
import { actionTypes, ns } from './action-types';
|
||||
import { createAppMountSaga } from './app-mount-saga';
|
||||
import { createReportUserSaga } from './report-user-saga';
|
||||
import { createShowCertSaga } from './show-cert-saga';
|
||||
import { createNightModeSaga } from './night-mode-saga';
|
||||
import { createDonationSaga } from './donation-saga';
|
||||
import failedUpdatesEpic from './failed-updates-epic';
|
||||
import { createFetchUserSaga } from './fetch-user-saga';
|
||||
import { createGaSaga } from './ga-saga';
|
||||
|
||||
import hardGoToEpic from './hard-go-to-epic';
|
||||
import failedUpdatesEpic from './failed-updates-epic';
|
||||
import { createNightModeSaga } from './night-mode-saga';
|
||||
import { createReportUserSaga } from './report-user-saga';
|
||||
|
||||
import { actionTypes as settingsTypes } from './settings/action-types';
|
||||
import { createShowCertSaga } from './show-cert-saga';
|
||||
import updateCompleteEpic from './update-complete-epic';
|
||||
|
||||
import { types as settingsTypes } from './settings';
|
||||
import { types as challengeTypes } from '../templates/Challenges/redux/';
|
||||
// eslint-disable-next-line max-len
|
||||
import { CURRENT_CHALLENGE_KEY } from '../templates/Challenges/redux/current-challenge-saga';
|
||||
|
||||
export const ns = 'app';
|
||||
export { ns };
|
||||
|
||||
export const defaultFetchState = {
|
||||
pending: true,
|
||||
@@ -62,114 +61,92 @@ const initialState = {
|
||||
}
|
||||
};
|
||||
|
||||
export const types = createTypes(
|
||||
[
|
||||
'appMount',
|
||||
'hardGoTo',
|
||||
'allowBlockDonationRequests',
|
||||
'closeDonationModal',
|
||||
'preventBlockDonationRequests',
|
||||
'preventProgressDonationRequests',
|
||||
'openDonationModal',
|
||||
'onlineStatusChange',
|
||||
'resetUserData',
|
||||
'tryToShowDonationModal',
|
||||
'executeGA',
|
||||
'submitComplete',
|
||||
'updateComplete',
|
||||
'updateCurrentChallengeId',
|
||||
'updateFailed',
|
||||
'updateDonationFormState',
|
||||
...createAsyncTypes('fetchUser'),
|
||||
...createAsyncTypes('addDonation'),
|
||||
...createAsyncTypes('fetchProfileForUser'),
|
||||
...createAsyncTypes('acceptTerms'),
|
||||
...createAsyncTypes('showCert'),
|
||||
...createAsyncTypes('reportUser')
|
||||
],
|
||||
ns
|
||||
);
|
||||
|
||||
export const epics = [hardGoToEpic, failedUpdatesEpic, updateCompleteEpic];
|
||||
|
||||
export const sagas = [
|
||||
...createAcceptTermsSaga(types),
|
||||
...createAppMountSaga(types),
|
||||
...createDonationSaga(types),
|
||||
...createGaSaga(types),
|
||||
...createFetchUserSaga(types),
|
||||
...createShowCertSaga(types),
|
||||
...createReportUserSaga(types),
|
||||
...createNightModeSaga({ ...types, ...settingsTypes })
|
||||
...createAcceptTermsSaga(actionTypes),
|
||||
...createAppMountSaga(actionTypes),
|
||||
...createDonationSaga(actionTypes),
|
||||
...createGaSaga(actionTypes),
|
||||
...createFetchUserSaga(actionTypes),
|
||||
...createShowCertSaga(actionTypes),
|
||||
...createReportUserSaga(actionTypes),
|
||||
...createNightModeSaga({ ...actionTypes, ...settingsTypes })
|
||||
];
|
||||
|
||||
export const appMount = createAction(types.appMount);
|
||||
export const appMount = createAction(actionTypes.appMount);
|
||||
|
||||
export const tryToShowDonationModal = createAction(
|
||||
types.tryToShowDonationModal
|
||||
actionTypes.tryToShowDonationModal
|
||||
);
|
||||
|
||||
export const executeGA = createAction(types.executeGA);
|
||||
export const executeGA = createAction(actionTypes.executeGA);
|
||||
|
||||
export const allowBlockDonationRequests = createAction(
|
||||
types.allowBlockDonationRequests
|
||||
actionTypes.allowBlockDonationRequests
|
||||
);
|
||||
export const closeDonationModal = createAction(types.closeDonationModal);
|
||||
export const openDonationModal = createAction(types.openDonationModal);
|
||||
export const closeDonationModal = createAction(actionTypes.closeDonationModal);
|
||||
export const openDonationModal = createAction(actionTypes.openDonationModal);
|
||||
export const preventBlockDonationRequests = createAction(
|
||||
types.preventBlockDonationRequests
|
||||
actionTypes.preventBlockDonationRequests
|
||||
);
|
||||
export const preventProgressDonationRequests = createAction(
|
||||
types.preventProgressDonationRequests
|
||||
actionTypes.preventProgressDonationRequests
|
||||
);
|
||||
export const updateDonationFormState = createAction(
|
||||
types.updateDonationFormState
|
||||
actionTypes.updateDonationFormState
|
||||
);
|
||||
|
||||
export const onlineStatusChange = createAction(types.onlineStatusChange);
|
||||
export const onlineStatusChange = createAction(actionTypes.onlineStatusChange);
|
||||
|
||||
// TODO: re-evaluate this since /internal is no longer used.
|
||||
// `hardGoTo` is used to hit the API server directly
|
||||
// without going through /internal
|
||||
// used for things like /signin and /signout
|
||||
export const hardGoTo = createAction(types.hardGoTo);
|
||||
export const hardGoTo = createAction(actionTypes.hardGoTo);
|
||||
|
||||
export const submitComplete = createAction(types.submitComplete);
|
||||
export const updateComplete = createAction(types.updateComplete);
|
||||
export const updateFailed = createAction(types.updateFailed);
|
||||
export const submitComplete = createAction(actionTypes.submitComplete);
|
||||
export const updateComplete = createAction(actionTypes.updateComplete);
|
||||
export const updateFailed = createAction(actionTypes.updateFailed);
|
||||
|
||||
export const acceptTerms = createAction(types.acceptTerms);
|
||||
export const acceptTermsComplete = createAction(types.acceptTermsComplete);
|
||||
export const acceptTermsError = createAction(types.acceptTermsError);
|
||||
export const acceptTerms = createAction(actionTypes.acceptTerms);
|
||||
export const acceptTermsComplete = createAction(
|
||||
actionTypes.acceptTermsComplete
|
||||
);
|
||||
export const acceptTermsError = createAction(actionTypes.acceptTermsError);
|
||||
|
||||
export const fetchUser = createAction(types.fetchUser);
|
||||
export const fetchUserComplete = createAction(types.fetchUserComplete);
|
||||
export const fetchUserError = createAction(types.fetchUserError);
|
||||
export const fetchUser = createAction(actionTypes.fetchUser);
|
||||
export const fetchUserComplete = createAction(actionTypes.fetchUserComplete);
|
||||
export const fetchUserError = createAction(actionTypes.fetchUserError);
|
||||
|
||||
export const addDonation = createAction(types.addDonation);
|
||||
export const addDonationComplete = createAction(types.addDonationComplete);
|
||||
export const addDonationError = createAction(types.addDonationError);
|
||||
export const addDonation = createAction(actionTypes.addDonation);
|
||||
export const addDonationComplete = createAction(
|
||||
actionTypes.addDonationComplete
|
||||
);
|
||||
export const addDonationError = createAction(actionTypes.addDonationError);
|
||||
|
||||
export const fetchProfileForUser = createAction(types.fetchProfileForUser);
|
||||
export const fetchProfileForUser = createAction(
|
||||
actionTypes.fetchProfileForUser
|
||||
);
|
||||
export const fetchProfileForUserComplete = createAction(
|
||||
types.fetchProfileForUserComplete
|
||||
actionTypes.fetchProfileForUserComplete
|
||||
);
|
||||
export const fetchProfileForUserError = createAction(
|
||||
types.fetchProfileForUserError
|
||||
actionTypes.fetchProfileForUserError
|
||||
);
|
||||
|
||||
export const reportUser = createAction(types.reportUser);
|
||||
export const reportUserComplete = createAction(types.reportUserComplete);
|
||||
export const reportUserError = createAction(types.reportUserError);
|
||||
export const reportUser = createAction(actionTypes.reportUser);
|
||||
export const reportUserComplete = createAction(actionTypes.reportUserComplete);
|
||||
export const reportUserError = createAction(actionTypes.reportUserError);
|
||||
|
||||
export const resetUserData = createAction(types.resetUserData);
|
||||
export const resetUserData = createAction(actionTypes.resetUserData);
|
||||
|
||||
export const showCert = createAction(types.showCert);
|
||||
export const showCertComplete = createAction(types.showCertComplete);
|
||||
export const showCertError = createAction(types.showCertError);
|
||||
export const showCert = createAction(actionTypes.showCert);
|
||||
export const showCertComplete = createAction(actionTypes.showCertComplete);
|
||||
export const showCertError = createAction(actionTypes.showCertError);
|
||||
|
||||
export const updateCurrentChallengeId = createAction(
|
||||
types.updateCurrentChallengeId
|
||||
actionTypes.updateCurrentChallengeId
|
||||
);
|
||||
|
||||
export const completedChallengesSelector = state =>
|
||||
@@ -384,7 +361,7 @@ function spreadThePayloadOnUser(state, payload) {
|
||||
|
||||
export const reducer = handleActions(
|
||||
{
|
||||
[types.acceptTermsComplete]: (state, { payload }) => {
|
||||
[actionTypes.acceptTermsComplete]: (state, { payload }) => {
|
||||
const { appUsername } = state;
|
||||
return {
|
||||
...state,
|
||||
@@ -405,21 +382,21 @@ export const reducer = handleActions(
|
||||
}
|
||||
};
|
||||
},
|
||||
[types.allowBlockDonationRequests]: (state, { payload }) => {
|
||||
[actionTypes.allowBlockDonationRequests]: (state, { payload }) => {
|
||||
return {
|
||||
...state,
|
||||
recentlyClaimedBlock: payload
|
||||
};
|
||||
},
|
||||
[types.updateDonationFormState]: (state, { payload }) => ({
|
||||
[actionTypes.updateDonationFormState]: (state, { payload }) => ({
|
||||
...state,
|
||||
donationFormState: { ...state.donationFormState, ...payload }
|
||||
}),
|
||||
[types.addDonation]: state => ({
|
||||
[actionTypes.addDonation]: state => ({
|
||||
...state,
|
||||
donationFormState: { ...defaultDonationFormState, processing: true }
|
||||
}),
|
||||
[types.addDonationComplete]: state => {
|
||||
[actionTypes.addDonationComplete]: state => {
|
||||
const { appUsername } = state;
|
||||
return {
|
||||
...state,
|
||||
@@ -434,19 +411,19 @@ export const reducer = handleActions(
|
||||
donationFormState: { ...defaultDonationFormState, success: true }
|
||||
};
|
||||
},
|
||||
[types.addDonationError]: (state, { payload }) => ({
|
||||
[actionTypes.addDonationError]: (state, { payload }) => ({
|
||||
...state,
|
||||
donationFormState: { ...defaultDonationFormState, error: payload }
|
||||
}),
|
||||
[types.fetchUser]: state => ({
|
||||
[actionTypes.fetchUser]: state => ({
|
||||
...state,
|
||||
userFetchState: { ...defaultFetchState }
|
||||
}),
|
||||
[types.fetchProfileForUser]: state => ({
|
||||
[actionTypes.fetchProfileForUser]: state => ({
|
||||
...state,
|
||||
userProfileFetchState: { ...defaultFetchState }
|
||||
}),
|
||||
[types.fetchUserComplete]: (
|
||||
[actionTypes.fetchUserComplete]: (
|
||||
state,
|
||||
{ payload: { user, username, sessionMeta } }
|
||||
) => ({
|
||||
@@ -468,7 +445,7 @@ export const reducer = handleActions(
|
||||
...sessionMeta
|
||||
}
|
||||
}),
|
||||
[types.fetchUserError]: (state, { payload }) => ({
|
||||
[actionTypes.fetchUserError]: (state, { payload }) => ({
|
||||
...state,
|
||||
userFetchState: {
|
||||
pending: false,
|
||||
@@ -477,7 +454,7 @@ export const reducer = handleActions(
|
||||
error: payload
|
||||
}
|
||||
}),
|
||||
[types.fetchProfileForUserComplete]: (
|
||||
[actionTypes.fetchProfileForUserComplete]: (
|
||||
state,
|
||||
{ payload: { user, username } }
|
||||
) => {
|
||||
@@ -496,7 +473,7 @@ export const reducer = handleActions(
|
||||
}
|
||||
};
|
||||
},
|
||||
[types.fetchProfileForUserError]: (state, { payload }) => ({
|
||||
[actionTypes.fetchProfileForUserError]: (state, { payload }) => ({
|
||||
...state,
|
||||
userProfileFetchState: {
|
||||
pending: false,
|
||||
@@ -505,37 +482,37 @@ export const reducer = handleActions(
|
||||
error: payload
|
||||
}
|
||||
}),
|
||||
[types.onlineStatusChange]: (state, { payload: isOnline }) => ({
|
||||
[actionTypes.onlineStatusChange]: (state, { payload: isOnline }) => ({
|
||||
...state,
|
||||
isOnline
|
||||
}),
|
||||
[types.closeDonationModal]: state => ({
|
||||
[actionTypes.closeDonationModal]: state => ({
|
||||
...state,
|
||||
showDonationModal: false
|
||||
}),
|
||||
[types.openDonationModal]: state => ({
|
||||
[actionTypes.openDonationModal]: state => ({
|
||||
...state,
|
||||
showDonationModal: true
|
||||
}),
|
||||
[types.preventBlockDonationRequests]: state => ({
|
||||
[actionTypes.preventBlockDonationRequests]: state => ({
|
||||
...state,
|
||||
recentlyClaimedBlock: null
|
||||
}),
|
||||
[types.preventProgressDonationRequests]: state => ({
|
||||
[actionTypes.preventProgressDonationRequests]: state => ({
|
||||
...state,
|
||||
canRequestProgressDonation: false
|
||||
}),
|
||||
[types.resetUserData]: state => ({
|
||||
[actionTypes.resetUserData]: state => ({
|
||||
...state,
|
||||
appUsername: '',
|
||||
user: {}
|
||||
}),
|
||||
[types.showCert]: state => ({
|
||||
[actionTypes.showCert]: state => ({
|
||||
...state,
|
||||
showCert: {},
|
||||
showCertFetchState: { ...defaultFetchState }
|
||||
}),
|
||||
[types.showCertComplete]: (state, { payload }) => ({
|
||||
[actionTypes.showCertComplete]: (state, { payload }) => ({
|
||||
...state,
|
||||
showCert: payload,
|
||||
showCertFetchState: {
|
||||
@@ -544,7 +521,7 @@ export const reducer = handleActions(
|
||||
complete: true
|
||||
}
|
||||
}),
|
||||
[types.showCertError]: (state, { payload }) => ({
|
||||
[actionTypes.showCertError]: (state, { payload }) => ({
|
||||
...state,
|
||||
showCert: {},
|
||||
showCertFetchState: {
|
||||
@@ -554,7 +531,7 @@ export const reducer = handleActions(
|
||||
error: payload
|
||||
}
|
||||
}),
|
||||
[types.submitComplete]: (state, { payload }) => {
|
||||
[actionTypes.submitComplete]: (state, { payload }) => {
|
||||
let submittedchallenges = [{ ...payload, completedDate: Date.now() }];
|
||||
if (payload.challArray) {
|
||||
submittedchallenges = payload.challArray;
|
||||
|
@@ -1,10 +1,10 @@
|
||||
import { call, put, takeEvery } from 'redux-saga/effects';
|
||||
import { navigate } from 'gatsby';
|
||||
import { call, put, takeEvery } from 'redux-saga/effects';
|
||||
|
||||
import { reportUserComplete, reportUserError } from './';
|
||||
import { createFlashMessage } from '../components/Flash/redux';
|
||||
|
||||
import { postReportUser } from '../utils/ajax';
|
||||
import { reportUserComplete, reportUserError } from './';
|
||||
|
||||
function* reportUserSaga({ payload }) {
|
||||
try {
|
||||
|
@@ -1,7 +1,7 @@
|
||||
import { combineEpics } from 'redux-observable';
|
||||
|
||||
import { epics as appEpics } from './';
|
||||
import { epics as challengeEpics } from '../templates/Challenges/redux';
|
||||
import { epics as appEpics } from './';
|
||||
|
||||
const rootEpic = combineEpics(...appEpics, ...challengeEpics);
|
||||
|
||||
|
@@ -1,23 +1,23 @@
|
||||
import { combineReducers } from 'redux';
|
||||
|
||||
import { reducer as app, ns as appNameSpace } from './';
|
||||
import {
|
||||
reducer as flash,
|
||||
ns as flashNameSpace
|
||||
} from '../components/Flash/redux';
|
||||
import { reducer as settings, ns as settingsNameSpace } from './settings';
|
||||
import {
|
||||
reducer as curriculumMap,
|
||||
ns as curriculumMapNameSpace
|
||||
} from '../templates/Introduction/redux';
|
||||
reducer as search,
|
||||
ns as searchNameSpace
|
||||
} from '../components/search/redux';
|
||||
import {
|
||||
reducer as challenge,
|
||||
ns as challengeNameSpace
|
||||
} from '../templates/Challenges/redux';
|
||||
import {
|
||||
reducer as search,
|
||||
ns as searchNameSpace
|
||||
} from '../components/search/redux';
|
||||
reducer as curriculumMap,
|
||||
ns as curriculumMapNameSpace
|
||||
} from '../templates/Introduction/redux';
|
||||
import { reducer as settings, ns as settingsNameSpace } from './settings';
|
||||
import { reducer as app, ns as appNameSpace } from './';
|
||||
|
||||
export default combineReducers({
|
||||
[appNameSpace]: app,
|
||||
|
@@ -1,9 +1,9 @@
|
||||
import { all } from 'redux-saga/effects';
|
||||
|
||||
import errorSagas from './error-saga';
|
||||
import { sagas as appSagas } from './';
|
||||
import { sagas as challengeSagas } from '../templates/Challenges/redux';
|
||||
import errorSagas from './error-saga';
|
||||
import { sagas as settingsSagas } from './settings';
|
||||
import { sagas as appSagas } from './';
|
||||
|
||||
export default function* rootSaga() {
|
||||
yield all([...errorSagas, ...appSagas, ...challengeSagas, ...settingsSagas]);
|
||||
|
19
client/src/redux/settings/action-types.js
Normal file
19
client/src/redux/settings/action-types.js
Normal file
@@ -0,0 +1,19 @@
|
||||
import { createTypes, createAsyncTypes } from '../../utils/create-types';
|
||||
|
||||
export const ns = 'settings';
|
||||
|
||||
export const actionTypes = createTypes(
|
||||
[
|
||||
...createAsyncTypes('validateUsername'),
|
||||
...createAsyncTypes('submitNewAbout'),
|
||||
...createAsyncTypes('submitNewUsername'),
|
||||
...createAsyncTypes('updateMyEmail'),
|
||||
...createAsyncTypes('updateLegacyCert'),
|
||||
...createAsyncTypes('updateUserFlag'),
|
||||
...createAsyncTypes('submitProfileUI'),
|
||||
...createAsyncTypes('verifyCert'),
|
||||
...createAsyncTypes('resetProgress'),
|
||||
...createAsyncTypes('deleteAccount')
|
||||
],
|
||||
ns
|
||||
);
|
@@ -1,10 +1,11 @@
|
||||
import { navigate } from 'gatsby';
|
||||
import { call, put, takeEvery, take } from 'redux-saga/effects';
|
||||
|
||||
import { deleteAccountError, resetProgressError } from './';
|
||||
import { resetUserData, fetchUser, types as appTypes } from '../';
|
||||
import { postResetProgress, postDeleteAccount } from '../../utils/ajax';
|
||||
import { resetUserData, fetchUser } from '../';
|
||||
import { createFlashMessage } from '../../components/Flash/redux';
|
||||
import { postResetProgress, postDeleteAccount } from '../../utils/ajax';
|
||||
import { actionTypes as appTypes } from '../action-types';
|
||||
import { deleteAccountError, resetProgressError } from './';
|
||||
|
||||
function* deleteAccountSaga() {
|
||||
try {
|
||||
|
@@ -1,11 +1,10 @@
|
||||
import { createAction, handleActions } from 'redux-actions';
|
||||
|
||||
import { createTypes, createAsyncTypes } from '../../utils/create-types';
|
||||
import { actionTypes as types, ns } from './action-types';
|
||||
import { createDangerZoneSaga } from './danger-zone-saga';
|
||||
import { createSettingsSagas } from './settings-sagas';
|
||||
import { createUpdateMyEmailSaga } from './update-email-saga';
|
||||
|
||||
export const ns = 'settings';
|
||||
export { ns };
|
||||
|
||||
const defaultFetchState = {
|
||||
pending: false,
|
||||
@@ -21,21 +20,6 @@ const initialState = {
|
||||
}
|
||||
};
|
||||
|
||||
export const types = createTypes(
|
||||
[
|
||||
...createAsyncTypes('validateUsername'),
|
||||
...createAsyncTypes('submitNewAbout'),
|
||||
...createAsyncTypes('submitNewUsername'),
|
||||
...createAsyncTypes('updateMyEmail'),
|
||||
...createAsyncTypes('updateUserFlag'),
|
||||
...createAsyncTypes('submitProfileUI'),
|
||||
...createAsyncTypes('verifyCert'),
|
||||
...createAsyncTypes('resetProgress'),
|
||||
...createAsyncTypes('deleteAccount')
|
||||
],
|
||||
ns
|
||||
);
|
||||
|
||||
export const sagas = [
|
||||
...createSettingsSagas(types),
|
||||
...createUpdateMyEmailSaga(types),
|
||||
|
@@ -1,5 +1,14 @@
|
||||
import { call, delay, put, takeLatest, takeEvery } from 'redux-saga/effects';
|
||||
|
||||
import { createFlashMessage } from '../../components/Flash/redux';
|
||||
import {
|
||||
getUsernameExists,
|
||||
putUpdateMyAbout,
|
||||
putUpdateMyProfileUI,
|
||||
putUpdateMyUsername,
|
||||
putUpdateUserFlag,
|
||||
putVerifyCert
|
||||
} from '../../utils/ajax';
|
||||
import {
|
||||
updateUserFlagComplete,
|
||||
updateUserFlagError,
|
||||
@@ -14,15 +23,6 @@ import {
|
||||
verifyCertComplete,
|
||||
verifyCertError
|
||||
} from './';
|
||||
import {
|
||||
getUsernameExists,
|
||||
putUpdateMyAbout,
|
||||
putUpdateMyProfileUI,
|
||||
putUpdateMyUsername,
|
||||
putUpdateUserFlag,
|
||||
putVerifyCert
|
||||
} from '../../utils/ajax';
|
||||
import { createFlashMessage } from '../../components/Flash/redux';
|
||||
|
||||
function* submitNewAboutSaga({ payload }) {
|
||||
try {
|
||||
|
@@ -1,11 +1,11 @@
|
||||
import { call, put, takeEvery } from 'redux-saga/effects';
|
||||
import isEmail from 'validator/lib/isEmail';
|
||||
|
||||
import { updateMyEmailComplete, updateMyEmailError } from './';
|
||||
import { createFlashMessage } from '../../components/Flash/redux';
|
||||
|
||||
import { putUserUpdateEmail } from '../../utils/ajax';
|
||||
import reallyWeirdErrorMessage from '../../utils/really-weird-error-message';
|
||||
import { updateMyEmailComplete, updateMyEmailError } from './';
|
||||
|
||||
function* updateMyEmailSaga({ payload: email = '' }) {
|
||||
if (!email || !isEmail(email)) {
|
||||
|
@@ -1,5 +1,5 @@
|
||||
import { put, takeEvery, call } from 'redux-saga/effects';
|
||||
import { navigate } from 'gatsby';
|
||||
import { put, takeEvery, call } from 'redux-saga/effects';
|
||||
|
||||
import { createFlashMessage } from '../components/Flash/redux';
|
||||
import { getShowCert } from '../utils/ajax';
|
||||
|
@@ -1,7 +1,8 @@
|
||||
import { ofType } from 'redux-observable';
|
||||
import { mapTo, filter } from 'rxjs/operators';
|
||||
|
||||
import { types, onlineStatusChange, isOnlineSelector } from './';
|
||||
import { actionTypes as types } from './action-types';
|
||||
import { onlineStatusChange, isOnlineSelector } from './';
|
||||
|
||||
export default function updateCompleteEpic(action$, state$) {
|
||||
return action$.pipe(
|
||||
|
Reference in New Issue
Block a user