@@ -13,7 +13,6 @@ import SoftBackground from "./FormComponent/SoftBackground";
1313import { getDisplayName } from "../../../Data/UserData" ;
1414import { getPrograms } from "../../../Data/ProgramData" ;
1515import { blobToBase64 } from "../../../Data/Common" ;
16- import { addModifyPost , getPostObject , removePost } from "../../../Data/PostData" ;
1716import { addModifyFile , getFileObject , removeFile } from "../../../Data/FileData" ;
1817
1918export async function loader ( { params} ) {
@@ -67,14 +66,16 @@ export async function action({request}) {
6766 const L = formValues . L ;
6867 const S = formValues . S ;
6968 const EnglishProficiency = {
70- [ EnglishOption === 'TOEFL ' ? 'TOEFL ' : 'IELTS ' ] : {
71- 'Total' : Number ( EnglishTotal ) ,
72- 'R' : Number ( R ) ,
73- 'W' : Number ( W ) ,
74- 'L' : Number ( L ) ,
75- 'S' : Number ( S ) ,
69+ [ EnglishOption === 'IELTS ' ? 'IELTS ' : 'TOEFL ' ] : {
70+ 'Total' : EnglishTotal ? Number ( EnglishTotal ) : null ,
71+ 'R' : R ? Number ( R ) : null ,
72+ 'W' : W ? Number ( W ) : null ,
73+ 'L' : L ? Number ( L ) : null ,
74+ 'S' : S ? Number ( S ) : null ,
7675 }
7776 }
77+ console . log ( EnglishProficiency ) ;
78+ console . log ( ( ( EnglishTotal && R && W && L && S ) && { 'EnglishProficiency' : EnglishProficiency } ) )
7879 const Exchange = formValues . Exchange ? removeEmptyDictInList ( formValues . Exchange ) : [ ] ;
7980 const Publication = formValues . Publication ? removeEmptyDictInList ( formValues . Publication ) : [ ] ;
8081 const Recommendation = formValues . Recommendation ? removeEmptyDictInList ( formValues . Recommendation ) : [ ] ;
@@ -124,14 +125,15 @@ export async function action({request}) {
124125 'Major' : Major ,
125126 'GPA' : GPA ,
126127 'Ranking' : Ranking ,
127- ...( ( GRE . Total !== 260 || GRE . V !== 130 || GRE . Q !== 130 || GRE . AW !== 0 ) && { 'GRE' : GRE } ) ,
128- 'EnglishProficiency' : EnglishProficiency ,
129- ...( Exchange . length !== 0 && { 'Exchange' : Exchange } ) ,
130- ...( Publication . length !== 0 && { 'Publication' : Publication } ) ,
128+ ...( ( GRE . Total !== 260 || GRE . V !== 130 || GRE . Q !== 130 || GRE . AW !== 0 ) && { 'GRE' : GRE } ) ,
129+ // 'EnglishProficiency': EnglishProficiency,
130+ ...{ 'EnglishProficiency' : ( ( EnglishTotal && R && W && L && S ) ? EnglishProficiency : { } ) } ,
131+ ...( Exchange . length !== 0 && { 'Exchange' : Exchange } ) ,
132+ ...( Publication . length !== 0 && { 'Publication' : Publication } ) ,
131133 'Research' : Research ,
132134 'Internship' : Internship ,
133- ...( Recommendation . length !== 0 && { 'Recommendation' : Recommendation } ) ,
134- ...( Competition !== undefined && { 'Competition' : Competition } ) ,
135+ ...( Recommendation . length !== 0 && { 'Recommendation' : Recommendation } ) ,
136+ ...( Competition !== undefined && { 'Competition' : Competition } ) ,
135137 'Programs' : ActionType === 'new' ? { } : Programs ,
136138 'Final' : Final === undefined ? "" : Final ,
137139 'Posts' : Posts
@@ -201,9 +203,11 @@ export async function action({request}) {
201203const FormContent = ( activeStep , formValues , handleBack , handleNext , handleChange , type , loaderData ) => {
202204 switch ( activeStep ) {
203205 case 0 :
204- return < BasicInfo formValues = { formValues } handleNext = { handleNext } handleChange = { handleChange } actionType = { type } loaderData = { loaderData } /> ;
206+ return < BasicInfo formValues = { formValues } handleNext = { handleNext } handleChange = { handleChange }
207+ actionType = { type } loaderData = { loaderData } /> ;
205208 case 1 :
206- return < SoftBackground formValues = { formValues } handleBack = { handleBack } handleChange = { handleChange } loaderData = { loaderData } /> ;
209+ return < SoftBackground formValues = { formValues } handleBack = { handleBack } handleChange = { handleChange }
210+ loaderData = { loaderData } /> ;
207211 default :
208212 return null ;
209213 }
@@ -280,8 +284,27 @@ export default function AddModifyApplicant({type}) {
280284 }
281285 const [ formValues , setFormValues ] = useState ( applicantContent ?? { } ) ;
282286 const handleChange = ( event , value , name ) => {
283- setFormValues ( { ...formValues , [ event ?. target . name ? event ?. target . name : name ] : value ? value : event ?. target . value } ) ;
287+ console . log ( event ?. target ?. name , event ?. target ?. value , value , name )
288+ console . log ( { [ event ?. target . name ? event ?. target . name : name ] : value ? value : event ?. target . value } )
289+ setFormValues ( {
290+ ...formValues ,
291+ [ event ?. target . name ? event ?. target . name : name ] : value ? value : event ?. target . value
292+ } ) ;
293+ console . log ( formValues ) ;
284294 if ( event ?. target . value === "" || ( event ?. target . name === undefined && ( value === "" || value === undefined || value === null || value === '[]' ) ) ) {
295+ if ( name === "EnglishOption" || name === "R" || name === "W" || name === "L" || name === "S" || name === "EnglishTotal" ) {
296+ if ( name === "EnglishOption" ) {
297+ setFormValues ( {
298+ ...formValues ,
299+ 'EnglishTotal' : undefined ,
300+ 'R' : undefined ,
301+ 'W' : undefined ,
302+ 'L' : undefined ,
303+ 'S' : undefined
304+ } ) ;
305+ }
306+ return
307+ }
285308 const { [ event ?. target . name ? event ?. target . name : name ] : _ , ...rest } = formValues ;
286309 setFormValues ( rest ) ;
287310 }
@@ -293,14 +316,16 @@ export default function AddModifyApplicant({type}) {
293316 nonLinear
294317 alternativeLabel
295318 activeStep = { activeStep }
296- sx = { { mt : 10 } }
319+ sx = { { mt : 10 } }
297320 >
298321 { steps . map ( ( label ) => (
299322 < Step key = { label } >
300- < StepButton color = "inherit" sx = { { "&.MuiButtonBase-root:hover" : {
323+ < StepButton color = "inherit" sx = { {
324+ "&.MuiButtonBase-root:hover" : {
301325 bgcolor : "transparent" ,
302326 cursor : "default"
303- } } } >
327+ }
328+ } } >
304329 { label }
305330 </ StepButton >
306331 </ Step >
0 commit comments