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

Peterson_Fix_Weekly_Summaries_edit_Last_week #2023

Merged

Conversation

peterson337
Copy link
Contributor

Description

In the HGN software, specifically within the 'Tasks and Timelogs' card on the Dashboard, there is a tab named 'Weekly Summaries,' which displays three editable summaries. Upon clicking the 'edit' button below each summary, two additional buttons, 'save' and 'cancel,' appear. The bug was found in the 'save' button functionality, which, when triggered, initiated a 'put' request resulting in two errors. The first error occurred because Node did not receive information from React, resulting in an HTTP status code 500, indicating a server error. The second error was related to the frontend-to-backend request: the request URL should have contained the user ID but was instead sent as 'undefined.'

priority Medium

Related PRS (if any):

This frontend PR is associated with the following backend PR: OneCommunityGlobal/HGNRest#781

Main changes explained:

The WeeklySummaries component has been modified to fix the bugs.

How to test:

  1. check into current branch
  2. do npm install and npm start to run this PR locally
  3. log as any user.
  4. Go to Dashboard → Weekly Summaries.
  5. Click the "Edit" button.
  6. After editing the desired summary, click the "Save" button.
  7. Open the browser's Developer Tools by pressing F12 or right-clicking and selecting 'Inspect.' Navigate to the 'Console' tab. Check if the following errors appear in the console: a
  8. If the errors shown in the image above do not appear and the summary has been edited successfully, reload the page and check if the summary remains edited.

Screenshots or videos of changes:

Peterson_Fix_Weekly_Summaries_edit_Last_week’s

Note:

The console is going to have some errors not related to this PR. These can be disregarded because the code changed by this PR will not introduce these errors to the "development" branch when it gets merged.

@peterson337 peterson337 changed the title Peterson_Fix_Weekly_Summaries_edit_Last_week’s Peterson_Fix_Weekly_Summaries_edit_Last_week Mar 4, 2024
meetpadhiar4
meetpadhiar4 previously approved these changes Mar 7, 2024
Copy link

@meetpadhiar4 meetpadhiar4 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, I tested your PR and it works as intended. I was able to edit the summary without any errors and the communication between the server and the frontend is happening properly resulting in 200 status code. Refer the video attached for reference.

PR.2023.mov

@nnamdixobi
Copy link

testt

Everything compiles as expected but for some reason it wont let me save a weekly summary for testing

psharma1984
psharma1984 previously approved these changes Mar 10, 2024
Copy link

@psharma1984 psharma1984 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @peterson337 I reviewed and its working as expected. Able to edit the summary and its saved and remains updated when page is refreshed
a
b

hetvi11110
hetvi11110 previously approved these changes Mar 11, 2024
Copy link

@hetvi11110 hetvi11110 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested this PR as mentioned. It is working fine on my local server. Here is the screenshot.
PR2023

Tiantian-C
Tiantian-C previously approved these changes Mar 13, 2024
Copy link

@Tiantian-C Tiantian-C left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have tested the function,and it works well!
#2023

@Tiantian-C Tiantian-C closed this Mar 13, 2024
@Tiantian-C Tiantian-C reopened this Mar 13, 2024
Copy link
Contributor

@Abi-Liu Abi-Liu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey! Overall the code works as expected. However, there is one small bug I encountered. When editing the weekly summaries, if a user tries to save an invalid summary (either blank or less than 50 words), the error will fire as expected but the button will stay disabled. This forces the user to refresh and then make the changes again before being allowed to update.

This can be fixed by just setting the LoadingHandleSave state to null if an error occurs.

EDIT: Also no need to await setLoadingHandleSave on line 92 in src/components/Timelog/WeeklySummaries.jsx

video1131734987.mp4

