added selectors and template saga for updating legacy certificates
This commit is contained in:
committed by
Mrugesh Mohapatra
parent
3fc42b1ea8
commit
68854db61e
@ -1,5 +1,7 @@
|
||||
import React, { Component } from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { bindActionCreators } from 'redux';
|
||||
import { connect } from 'react-redux';
|
||||
import { find, first } from 'lodash';
|
||||
import {
|
||||
Table,
|
||||
@ -11,6 +13,7 @@ import {
|
||||
import { Link, navigate } from 'gatsby';
|
||||
import { createSelector } from 'reselect';
|
||||
|
||||
import { updateLegacyCertificate } from '../../redux/settings';
|
||||
import { projectMap, legacyProjectMap } from '../../resources/certProjectMap';
|
||||
|
||||
import SectionHeader from './SectionHeader';
|
||||
@ -22,6 +25,9 @@ import { maybeUrlRE } from '../../utils';
|
||||
|
||||
import './certification.css';
|
||||
|
||||
const mapDispatchToProps = dispatch =>
|
||||
bindActionCreators({ updateLegacyCertificate }, dispatch);
|
||||
|
||||
const propTypes = {
|
||||
completedChallenges: PropTypes.arrayOf(
|
||||
PropTypes.shape({
|
||||
@ -45,6 +51,7 @@ const propTypes = {
|
||||
isInfosecQaCert: PropTypes.bool,
|
||||
isJsAlgoDataStructCert: PropTypes.bool,
|
||||
isRespWebDesignCert: PropTypes.bool,
|
||||
updateLegacyCertificate: PropTypes.func.isRequired,
|
||||
username: PropTypes.string,
|
||||
verifyCert: PropTypes.func.isRequired
|
||||
};
|
||||
@ -279,7 +286,8 @@ class CertificationSettings extends Component {
|
||||
// legacy projects rendering
|
||||
|
||||
handleSubmit(values) {
|
||||
console.log(values);
|
||||
const { updateLegacyCertificate } = this.props;
|
||||
updateLegacyCertificate(values);
|
||||
}
|
||||
|
||||
renderLegacyCertifications = certName => {
|
||||
@ -405,4 +413,7 @@ class CertificationSettings extends Component {
|
||||
CertificationSettings.displayName = 'CertificationSettings';
|
||||
CertificationSettings.propTypes = propTypes;
|
||||
|
||||
export default CertificationSettings;
|
||||
export default connect(
|
||||
null,
|
||||
mapDispatchToProps
|
||||
)(CertificationSettings);
|
||||
|
@ -5,6 +5,10 @@ import { createDangerZoneSaga } from './danger-zone-saga';
|
||||
import { createSettingsSagas } from './settings-sagas';
|
||||
import { createUpdateMyEmailSaga } from './update-email-saga';
|
||||
|
||||
// prettier-ignore
|
||||
import { createUpdateLegacyCertificateSaga } from
|
||||
'./update-legacy-certificate-saga';
|
||||
|
||||
export const ns = 'settings';
|
||||
|
||||
const defaultFetchState = {
|
||||
@ -27,6 +31,7 @@ export const types = createTypes(
|
||||
...createAsyncTypes('submitNewAbout'),
|
||||
...createAsyncTypes('submitNewUsername'),
|
||||
...createAsyncTypes('updateMyEmail'),
|
||||
...createAsyncTypes('updateLegacyCertificate'),
|
||||
...createAsyncTypes('updateUserFlag'),
|
||||
...createAsyncTypes('submitProfileUI'),
|
||||
...createAsyncTypes('verifyCert'),
|
||||
@ -39,7 +44,8 @@ export const types = createTypes(
|
||||
export const sagas = [
|
||||
...createSettingsSagas(types),
|
||||
...createUpdateMyEmailSaga(types),
|
||||
...createDangerZoneSaga(types)
|
||||
...createDangerZoneSaga(types),
|
||||
...createUpdateLegacyCertificateSaga(types)
|
||||
];
|
||||
|
||||
const checkForSuccessPayload = ({ type, payload }) =>
|
||||
@ -72,6 +78,16 @@ export const updateMyEmail = createAction(types.updateMyEmail);
|
||||
export const updateMyEmailComplete = createAction(types.updateMyEmailComplete);
|
||||
export const updateMyEmailError = createAction(types.updateMyEmailError);
|
||||
|
||||
export const updateLegacyCertificate = createAction(
|
||||
types.updateLegacyCertificate
|
||||
);
|
||||
export const updateLegacyCertificateComplete = createAction(
|
||||
types.updateLegacyCertificateComplete
|
||||
);
|
||||
export const updateLegacyCertificateError = createAction(
|
||||
types.updateLegacyCertificateError
|
||||
);
|
||||
|
||||
export const updateUserFlag = createAction(types.updateUserFlag);
|
||||
export const updateUserFlagComplete = createAction(
|
||||
types.updateUserFlagComplete,
|
||||
|
36
client/src/redux/settings/update-legacy-certificate-saga.js
Normal file
36
client/src/redux/settings/update-legacy-certificate-saga.js
Normal file
@ -0,0 +1,36 @@
|
||||
import { takeEvery } from 'redux-saga/effects';
|
||||
|
||||
// import {
|
||||
// updateLegacyCertificateComplete,
|
||||
// updateLegacyCertificateError
|
||||
// } from './';
|
||||
// import { createFlashMessage } from '../../components/Flash/redux';
|
||||
|
||||
// import { putUserUpdateEmail } from '../../utils/ajax';
|
||||
// import reallyWeirdErrorMessage from '../../utils/reallyWeirdErrorMessage';
|
||||
|
||||
function* updateLegacyCertificateSaga(values) {
|
||||
console.log(values);
|
||||
/* if (!email || !isEmail(email)) {
|
||||
yield put(createFlashMessage(reallyWeirdErrorMessage));
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const { data: response } = yield call(putUserUpdateEmail, email);
|
||||
yield put(
|
||||
updateMyEmailComplete({
|
||||
...response,
|
||||
payload: { email, isEmailVerified: false }
|
||||
})
|
||||
);
|
||||
yield put(createFlashMessage(response));
|
||||
} catch (e) {
|
||||
yield put(updateMyEmailError(e));
|
||||
}*/
|
||||
}
|
||||
|
||||
export function createUpdateLegacyCertificateSaga(types) {
|
||||
return [
|
||||
takeEvery(types.updateLegacyCertificate, updateLegacyCertificateSaga)
|
||||
];
|
||||
}
|
Reference in New Issue
Block a user