@@ -7,9 +7,11 @@ import { RESTRICTIONS } from '../constants'
77
88function refinedUserData ( user : Partial < UserDetails > ) {
99 let graduationDate
10+
1011 if ( user . expectedGraduationDate ) {
1112 graduationDate = new Date ( user . expectedGraduationDate )
1213 }
14+
1315 let refinedAllergies
1416 if ( user . allergies ) {
1517 refinedAllergies = user . allergies
@@ -27,8 +29,23 @@ function refinedUserData(user: Partial<UserDetails>) {
2729 ) )
2830 . filter ( Boolean )
2931 }
30- return { ...user , dietaryRestrictions : refinedRestrictions , allergies : refinedAllergies , expectedGraduationDate : graduationDate }
32+
33+ const refinedUser = {
34+ ...user ,
35+ dietaryRestrictions : refinedRestrictions ,
36+ allergies : refinedAllergies ,
37+ expectedGraduationDate : graduationDate ,
38+ }
39+
40+ Object . keys ( refinedUser ) . forEach ( ( key ) => {
41+ if ( refinedUser [ key ] === null ) {
42+ delete refinedUser [ key ]
43+ }
44+ } )
45+
46+ return refinedUser
3147}
48+
3249export function useProfileSchema (
3350 user : Partial < UserDetails > ,
3451 isStudent : boolean ,
@@ -69,7 +86,7 @@ export function useProfileSchema(
6986 {
7087 message : 'Invalid Google Drive link.' ,
7188 } ,
72- ) ,
89+ ) . optional ( ) ,
7390 yearStanding : z . nativeEnum ( YearStandings )
7491 . optional ( )
7592 . refine (
@@ -154,7 +171,7 @@ export function useProfileSchema(
154171 }
155172 } , {
156173 message : 'Invalid URL' ,
157- } ) ,
174+ } ) . nullable ( ) ,
158175 } )
159176
160177 const profile = useForm < UserDetails > ( {
0 commit comments