feat(client,api): add user tokens and route for submitting coderoad tutorials (#43304)
Co-authored-by: Nicholas Carrigan (he/him) <nhcarrigan@gmail.com> Co-authored-by: Shaun Hamilton <shauhami020@gmail.com> Co-authored-by: Oliver Eyton-Williams <ojeytonwilliams@gmail.com>
This commit is contained in:
@@ -18,6 +18,7 @@ import { actionTypes as settingsTypes } from './settings/action-types';
|
||||
import { createShowCertSaga } from './show-cert-saga';
|
||||
import { createSoundModeSaga } from './sound-mode-saga';
|
||||
import updateCompleteEpic from './update-complete-epic';
|
||||
import { createWebhookSaga } from './webhook-saga';
|
||||
|
||||
export const MainApp = 'app';
|
||||
|
||||
@@ -75,7 +76,8 @@ export const sagas = [
|
||||
...createFetchUserSaga(actionTypes),
|
||||
...createShowCertSaga(actionTypes),
|
||||
...createReportUserSaga(actionTypes),
|
||||
...createSoundModeSaga({ ...actionTypes, ...settingsTypes })
|
||||
...createSoundModeSaga({ ...actionTypes, ...settingsTypes }),
|
||||
...createWebhookSaga(actionTypes)
|
||||
];
|
||||
|
||||
export const appMount = createAction(actionTypes.appMount);
|
||||
@@ -167,6 +169,15 @@ export const showCert = createAction(actionTypes.showCert);
|
||||
export const showCertComplete = createAction(actionTypes.showCertComplete);
|
||||
export const showCertError = createAction(actionTypes.showCertError);
|
||||
|
||||
export const postWebhookToken = createAction(actionTypes.postWebhookToken);
|
||||
export const postWebhookTokenComplete = createAction(
|
||||
actionTypes.postWebhookTokenComplete
|
||||
);
|
||||
export const deleteWebhookToken = createAction(actionTypes.deleteWebhookToken);
|
||||
export const deleteWebhookTokenComplete = createAction(
|
||||
actionTypes.deleteWebhookTokenComplete
|
||||
);
|
||||
|
||||
export const updateCurrentChallengeId = createAction(
|
||||
actionTypes.updateCurrentChallengeId
|
||||
);
|
||||
@@ -230,6 +241,10 @@ export const shouldRequestDonationSelector = state => {
|
||||
return completionCount >= 3;
|
||||
};
|
||||
|
||||
export const webhookTokenSelector = state => {
|
||||
return userSelector(state).webhookToken;
|
||||
};
|
||||
|
||||
export const userByNameSelector = username => state => {
|
||||
const { user } = state[MainApp];
|
||||
// return initial state empty user empty object instead of empty
|
||||
@@ -633,6 +648,32 @@ export const reducer = handleActions(
|
||||
}
|
||||
};
|
||||
},
|
||||
[actionTypes.postWebhookTokenComplete]: (state, { payload }) => {
|
||||
const { appUsername } = state;
|
||||
return {
|
||||
...state,
|
||||
user: {
|
||||
...state.user,
|
||||
[appUsername]: {
|
||||
...state.user[appUsername],
|
||||
webhookToken: payload
|
||||
}
|
||||
}
|
||||
};
|
||||
},
|
||||
[actionTypes.deleteWebhookTokenComplete]: state => {
|
||||
const { appUsername } = state;
|
||||
return {
|
||||
...state,
|
||||
user: {
|
||||
...state.user,
|
||||
[appUsername]: {
|
||||
...state.user[appUsername],
|
||||
webhookToken: null
|
||||
}
|
||||
}
|
||||
};
|
||||
},
|
||||
[challengeTypes.challengeMounted]: (state, { payload }) => ({
|
||||
...state,
|
||||
currentChallengeId: payload
|
||||
|
Reference in New Issue
Block a user