diff --git a/src/components/CodeAssignmentModal/index.jsx b/src/components/CodeAssignmentModal/index.jsx index d2a8e199ab..b59e3cc7f2 100644 --- a/src/components/CodeAssignmentModal/index.jsx +++ b/src/components/CodeAssignmentModal/index.jsx @@ -310,10 +310,8 @@ class BaseCodeAssignmentModal extends React.Component { hasAllCodesSelected, }, sendCodeAssignment, - createPendingEnterpriseUsers, enableLearnerPortal, enterpriseSlug, - enterpriseUuid, } = this.props; this.setMode('assign'); @@ -338,11 +336,10 @@ class BaseCodeAssignmentModal extends React.Component { options.template_id = formData['template-id']; } - const hasTextAreaEmails = !!formData[EMAIL_ADDRESS_TEXT_FORM_DATA]; - const emails = hasTextAreaEmails ? formData[EMAIL_ADDRESS_TEXT_FORM_DATA].split(/\r\n|\n/) : formData[EMAIL_ADDRESS_CSV_FORM_DATA]; - const { validEmails } = this.validateEmailAddresses(emails, !hasTextAreaEmails); - if (isBulkAssign) { + const hasTextAreaEmails = !!formData[EMAIL_ADDRESS_TEXT_FORM_DATA]; + const emails = hasTextAreaEmails ? formData[EMAIL_ADDRESS_TEXT_FORM_DATA].split(/\r\n|\n/) : formData[EMAIL_ADDRESS_CSV_FORM_DATA]; + const { validEmails } = this.validateEmailAddresses(emails, !hasTextAreaEmails); options.emails = validEmails; // Only includes `codes` in `options` if not all codes are selected. @@ -354,21 +351,7 @@ class BaseCodeAssignmentModal extends React.Component { options.codes = [code.code]; } - let pendingEnterpriseUserData; - if (hasTextAreaEmails) { - pendingEnterpriseUserData = validEmails.map((email) => ({ - user_email: email, - enterprise_customer: enterpriseUuid, - })); - } else { - pendingEnterpriseUserData = { - user_email: formData['email-address'], - enterprise_customer: enterpriseUuid, - }; - } - - return createPendingEnterpriseUsers(pendingEnterpriseUserData) - .then(() => sendCodeAssignment(couponId, options)) + return sendCodeAssignment(couponId, options) .then((response) => { this.props.onSuccess(response); }) @@ -564,7 +547,6 @@ BaseCodeAssignmentModal.defaultProps = { BaseCodeAssignmentModal.propTypes = { // props from redux enterpriseSlug: PropTypes.string.isRequired, - enterpriseUuid: PropTypes.string.isRequired, currentEmail: PropTypes.string, enableLearnerPortal: PropTypes.bool.isRequired, // props From redux-form @@ -580,7 +562,6 @@ BaseCodeAssignmentModal.propTypes = { onClose: PropTypes.func.isRequired, onSuccess: PropTypes.func.isRequired, sendCodeAssignment: PropTypes.func.isRequired, - createPendingEnterpriseUsers: PropTypes.func.isRequired, setEmailAddress: PropTypes.func.isRequired, couponDetailsTable: PropTypes.shape({ data: PropTypes.shape({ diff --git a/src/containers/CodeAssignmentModal/index.jsx b/src/containers/CodeAssignmentModal/index.jsx index c991be1ffd..2fac4094bb 100644 --- a/src/containers/CodeAssignmentModal/index.jsx +++ b/src/containers/CodeAssignmentModal/index.jsx @@ -3,7 +3,6 @@ import { connect } from 'react-redux'; import CodeAssignmentModal from '../../components/CodeAssignmentModal'; import sendCodeAssignment from '../../data/actions/codeAssignment'; -import createPendingEnterpriseUsers from '../../data/actions/createPendingEnterpriseUsers'; import { EMAIL_TEMPLATE_SOURCE_NEW_EMAIL } from '../../data/constants/emailTemplate'; import { setEmailAddress } from '../../data/actions/emailTemplate'; @@ -19,9 +18,6 @@ const mapStateToProps = (state) => { couponDetailsTable: state.table['coupon-details'], initialValues, enableReinitialize: true, - enterpriseSlug: state.portalConfiguration.enterpriseSlug, - enterpriseUuid: state.portalConfiguration.enterpriseId, - enableLearnerPortal: state.portalConfiguration.enableLearnerPortal, }; }; @@ -34,13 +30,6 @@ const mapDispatchToProps = dispatch => ({ onError: (error) => { reject(error); }, })); }), - createPendingEnterpriseUsers: (users) => new Promise((resolve, reject) => { - dispatch(createPendingEnterpriseUsers({ - users, - onSuccess: (response) => { resolve(response); }, - onError: (error) => { reject(error); }, - })); - }), setEmailAddress: (emailAddress, emailType) => dispatch(setEmailAddress(emailAddress, emailType)), }); diff --git a/src/data/actions/createPendingEnterpriseUsers.js b/src/data/actions/createPendingEnterpriseUsers.js deleted file mode 100644 index 4049a8067f..0000000000 --- a/src/data/actions/createPendingEnterpriseUsers.js +++ /dev/null @@ -1,46 +0,0 @@ -import { - PENDING_ENT_USER_REQUEST, - PENDING_ENT_USER_SUCCESS, - PENDING_ENT_USER_FAILURE, -} from '../constants/createPendingEntUser'; - -import LmsApiService from '../services/LmsApiService'; - -const createPendingUsersRequest = () => ({ - type: PENDING_ENT_USER_REQUEST, -}); - -const createPendingUsersSuccess = data => ({ - type: PENDING_ENT_USER_SUCCESS, - payload: { - data, - }, -}); - -const createPendingUsersFailure = error => ({ - type: PENDING_ENT_USER_FAILURE, - payload: { - error, - }, -}); - -const createPendingEnterpriseUsers = ({ - users, - onSuccess = () => {}, - onError = () => {}, -}) => ( - (dispatch) => { - dispatch(createPendingUsersRequest()); - return LmsApiService.createPendingEnterpriseUsers(users) - .then((response) => { - dispatch(createPendingUsersSuccess(response.data)); - onSuccess(response.data); - }) - .catch((error) => { - dispatch(createPendingUsersFailure(error)); - onError(error); - }); - } -); - -export default createPendingEnterpriseUsers; diff --git a/src/data/constants/createPendingEntUser.js b/src/data/constants/createPendingEntUser.js deleted file mode 100644 index ca50486b01..0000000000 --- a/src/data/constants/createPendingEntUser.js +++ /dev/null @@ -1,9 +0,0 @@ -const PENDING_ENT_USER_REQUEST = 'PENDING_ENT_USER_REQUEST'; -const PENDING_ENT_USER_SUCCESS = 'PENDING_ENT_USER_SUCCESS'; -const PENDING_ENT_USER_FAILURE = 'PENDING_ENT_USER_FAILURE'; - -export { - PENDING_ENT_USER_REQUEST, - PENDING_ENT_USER_SUCCESS, - PENDING_ENT_USER_FAILURE, -}; diff --git a/src/data/services/LmsApiService.js b/src/data/services/LmsApiService.js index 66c1a91ab9..a0f0c37a5e 100644 --- a/src/data/services/LmsApiService.js +++ b/src/data/services/LmsApiService.js @@ -18,8 +18,6 @@ class LmsApiService { static lmsIntegrationUrl = `${LmsApiService.baseUrl}/integrated_channels/api/v1`; - static createPendingUsersUrl = `${LmsApiService.baseUrl}/enterprise/api/v1/pending-enterprise-learner/` - static fetchCourseOutline(courseId) { const options = { course_id: courseId, @@ -198,10 +196,6 @@ class LmsApiService { const url = `${LmsApiService.enterpriseCustomerUrl}${enterpriseId}/enterprise_learners/`; return LmsApiService.apiClient().post(url, options); } - - static createPendingEnterpriseUsers(formData) { - return LmsApiService.apiClient().post(LmsApiService.createPendingUsersUrl, formData); - } } export default LmsApiService;