@@ -6,6 +6,7 @@ import Textarea from '../../components/Textarea';
66import { applyForMentorship , getMyMentorshipApplication } from '../../../api' ;
77import ImageSrc from '../../../assets/mentorshipRequestSuccess.svg' ;
88import Body from './style' ;
9+ import { links } from '../../../config/constants' ;
910
1011const FormFields = styled . div `
1112 display: flex;
@@ -28,8 +29,6 @@ const ExtendedFormField = styled(FormField)`
2829
2930 & label {
3031 margin-top: 32px;
31- color: ${ props =>
32- props . invalid ? 'var(--form-text-invalid)' : 'var(--form-text-default)' } ;
3332 }
3433` ;
3534
@@ -55,35 +54,35 @@ const MentorshipRequest = ({ mentor }) => {
5554 } ) ;
5655 } ;
5756
57+ const commonProps = {
58+ type : 'longtext' ,
59+ required : true ,
60+ minLength : 30 ,
61+ validate : value => value . length >= 30 ,
62+ helpText : 'Minimum 30 characters' ,
63+ style : {
64+ height : '121px' ,
65+ } ,
66+ } ;
67+
5868 const model = {
5969 background : {
70+ ...commonProps ,
6071 label : 'My Background' ,
61- type : 'longtext' ,
6272 defaultValue : mentorshipRequestDetails . background ,
6373 placeholder : 'Tell the mentor about yourself.' ,
64- style : {
65- height : '121px' ,
66- } ,
6774 } ,
6875 expectation : {
76+ ...commonProps ,
6977 label : 'My Expectations' ,
70- type : 'longtext' ,
7178 defaultValue : mentorshipRequestDetails . expectation ,
7279 placeholder : 'What do you expect from this mentorship?' ,
73- style : {
74- height : '121px' ,
75- } ,
7680 } ,
7781 message : {
82+ ...commonProps ,
7883 label : 'Message' ,
79- type : 'longtext' ,
8084 defaultValue : mentorshipRequestDetails . message ,
81- validate : value => ! ! value ,
82- required : true ,
8385 placeholder : 'Anything else you want to say?' ,
84- style : {
85- height : '121px' ,
86- } ,
8786 } ,
8887 } ;
8988
@@ -104,11 +103,9 @@ const MentorshipRequest = ({ mentor }) => {
104103 required = { config . required }
105104 placeholder = { config . placeholder }
106105 value = { config . defaultValue }
107- style = { {
108- ...config . style ,
109- borderColor : errors [ fieldName ] && 'var(--form-text-invalid)' ,
110- } }
106+ style = { config . style }
111107 invalid = { errors [ fieldName ] }
108+ minLength = { config . minLength }
112109 />
113110 { errors [ fieldName ] && (
114111 < ErrorMessage > { errors [ fieldName ] } </ ErrorMessage >
@@ -120,27 +117,21 @@ const MentorshipRequest = ({ mentor }) => {
120117 }
121118 } ;
122119
123- // validate form details
124120 const validate = ( ) => {
125- let isValid = true ;
126121 const _errors = { } ;
127122 Object . entries ( model ) . forEach ( ( [ field , config ] ) => {
128123 if (
129124 config . validate &&
130125 ! config . validate ( mentorshipRequestDetails [ field ] )
131126 ) {
132- _errors [ field ] = `The ${ config . label . toLowerCase ( ) } is required.` ;
133- isValid = false ;
127+ _errors [
128+ field
129+ ] = `"${ config . label } " should be longer than 30 characters` ;
134130 }
135131 } ) ;
136132
137- setErrors ( pervState => ( {
138- ...pervState ,
139- ..._errors ,
140- isValid,
141- } ) ) ;
142-
143- return isValid ;
133+ setErrors ( _errors ) ;
134+ return Object . keys ( _errors ) . length === 0 ;
144135 } ;
145136
146137 const onSubmit = async e => {
@@ -176,6 +167,23 @@ const MentorshipRequest = ({ mentor }) => {
176167 formField ( fieldName , field , i === 0 )
177168 ) }
178169 </ FormFields >
170+ < ul >
171+ < li >
172+ It's important to include all the relevant details so the mentor
173+ will understand who you are, where you stand and what you're
174+ looking for. Once you finish, please read it to make sure you
175+ havn't miss anything.
176+ </ li >
177+ < li >
178+ < span >
179+ If you haven't read our { /* eslint-disable-next-line */ }
180+ < a target = "_blank" href = { links . MENTORSHIP_GUIDELINES } >
181+ Mentorship Guidelines
182+ </ a >
183+ , now is the a good time
184+ </ span >
185+ </ li >
186+ </ ul >
179187 </ Body >
180188 ) }
181189 </ Modal >
0 commit comments