Skip to content

Commit

Permalink
fix: git#892-Thomas' Review of Process
Browse files Browse the repository at this point in the history
- Now validating the task assignment from the presence of Submitter resource instead of looking at `task.memberId` field as per the suggestions
feat: git#896-Remove copilot and copilot fee validation for a task close
  • Loading branch information
Vikas Agarwal committed Nov 10, 2020
1 parent 4cd7bc4 commit 55bc7bf
Showing 1 changed file with 5 additions and 15 deletions.
20 changes: 5 additions & 15 deletions src/components/ChallengeEditor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1031,6 +1031,7 @@ class ChallengeEditor extends Component {
return <div>Error loading challenge</div>
}
const isTask = _.get(challenge, 'task.isTask', false)
console.log(this.props.assignedMemberDetails)
const { assignedMemberDetails, error } = this.state
let isActive = false
let isDraft = false
Expand Down Expand Up @@ -1098,33 +1099,22 @@ class ChallengeEditor extends Component {
*/
if (isCloseTask && !isConfirm) {
const taskPrize = _.get(_.find(challenge.prizeSets, { type: 'placement' }), 'prizes[0].value')
const assignedMember = assignedMemberDetails ? assignedMemberDetails.handle : `User id: ${_.get(challenge, 'task.memberId')}`
const copilotFee = _.get(_.find(challenge.prizeSets, { type: 'copilot' }), 'prizes[0].value')
const copilot = challenge.copilot
const assignedMemberId = _.get(assignedMemberDetails, 'userId')
const assignedMember = _.get(assignedMemberDetails, 'handle', `User Id: ${assignedMemberId}`)

const validationErrors = []
if (!_.get(challenge, 'task.memberId')) {
if (!assignedMemberId) {
validationErrors.push('assign task member')
}

if (!copilot) {
validationErrors.push('select copilot')
}

if (!copilotFee) {
validationErrors.push('set copilot fee')
}

// if all data for closing task is there, show confirmation modal
if (validationErrors.length === 0) {
closeTaskModal = (
<ConfirmationModal
title='Close Task Confirmation'
message={
<p>
Are you sure want to close task <strong>"{challenge.name}"</strong> with the prize <strong>${taskPrize}</strong> for <strong>{assignedMember}</strong>
{' '}
and copilot fee <strong>${copilotFee}</strong> for <strong>{copilot}</strong>?
Are you sure want to close task <strong>"{challenge.name}"</strong> with the prize <strong>${taskPrize}</strong> for <strong>{assignedMember}</strong>?
</p>
}
theme={theme}
Expand Down

0 comments on commit 55bc7bf

Please sign in to comment.