Skip to content

Commit b936b4c

Browse files
update UI after challenge is assigned to self
1 parent 3f32ca6 commit b936b4c

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

src/components/ChallengeEditor/ChallengeView/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ const ChallengeView = ({
7676
const reviewerFromResources = reviewerResource ? reviewerResource.memberHandle : ''
7777
let copilot, reviewer
7878
if (challenge) {
79-
copilot = challenge.copilot
79+
copilot = challenge.copilot || (challenge.legacy && challenge.legacy.selfServiceCopilot)
8080
reviewer = challenge.reviewer
8181
}
8282
copilot = copilot || copilotFromResources

src/components/ChallengeEditor/Copilot-Field/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const CopilotField = ({ copilots, challenge, onUpdateOthers, readOnly, assignYou
2020
</div>
2121
{(selectedCopilot || selfService) && (<div className={cn(styles.field, styles.col2)}>
2222
{(selectedCopilot && <CopilotCard copilot={selectedCopilot} selectedCopilot='' key={selectedCopilot.handle} />)}
23-
{(selfService && <PrimaryButton
23+
{(selfService && !selectedCopilot && <PrimaryButton
2424
text={'Assign Yourself'}
2525
type={'info'}
2626
onClick={assignYourselfCopilot}

src/containers/ChallengeEditor/index.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,14 @@ class ChallengeEditor extends Component {
322322
async assignYourselfCopilot () {
323323
const { challengeDetails, loggedInUser, metadata, createResource } = this.props
324324
const copilotRole = getResourceRoleByName(metadata.resourceRoles, 'Copilot')
325-
createResource(challengeDetails.id, copilotRole.id, loggedInUser.handle)
325+
const copilotHandle = loggedInUser.handle
326+
await createResource(challengeDetails.id, copilotRole.id, copilotHandle)
327+
const updatedChallenge = await patchChallenge(challengeDetails.id, {
328+
legacy: {
329+
selfServiceCopilot: copilotHandle
330+
}
331+
})
332+
this.setState({ challengeDetails: updatedChallenge })
326333
}
327334

328335
showRejectChallengeModal () {

0 commit comments

Comments
 (0)