forked from openedx/edx-platform
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add entitlement support creation and reissue
Learner-3925
- Loading branch information
1 parent
187e39f
commit 10be8bc
Showing
21 changed files
with
419 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
...angoapps/support/static/support/jsx/entitlements/components/EntitlementForm/container.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { connect } from 'react-redux'; | ||
|
||
import { createEntitlement, reissueEntitlement } from '../../data/actions/entitlement'; | ||
import { closeForm } from '../../data/actions/form'; | ||
|
||
import EntitlementForm from './index.jsx'; | ||
|
||
const mapStateToProps = state => ({ | ||
formType: state.form.formType, | ||
isOpen: state.form.isOpen, | ||
entitlement: state.form.activeEntitlement, | ||
}); | ||
|
||
const mapDispatchToProps = dispatch => ({ | ||
createEntitlement: ({ username, courseUuid, mode, comments }) => | ||
dispatch(createEntitlement({ username, courseUuid, mode, comments })), | ||
reissueEntitlement: ({ entitlement, comments }) => | ||
dispatch(reissueEntitlement({ entitlement, comments })), | ||
closeForm: () => dispatch(closeForm()), | ||
}); | ||
|
||
const EntitlementFormContainer = connect( | ||
mapStateToProps, | ||
mapDispatchToProps, | ||
)(EntitlementForm); | ||
|
||
export default EntitlementFormContainer; |
163 changes: 163 additions & 0 deletions
163
lms/djangoapps/support/static/support/jsx/entitlements/components/EntitlementForm/index.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,163 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
|
||
import { Button, InputSelect, InputText, TextArea } from '@edx/paragon'; | ||
import { formTypes } from '../../data/constants/formTypes'; | ||
|
||
class EntitlementForm extends React.Component { | ||
constructor(props) { | ||
super(props); | ||
|
||
if (props.formType === formTypes.REISSUE) { | ||
const { courseUuid, mode, user } = props.entitlement; | ||
this.state = { | ||
courseUuid, | ||
mode, | ||
username: user, | ||
comments: '', | ||
}; | ||
} else { | ||
this.state = { | ||
courseUuid: '', | ||
mode: '', | ||
username: '', | ||
comments: '', | ||
}; | ||
} | ||
|
||
this.onClose = this.onClose.bind(this); | ||
this.handleCourseUUIDChange = this.handleCourseUUIDChange.bind(this); | ||
this.handleUsernameChange = this.handleUsernameChange.bind(this); | ||
this.handleModeChange = this.handleModeChange.bind(this); | ||
this.handleCommentsChange = this.handleCommentsChange.bind(this); | ||
this.submitForm = this.submitForm.bind(this); | ||
} | ||
|
||
onClose() { | ||
this.props.closeForm(); | ||
} | ||
|
||
handleCourseUUIDChange(courseUuid) { | ||
this.setState({ courseUuid }); | ||
} | ||
|
||
handleUsernameChange(username) { | ||
this.setState({ username }); | ||
} | ||
|
||
handleModeChange(mode) { | ||
this.setState({ mode }); | ||
} | ||
|
||
handleCommentsChange(comments) { | ||
this.setState({ comments }); | ||
} | ||
|
||
submitForm() { | ||
const { courseUuid, username, mode, comments } = this.state; | ||
const { formType, entitlement } = this.props; | ||
if (formType === formTypes.REISSUE) { // if there is an active entitlement we are updating an entitlement | ||
this.props.reissueEntitlement({ entitlement, comments }); | ||
} else { // if there is no active entitlement we are creating a new entitlement | ||
this.props.createEntitlement({ courseUuid, username, mode, comments }); | ||
} | ||
} | ||
|
||
render() { | ||
const { courseUuid, username, mode, comments } = this.state; | ||
const isReissue = this.props.formType === formTypes.REISSUE; | ||
const title = isReissue ? 'Re-issue Entitlement' : 'Create Entitlement'; | ||
|
||
const body = ( | ||
<div> | ||
<h3> {title} </h3> | ||
<InputText | ||
disabled={isReissue} | ||
name="courseUuid" | ||
label="Course UUID" | ||
value={courseUuid} | ||
onChange={this.handleCourseUUIDChange} | ||
/> | ||
<InputText | ||
disabled={isReissue} | ||
name="username" | ||
label="Username" | ||
value={username} | ||
onChange={this.handleUsernameChange} | ||
/> | ||
<InputSelect | ||
disabled={isReissue} | ||
name="mode" | ||
label="Mode" | ||
value={mode} | ||
options={[ | ||
{ label: '--', value: '' }, | ||
{ label: 'Verified', value: 'verified' }, | ||
{ label: 'Professional', value: 'professional' }, | ||
]} | ||
onChange={this.handleModeChange} | ||
/> | ||
<TextArea | ||
name="comments" | ||
label="Comments" | ||
value={comments} | ||
onChange={this.handleCommentsChange} | ||
/> | ||
<div> | ||
<Button | ||
className={['btn', 'btn-secondary']} | ||
label="Close" | ||
onClick={this.onClose} | ||
/> | ||
<Button | ||
className={['btn', 'btn-primary']} | ||
label="Submit" | ||
onClick={this.submitForm} | ||
/> | ||
</div> | ||
</div> | ||
); | ||
|
||
return this.props.isOpen && body; | ||
} | ||
} | ||
|
||
EntitlementForm.propTypes = { | ||
formType: PropTypes.string.isRequired, | ||
isOpen: PropTypes.bool.isRequired, | ||
entitlement: PropTypes.shape({ | ||
uuid: PropTypes.string.isRequired, | ||
courseUuid: PropTypes.string.isRequired, | ||
created: PropTypes.string.isRequired, | ||
modified: PropTypes.string.isRequired, | ||
expiredAt: PropTypes.string, | ||
mode: PropTypes.string.isRequired, | ||
orderNumber: PropTypes.string, | ||
supportDetails: PropTypes.arrayOf(PropTypes.shape({ | ||
supportUser: PropTypes.string, | ||
action: PropTypes.string, | ||
comments: PropTypes.string, | ||
unenrolledRun: PropTypes.string, | ||
})), | ||
user: PropTypes.string.isRequired, | ||
}), | ||
createEntitlement: PropTypes.func.isRequired, | ||
reissueEntitlement: PropTypes.func.isRequired, | ||
closeForm: PropTypes.func.isRequired, | ||
}; | ||
|
||
EntitlementForm.defaultProps = { | ||
entitlement: { | ||
uuid:'', | ||
courseUuid: '', | ||
created: '', | ||
modified: '', | ||
expiredAt: '', | ||
mode: 'verified', | ||
orderNumber: '', | ||
supportDetails: [], | ||
user: '', | ||
} | ||
}; | ||
|
||
export default EntitlementForm; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
lms/djangoapps/support/static/support/jsx/entitlements/components/Main/MainContainer.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
...ort/static/support/jsx/entitlements/components/Table/EntitlementSupportTableContainer.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,19 @@ | ||
import { connect } from 'react-redux'; | ||
|
||
import { openReissueForm } from '../../data/actions/form'; | ||
import EntitlementSupportTable from './EntitlementSupportTable.jsx'; | ||
|
||
const mapStateToProps = state => ({ | ||
entitlements: state.entitlements, | ||
}); | ||
|
||
const mapDispatchToProps = dispatch => ({ | ||
openReissueForm: entitlement => dispatch(openReissueForm(entitlement)), | ||
}); | ||
|
||
const EntitlementSupportTableContainer = connect( | ||
mapStateToProps, | ||
mapDispatchToProps, | ||
)(EntitlementSupportTable); | ||
|
||
export default EntitlementSupportTableContainer; |
12 changes: 0 additions & 12 deletions
12
lms/djangoapps/support/static/support/jsx/entitlements/data/actions/constants.js
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.