@@ -79,7 +79,8 @@ export const updateWeeklySummaries = (userId, weeklySummariesData) => {

// Merge the weekly summaries related changes with the user's profile.
const {mediaUrl, weeklySummaries, weeklySummariesCount } = weeklySummariesData;
console.log('respon get', response.data)

// console.log('respon get', response.data)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove console.log

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed the console.log from the weeklySummaries.js archive.

photo 4

@peterson337
Copy link
Contributor Author

Hey! Overall the code works as expected. However, there is one small bug I encountered. When editing the weekly summaries, if a user tries to save an invalid summary (either blank or less than 50 words), the error will fire as expected but the button will stay disabled. This forces the user to refresh and then make the changes again before being allowed to update.

This can be fixed by just setting the LoadingHandleSave state to null if an error occurs.

EDIT: Also no need to await setLoadingHandleSave on line 92 in src/components/Timelog/WeeklySummaries.jsx

video1131734987.mp4

Hey! Overall the code works as expected. However, there is one small bug I encountered. When editing the weekly summaries, if a user tries to save an invalid summary (either blank or less than 50 words), the error will fire as expected but the button will stay disabled. This forces the user to refresh and then make the changes again before being allowed to update.

This can be fixed by just setting the LoadingHandleSave state to null if an error occurs.

EDIT: Also no need to await setLoadingHandleSave on line 92 in src/components/Timelog/WeeklySummaries.jsx

video1131734987.mp4

I fixed the bug. See my gif for more reference:
Video 1

@peterson337 peterson337 requested a review from Abi-Liu March 13, 2024 17:53
Copy link
Contributor

@Abi-Liu Abi-Liu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just an extra set state that is setting the state to the same value. Other than that the changes look good!

src/components/Timelog/WeeklySummaries.jsx Show resolved Hide resolved
} else {
// Invalid summary, show an error message or handle it as needed
alert('Please enter a valid summary with at least 50 words.');
await setLoadingHandleSave(null);
Copy link
Contributor

@Abi-Liu Abi-Liu Mar 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Delete the await setLoadingHandleSave line. Sorry I quoted the wrong code snippet in my other comment

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Abi-Liu. I removed the setLoadingHandleSave from the handleSave function.

photo 3

Copy link
Contributor

@Abi-Liu Abi-Liu Mar 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's still there. Underneath await dispatch(getUserProfile(userProfile._id)); There's 2 setLoadingHandleSave(null)

@peterson337 peterson337 requested a review from Abi-Liu March 14, 2024 12:41
@SanketKaware
Copy link

Followed all the mentioned steps and the changes look good to me. Those errors didn't appear.

Screen.Recording.2024-03-14.at.8.47.06.PM.mov

Abi-Liu
Abi-Liu previously approved these changes Mar 15, 2024
Copy link
Contributor

@Abi-Liu Abi-Liu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

Copy link
Contributor

@20chen-7 20chen-7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

npm run locally, the function looks good. but when I run npm start, npm test errors occur.
Screenshot 2024-03-15 at 4 34 31 PM
Screenshot 2024-03-15 at 4 34 42 PM
Screenshot 2024-03-15 at 4 22 40 PM

SanketKaware
SanketKaware previously approved these changes Mar 15, 2024
Copy link

@SRamen1999 SRamen1999 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR works as intended. I was able to edit the summary without any errors and the communication between the server and the frontend is happening properly resulting in 200 status code.

Screen.Recording.2024-03-15.at.5.39.06.PM.mov

There is also a safe check to see if the user edits the summary less than 50 words.

Screen Shot 2024-03-15 at 5 44 26 PM

@rajnada
Copy link

rajnada commented Mar 16, 2024

Hii,

I have tested the functionality and it is working fine!
Good Job

Before :

2023 781

After :

781

PratimaSingh02
PratimaSingh02 previously approved these changes Mar 16, 2024
Copy link
Contributor

@PratimaSingh02 PratimaSingh02 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi I took the following steps to execute this PR:

  1. Logged in as an owner
  2. Created a test weekly summary
  3. Edited the weekly summary
  4. Verified that the server error was not there
  5. Reloaded the page to check if the edit was still present
    image

Copy link

@sameersdeshpande sameersdeshpande left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @peterson337
The changes are working as expected. I checked in to current branch and logged in as a user and edited the summary and found no errors in console. It was with 200 ok status.
Thanks
Screenshot 2024-03-16 at 7 12 31 PM
Screenshot 2024-03-16 at 7 12 48 PM
Screenshot 2024-03-16 at 7 13 00 PM

iven-yao
iven-yao previously approved these changes Mar 17, 2024
Copy link
Contributor

@iven-yao iven-yao left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tested the edit function in weekly summaries, and it works perfect without any error in console, and reflect the editing after save correctly.

PR2023.mp4

ImzIssa
ImzIssa previously approved these changes Mar 17, 2024
Copy link
Contributor

@ImzIssa ImzIssa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey, I've tested this PR and the functionality seems to be implemented correctly. Nice work!
Screenshot (32)

I do have a minor suggestion to enhance the UI. Consider using the reactstrap Alert inplace of the browser alert.
Screenshot (33)

the alert when creating a summary

Screenshot (34)

const [editedSummaries, setEditedSummaries] = useState([
userProfile.weeklySummaries[0]?.summary || '',
userProfile.weeklySummaries[1]?.summary || '',
userProfile.weeklySummaries[2]?.summary || '',
]);
const [originalSummaries, setOriginalSummaries] = useState([...editedSummaries]);

const [LoadingHandleSave, setLoadingHandleSave] = useState(null);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// Consider refactoring to use camelCase for consistency everywhere in the codebase.
const [loadingHandleSave, setLoadingHandleSave] = useState(null);

mohabbasd
mohabbasd previously approved these changes Mar 23, 2024
Copy link
Contributor

@mohabbasd mohabbasd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello, I tested your PR and it works perfectly. Below is a video for reference.

Screen.Recording.2024-03-23.at.12.42.06.AM.mov

Coops023
Coops023 previously approved these changes Mar 23, 2024
Copy link

@Coops023 Coops023 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi i reviewed this PR and was able to edit summaries with out an error! good job.

test

@anandsesha
Copy link
Contributor

Hi, I have tested this functionality with its associated backend PR #781, logging in as admin user and volunteer user.

  • Created weekly summary and while editing that summary checked console and the mentioned error is not seen.
  • After saving the edit, inspected Network tab which results in status 200 Ok as expected.
  • Reloaded page and Edited summary is persisted.
  • Issue reported earlier of summary less than 50 is not allowed. Appropriate message shown.

Below screenshots for reference:

PR 2023 - Edited Network tab
PR 2023 - Info persisted
PR 2023 - No console error
PR 2023 - Pre-edit
PR 2023 - summary less 50

Copy link
Member

@Sarthak32 Sarthak32 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi , I tested your PR. Everything works as expected but for some reason it does not let me save my edited summary.
Screenshot 2024-03-24 121544
Screenshot 2024-03-24 121555

Jaiwin-4998
Jaiwin-4998 previously approved these changes Mar 27, 2024
Copy link

@Jaiwin-4998 Jaiwin-4998 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, I have tested you PR and it works properly. The description remains the edited after the changes and no errors.
PR 2023

kylepham
kylepham previously approved these changes Mar 27, 2024
Copy link
Contributor

@kylepham kylepham left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything works as expected. New summary edit was successfully saved and returned 200 status code. 50-word guard also worked.

Before:

Screenshot 2024-03-27 at 2 52 44 PM (2)

After:

Screenshot 2024-03-27 at 2 53 30 PM (2)

Screenshot 2024-03-27 at 2 54 27 PM (2)

@rajnada
Copy link

rajnada commented Mar 30, 2024

Hii,

I have tested the PR. It works completely fine! Good Job.

image

@MQChen211
Copy link

Hi, I tested your PR and it works as expected.
PR#2023+781

Copy link
Contributor

@aaryaneil aaryaneil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@one-community
Copy link
Member

Thank you all, merging!

1 similar comment
@one-community
Copy link
Member

Thank you all, merging!

@one-community one-community merged commit dccb1c9 into development May 1, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.