diff --git a/app/frontend/src/javascript/components/user/user-profile-form.tsx b/app/frontend/src/javascript/components/user/user-profile-form.tsx index 9aae72cfe..f1e9adee1 100644 --- a/app/frontend/src/javascript/components/user/user-profile-form.tsx +++ b/app/frontend/src/javascript/components/user/user-profile-form.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import React, { useEffect } from 'react'; import { react2angular } from 'react2angular'; import { SubmitHandler, useForm, useWatch } from 'react-hook-form'; import { isNil as _isNil } from 'lodash'; @@ -14,6 +14,8 @@ import { FormSwitch } from '../form/form-switch'; import { FormRichText } from '../form/form-rich-text'; import MemberAPI from '../../api/member'; import { AvatarInput } from './avatar-input'; +import moment from 'moment'; +import { TDateISODate } from '../../typings/date-iso'; declare const Application: IApplication; @@ -36,6 +38,14 @@ export const UserProfileForm: React.FC = ({ action, size, const { handleSubmit, register, control, formState, setValue } = useForm({ defaultValues: { ...user } }); const output = useWatch({ control }); + useEffect(() => { + // this is a workaround needed because something in angular.js is transforming the YYY-MM-DD string to a Date Object + setValue( + 'statistic_profile_attributes.birthday', + moment(user.statistic_profile_attributes.birthday).format('YYYY-MM-DD') as TDateISODate + ); + }, [user]); + const [isOrganization, setIsOrganization] = React.useState(!_isNil(user.invoicing_profile_attributes.organization_attributes)); /** diff --git a/app/frontend/src/javascript/models/user.ts b/app/frontend/src/javascript/models/user.ts index b2208688b..7587663f7 100644 --- a/app/frontend/src/javascript/models/user.ts +++ b/app/frontend/src/javascript/models/user.ts @@ -1,5 +1,5 @@ import { Plan } from './plan'; -import { TDateISO } from '../typings/date-iso'; +import { TDateISO, TDateISODate } from '../typings/date-iso'; export enum UserRole { Member = 'member', @@ -69,7 +69,7 @@ export interface User { statistic_profile_attributes: { id: number, gender: string, - birthday: TDateISO + birthday: TDateISODate }, subscribed_plan: Plan, subscription: {