fix: add backend placeholder to solution form (#39494)
This commit is contained in:
@ -3,6 +3,7 @@ import PropTypes from 'prop-types';
|
|||||||
|
|
||||||
import { Form } from '../../../components/formHelpers';
|
import { Form } from '../../../components/formHelpers';
|
||||||
import {
|
import {
|
||||||
|
backend,
|
||||||
backEndProject,
|
backEndProject,
|
||||||
frontEndProject,
|
frontEndProject,
|
||||||
pythonProject
|
pythonProject
|
||||||
@ -16,15 +17,16 @@ const propTypes = {
|
|||||||
updateSolutionForm: PropTypes.func.isRequired
|
updateSolutionForm: PropTypes.func.isRequired
|
||||||
};
|
};
|
||||||
|
|
||||||
const frontEndProjectFields = ['solution'];
|
// back end challenges and front end projects use a single form field
|
||||||
const backEndProjectFields = ['solution', 'githubLink'];
|
const solutionField = ['solutionLink'];
|
||||||
|
const backEndProjectFields = ['solutionLink', 'githubLink'];
|
||||||
|
|
||||||
const options = {
|
const options = {
|
||||||
types: {
|
types: {
|
||||||
solution: 'url',
|
solutionLink: 'url',
|
||||||
githubLink: 'url'
|
githubLink: 'url'
|
||||||
},
|
},
|
||||||
required: ['solution']
|
required: ['solutionLink']
|
||||||
};
|
};
|
||||||
|
|
||||||
export class SolutionForm extends Component {
|
export class SolutionForm extends Component {
|
||||||
@ -45,25 +47,30 @@ export class SolutionForm extends Component {
|
|||||||
? 'Submit and go to my next challenge'
|
? 'Submit and go to my next challenge'
|
||||||
: "I've completed this challenge";
|
: "I've completed this challenge";
|
||||||
|
|
||||||
let solutionFormFields = frontEndProjectFields;
|
let formFields = solutionField;
|
||||||
let solutionLink = 'Link, ex: ';
|
let solutionLink = 'ex: ';
|
||||||
let solutionFormID = 'front-end-form';
|
let solutionFormID = 'front-end-form';
|
||||||
|
|
||||||
switch (challengeType) {
|
switch (challengeType) {
|
||||||
case frontEndProject:
|
case frontEndProject:
|
||||||
solutionFormFields = frontEndProjectFields;
|
formFields = solutionField;
|
||||||
solutionLink =
|
solutionLink =
|
||||||
solutionLink + 'https://codepen.io/camperbot/full/oNvPqqo';
|
solutionLink + 'https://codepen.io/camperbot/full/oNvPqqo';
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case backend:
|
||||||
|
formFields = solutionField;
|
||||||
|
solutionLink = solutionLink + 'https://project-name.camperbot.repl.co/';
|
||||||
|
break;
|
||||||
|
|
||||||
case backEndProject:
|
case backEndProject:
|
||||||
solutionFormFields = backEndProjectFields;
|
formFields = backEndProjectFields;
|
||||||
solutionLink = solutionLink + 'https://project-name.camperbot.repl.co/';
|
solutionLink = solutionLink + 'https://project-name.camperbot.repl.co/';
|
||||||
solutionFormID = 'back-end-form';
|
solutionFormID = 'back-end-form';
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case pythonProject:
|
case pythonProject:
|
||||||
solutionFormFields = frontEndProjectFields;
|
formFields = solutionField;
|
||||||
solutionLink =
|
solutionLink =
|
||||||
solutionLink +
|
solutionLink +
|
||||||
(description.includes('Colaboratory')
|
(description.includes('Colaboratory')
|
||||||
@ -72,7 +79,7 @@ export class SolutionForm extends Component {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
solutionFormFields = frontEndProjectFields;
|
formFields = solutionField;
|
||||||
solutionLink =
|
solutionLink =
|
||||||
solutionLink + 'https://codepen.io/camperbot/full/oNvPqqo';
|
solutionLink + 'https://codepen.io/camperbot/full/oNvPqqo';
|
||||||
}
|
}
|
||||||
@ -80,12 +87,12 @@ export class SolutionForm extends Component {
|
|||||||
return (
|
return (
|
||||||
<Form
|
<Form
|
||||||
buttonText={`${buttonCopy}`}
|
buttonText={`${buttonCopy}`}
|
||||||
formFields={solutionFormFields}
|
formFields={formFields}
|
||||||
id={solutionFormID}
|
id={solutionFormID}
|
||||||
options={{
|
options={{
|
||||||
...options,
|
...options,
|
||||||
placeholders: {
|
placeholders: {
|
||||||
solution: solutionLink,
|
solutionLink: solutionLink,
|
||||||
githubLink: 'ex: https://github.com/camperbot/hello'
|
githubLink: 'ex: https://github.com/camperbot/hello'
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
|
Reference in New Issue
Block a user