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

Commit b06cb49

Browse files
committed
fix(portal/profile): unable to create or update when the website field was not filled
1 parent 3d44266 commit b06cb49

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

libs/portal/features/profile/hooks/use-profile-schema.ts

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@ import { RESTRICTIONS } from '../constants'
77

88
function 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+
3249
export 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

Comments
 (0)