Skip to content

Commit

Permalink
Revert "Create linked learners when assigning codes (#506)" (#508)
Browse files Browse the repository at this point in the history
This reverts commit 37e853f.
  • Loading branch information
Lael Birch authored Mar 19, 2021
1 parent 37e853f commit e59f370
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 95 deletions.
27 changes: 4 additions & 23 deletions src/components/CodeAssignmentModal/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -310,10 +310,8 @@ class BaseCodeAssignmentModal extends React.Component {
hasAllCodesSelected,
},
sendCodeAssignment,
createPendingEnterpriseUsers,
enableLearnerPortal,
enterpriseSlug,
enterpriseUuid,
} = this.props;

this.setMode('assign');
Expand All @@ -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.
Expand All @@ -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);
})
Expand Down Expand Up @@ -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
Expand All @@ -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({
Expand Down
11 changes: 0 additions & 11 deletions src/containers/CodeAssignmentModal/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand All @@ -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,
};
};

Expand All @@ -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)),
});

Expand Down
46 changes: 0 additions & 46 deletions src/data/actions/createPendingEnterpriseUsers.js

This file was deleted.

9 changes: 0 additions & 9 deletions src/data/constants/createPendingEntUser.js

This file was deleted.

6 changes: 0 additions & 6 deletions src/data/services/LmsApiService.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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;

0 comments on commit e59f370

Please sign in to comment.