Skip to content
This repository was archived by the owner on Mar 7, 2024. It is now read-only.

Commit 32a7ba0

Browse files
authored
Remove challenge section from application form (#155)
1 parent 8f0b290 commit 32a7ba0

File tree

2 files changed

+39
-172
lines changed

2 files changed

+39
-172
lines changed

package-lock.json

Lines changed: 36 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/views/pages/ApplicationsView/ApplicationSteps.js

Lines changed: 3 additions & 169 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,7 @@ const useStyles = makeStyles(theme => ({
3939
function getSteps() {
4040
return [
4141
'Profile Information',
42-
'Education Information',
43-
'Application Challenge'
42+
'Education Information'
4443
];
4544
}
4645

@@ -73,16 +72,6 @@ function getStepContent(
7372
applicationId={applicationId}
7473
/>
7574
);
76-
case 2:
77-
return (
78-
<FormChallenge
79-
setActiveStep={setActiveStep}
80-
data={formData}
81-
setData={setFormData}
82-
baseUrl={baseUrl}
83-
applicationId={applicationId}
84-
/>
85-
);
8675
default:
8776
return 'Unknown step';
8877
}
@@ -118,7 +107,7 @@ export function ApplicationSteps({ applicationId, setCourseTitle }) {
118107
.catch(e => {
119108
enqueueSnackbar('Failed with error. Try again later.');
120109
});
121-
setActiveStep(4);
110+
setActiveStep(3);
122111
};
123112

124113
const getApplication = useCallback(() => {
@@ -129,7 +118,7 @@ export function ApplicationSteps({ applicationId, setCourseTitle }) {
129118

130119
if (isMountedRef.current) {
131120
if (response.data.submitted) {
132-
setActiveStep(4);
121+
setActiveStep(3);
133122
enqueueSnackbar(
134123
'You application in submitted. We will contact you back with result.'
135124
);
@@ -420,158 +409,3 @@ function FormEducationInfo({
420409
</ValidatorForm>
421410
);
422411
}
423-
424-
function FormChallenge({
425-
setActiveStep,
426-
data,
427-
setData,
428-
baseUrl,
429-
applicationId
430-
}) {
431-
const classes = useStyles();
432-
const [formData, updateFormData] = useState(data.challenge);
433-
const MIN_CHAR = 150;
434-
435-
const handleChange = event => {
436-
updateFormData({
437-
...formData,
438-
[event.target.name]: event.target.value
439-
});
440-
};
441-
442-
const handlePrev = () => {
443-
setActiveStep(1);
444-
};
445-
446-
const handleSubmit = e => {
447-
e.preventDefault();
448-
setData({
449-
...data,
450-
challenge: formData
451-
});
452-
453-
const url = `${baseUrl}/${applicationId}/challenge`;
454-
455-
axios({
456-
method: 'put',
457-
url: url,
458-
data: formData
459-
})
460-
.then(response => {})
461-
.catch(e => {});
462-
setActiveStep(3);
463-
};
464-
465-
const countChar = string => string.replace(/\s/g, '').length;
466-
467-
useEffect(() => {
468-
ValidatorForm.addValidationRule('isNotShort', value => {
469-
if (countChar(value) < MIN_CHAR) {
470-
return false;
471-
}
472-
return true;
473-
});
474-
});
475-
476-
return (
477-
<ValidatorForm onSubmit={handleSubmit}>
478-
<TextValidator
479-
className={classes.textField}
480-
multiline
481-
fullWidth
482-
label="Why do you wish to take up this course?"
483-
variant="outlined"
484-
onChange={handleChange}
485-
name="q1"
486-
value={formData.q1}
487-
rows={4}
488-
validators={['required', 'isNotShort']}
489-
errorMessages={[
490-
'This is a required field',
491-
`Text too short.
492-
${
493-
formData.q1 && formData.q1.length
494-
? 'Put in ' +
495-
(MIN_CHAR - countChar(formData.q1)) +
496-
`${
497-
countChar(formData.q1) < MIN_CHAR - 1
498-
? ' characters more'
499-
: ' character more'
500-
}`
501-
: `Put in ${MIN_CHAR} characters more`
502-
}`
503-
]}
504-
/>
505-
506-
<TextValidator
507-
className={classes.textField}
508-
multiline
509-
fullWidth
510-
label="Why do you deserve this scholarship?"
511-
variant="outlined"
512-
onChange={handleChange}
513-
name="q2"
514-
value={formData.q2}
515-
rows={4}
516-
validators={['required', 'isNotShort']}
517-
errorMessages={[
518-
'This is a required field',
519-
`Text too short.
520-
${
521-
formData.q2 && formData.q2.length
522-
? 'Put in ' +
523-
(MIN_CHAR - countChar(formData.q2)) +
524-
`${
525-
countChar(formData.q2) < MIN_CHAR - 1
526-
? ' characters more'
527-
: ' character more'
528-
}`
529-
: `Put in ${MIN_CHAR} characters more`
530-
}`
531-
]}
532-
/>
533-
534-
<TextValidator
535-
className={classes.textField}
536-
multiline
537-
fullWidth
538-
label="What is your viewpoint towards Coding for a Cause?"
539-
variant="outlined"
540-
onChange={handleChange}
541-
name="q3"
542-
value={formData.q3}
543-
rows={4}
544-
validators={['required', 'isNotShort']}
545-
errorMessages={[
546-
'This is a required field',
547-
`Text too short.
548-
${
549-
formData.q3 && formData.q3.length
550-
? 'Put in ' +
551-
(MIN_CHAR - countChar(formData.q3)) +
552-
`${
553-
countChar(formData.q3) < MIN_CHAR - 1
554-
? ' characters more'
555-
: ' character more'
556-
}`
557-
: `Put in ${MIN_CHAR} characters more`
558-
}`
559-
]}
560-
/>
561-
562-
<Button variant="outlined" onClick={handlePrev} color="secondary">
563-
Prev
564-
</Button>
565-
<Button
566-
type="submit"
567-
variant="contained"
568-
color="secondary"
569-
style={{
570-
marginLeft: '16px'
571-
}}
572-
>
573-
Save
574-
</Button>
575-
</ValidatorForm>
576-
);
577-
}

0 commit comments

Comments
 (0)