Skip to content

Commit

Permalink
Merge pull request #399 from EnMarche/EM-921-no-birthdate-return-null
Browse files Browse the repository at this point in the history
Fix birthdate issue
  • Loading branch information
XavierLac authored May 28, 2021
2 parents fb3a1a8 + d16aa48 commit 7e9e962
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
6 changes: 2 additions & 4 deletions src/pages/Profile/Profile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,8 @@ export const Profile: FunctionComponent = () => {
causeSubscription,
coalitionSubscription,
gender: gender === null ? GENDERS[0].value : gender,
birthday:
birthdate === undefined || birthdate === null
? null
: format(new Date(birthdate), 'yyyy-MM-dd'),
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
birthday: birthdate ? format(new Date(birthdate), 'yyyy-MM-dd') : null,
phoneNumber: phone !== null && phone !== undefined ? phone.number : null,
phoneCountry: findPhoneCountryByRegion(
phoneCountries,
Expand Down
5 changes: 3 additions & 2 deletions src/pages/Profile/hooks/useUpdateUserProfile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ type UpdateUserProfilePayload = {
last_name?: string;
phone?: { number?: string; country?: string };
gender?: string;
birthdate?: string;
birthdate?: string | null;
coalition_subscription?: boolean;
cause_subscription?: boolean;
};
Expand Down Expand Up @@ -68,7 +68,8 @@ export const useUpdateUserProfile = (userId?: string) => {
first_name: values.firstName,
last_name: values.lastName,
gender: values.gender === GENDERS[0].value ? undefined : values.gender,
birthdate: values.birthday,
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
birthdate: values.birthday ? values.birthday : null,
phone:
values.phoneNumber !== null
? {
Expand Down
4 changes: 2 additions & 2 deletions src/pages/Profile/hooks/useValidateForm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export interface ProfileFormValues {
phoneNumber?: string;
phoneCountry?: PhoneCountry;
gender?: string;
birthday?: string;
birthday?: string | null;
coalitionSubscription?: boolean;
causeSubscription?: boolean;
}
Expand All @@ -26,7 +26,7 @@ type ErrorForm = {
email?: string;
phoneNumber?: string;
gender?: string;
birthday?: string;
birthday?: string | null;
};

export const useValidateForm = () => {
Expand Down

0 comments on commit 7e9e962

Please sign in to comment.