fix: handle profile update when dateOfBirth is missing

This commit is contained in:
Arvid Norlin
2024-08-27 15:33:12 +02:00
parent d3b21b8e9c
commit 9efcaba887
2 changed files with 10 additions and 1 deletions

View File

@@ -120,6 +120,15 @@ export const editProfile = protectedServerActionProcedure
return return
} }
// Handle case where dateOfBirth is missing in profile and not updated in form
if (
typedKey === "dateOfBirth" &&
!profile.dateOfBirth &&
payload.data.dateOfBirth === "1900-01-01"
) {
return
}
if (payload.data[typedKey] !== profile[typedKey]) { if (payload.data[typedKey] !== profile[typedKey]) {
// @ts-ignore // @ts-ignore
body[typedKey] = payload.data[typedKey] body[typedKey] = payload.data[typedKey]

View File

@@ -60,7 +60,7 @@ export default function Form({ user }: EditFormProps) {
streetAddress: user.address.streetAddress ?? "", streetAddress: user.address.streetAddress ?? "",
zipCode: user.address.zipCode ?? "", zipCode: user.address.zipCode ?? "",
}, },
dateOfBirth: user.dateOfBirth, dateOfBirth: user.dateOfBirth ?? "1900-01-01",
email: user.email, email: user.email,
language: user.language ?? langToApiLang[lang], language: user.language ?? langToApiLang[lang],
phoneNumber: phoneInput, phoneNumber: phoneInput,