fix(projectCopmletion): Open completion modal for Project submission

This commit is contained in:
Stuart Taylor
2018-02-28 10:06:50 +00:00
parent 6cf3fb6049
commit 6a163bae88
6 changed files with 91 additions and 40 deletions

View File

@@ -3,11 +3,14 @@ import { ofType } from 'redux-epic';
import {
backendFormValuesSelector,
frontendProjectFormValuesSelector,
backendProjectFormValuesSelector,
challengeMetaSelector,
moveToNextChallenge,
submitChallengeComplete,
testsSelector,
types
types,
closeChallengeModal
} from './';
import {
@@ -69,7 +72,18 @@ function submitModern(type, state) {
);
}
function submitProject(type, state, { solution, githubLink }) {
function submitProject(type, state) {
if (type === types.checkChallenge) {
return Observable.empty();
}
const {
solution: frontEndSolution = ''
} = frontendProjectFormValuesSelector(state);
const {
solution: backendSolution = '',
githubLink = ''
} = backendProjectFormValuesSelector(state);
const solution = frontEndSolution ? frontEndSolution : backendSolution;
const { id, challengeType } = challengeSelector(state);
const { username } = userSelector(state);
const csrfToken = csrfSelector(state);
@@ -77,11 +91,16 @@ function submitProject(type, state, { solution, githubLink }) {
if (challengeType === backEndProject) {
challengeInfo.githubLink = githubLink;
}
return postChallenge(
'/project-completed',
username,
csrfToken,
challengeInfo
return Observable.merge(
postChallenge(
'/project-completed',
username,
csrfToken,
challengeInfo
),
Observable.of(
closeChallengeModal()
)
);
}