Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Develop : fixed birthdate update at user portal for all users #3497

8 changes: 5 additions & 3 deletions src/screens/MemberDetail/MemberDetail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ const MemberDetail: React.FC<MemberDetailProps> = ({ id }): JSX.Element => {
appLanguageCode: '',
image: '',
gender: '',
birthDate: '2024-03-14',
birthDate: '',
grade: '',
empStatus: '',
maritalStatus: '',
Expand Down Expand Up @@ -241,8 +241,10 @@ const MemberDetail: React.FC<MemberDetailProps> = ({ id }): JSX.Element => {
try {
const { data } = await updateUser({
variables: {
id: currentUrl,
...formState,
data: {
id: currentUrl,
...formState,
},
},
});
if (data) {
Expand Down
32 changes: 17 additions & 15 deletions src/screens/UserPortal/Settings/Settings.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -129,21 +129,23 @@ const updateMock = [
request: {
query: UPDATE_USER_MUTATION,
variables: {
firstName: 'John',
lastName: 'randomUpdated',
createdAt: '2021-03-01T00:00:00.000Z',
gender: 'MALE',
email: 'johndoe@gmail.com',
phoneNumber: '+174567890',
birthDate: '2024-03-01',
grade: 'GRADUATE',
empStatus: 'PART_TIME',
maritalStatus: 'SINGLE',
address: 'random',
state: 'random',
country: 'IN',
eventsAttended: [{ _id: 'event1' }, { _id: 'event2' }],
image: '',
data: {
firstName: 'John',
lastName: 'randomUpdated',
createdAt: '2021-03-01T00:00:00.000Z',
gender: 'MALE',
email: 'johndoe@gmail.com',
phoneNumber: '+174567890',
birthDate: '2024-03-01',
grade: 'GRADUATE',
empStatus: 'PART_TIME',
maritalStatus: 'SINGLE',
address: 'random',
state: 'random',
country: 'IN',
eventsAttended: [{ _id: 'event1' }, { _id: 'event2' }],
image: '',
},
bandhan-majumder marked this conversation as resolved.
Show resolved Hide resolved
},
},
result: {
Expand Down
30 changes: 13 additions & 17 deletions src/screens/UserPortal/Settings/Settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,9 @@
updatedUserDetails = { ...updatedUserDetails, image: '' };
}
const { data } = await updateUserDetails({
variables: updatedUserDetails,
variables: {
data: updatedUserDetails,
},
});
if (data) {
toast.success(
Expand Down Expand Up @@ -158,7 +160,6 @@
*/
const handleResetChanges = (): void => {
setisUpdated(false);
/* istanbul ignore next */
if (data) {
const {
firstName,
Expand Down Expand Up @@ -192,7 +193,6 @@
};

useEffect(() => {
/* istanbul ignore next */
if (data) {
const {
firstName,
Expand Down Expand Up @@ -314,9 +314,8 @@
role="button"
aria-label="Edit profile picture"
tabIndex={0}
onKeyDown={
/*istanbul ignore next*/
(e) => e.key === 'Enter' && handleImageUpload()
onKeyDown={(e) =>
e.key === 'Enter' && handleImageUpload()
}
/>
</div>
Expand All @@ -330,18 +329,15 @@
data-testid="fileInput"
multiple={false}
ref={fileInputRef}
onChange={
/* istanbul ignore next */
async (
e: React.ChangeEvent<HTMLInputElement>,
): Promise<void> => {
const file = e.target?.files?.[0];
if (file) {
const image = await convertToBase64(file);
setUserDetails({ ...userDetails, image });
}
onChange={async (
e: React.ChangeEvent<HTMLInputElement>,
): Promise<void> => {
const file = e.target?.files?.[0];

Check warning on line 335 in src/screens/UserPortal/Settings/Settings.tsx

View check run for this annotation

Codecov / codecov/patch

src/screens/UserPortal/Settings/Settings.tsx#L335

Added line #L335 was not covered by tests
if (file) {
const image = await convertToBase64(file);
setUserDetails({ ...userDetails, image });

Check warning on line 338 in src/screens/UserPortal/Settings/Settings.tsx

View check run for this annotation

Codecov / codecov/patch

src/screens/UserPortal/Settings/Settings.tsx#L337-L338

Added lines #L337 - L338 were not covered by tests
}
}
}}
style={{ display: 'none' }}
/>
</Col>
Expand Down
Loading