-
Notifications
You must be signed in to change notification settings - Fork 48
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
Sucheta Replace the blue square self-scheduler for anyone with 5 or more blue squares (anyone other than Owner/Admin) #1715
Sucheta Replace the blue square self-scheduler for anyone with 5 or more blue squares (anyone other than Owner/Admin) #1715
Conversation
…es to reach out to the administrator
…ser to schedule a blue sqaure
… square scheduler button
…etting schedule time offs
… blue squares, if they wanted to add a new blue square
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @sucheta90 , I have tested you PR and it looks good! Great Job!
Here is the test result:
- Log is as Volunteer/Mentor/Manager Account:
- Under the Profile -> BlueSquare Section
- The number of blue squares are more than 5
- I did see a button "Can't Schedule Time Off" on the BlueSquare Section.
- I can also see all the reasons why each blue sqaure is being assigned to the user by clicking the "Click to learn why".
- Under the Profile -> BlueSquare Section
Please watch the video for the overview of the test:
PR.1715.mp4
Hi @sucheta90, your codes looks good and workable! But I followed the steps to test for this PR, it still showed as "before changes", Is there anything I was wrong? Thanks! |
Hello @bienzguoa, there are no changes for Administrator and Owner roles. Hence, if you are logged in as an Administrator, which in your case is true (as shown in the picture above), you will still see the "Schedule Blue Square Reason" button. All other roles should see the changes. Let me know if you have questions. |
|
||
|
||
// This useEffect will check for any changes in the number of infringements | ||
useEffect(()=>{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is my first PR review, so I'm getting up to speed understanding things, so feel free to push back. But is this useEffect necessary? Can you not derive the number of infringements by the length of the infringement array? Additionally, this useEffect is likely throwing a linter error due to the use of the useProfile object. I get you left it empty so it only runs once when the component renders, but the dependancy array should be populated with the userProfile, and if this causes problems it's probably better to not use the effect.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You do have a point. There is already a variable "infringementsNum" initialized at the number of infringements in the userProfile prop (userProfile.infringements.length). This could be used to render modals conditionally too. I believe the major reason to have that useEffect run on first render, is to check if the user is an Admin or the Owner and not render those modals if so.
This is only my second week reviewing PR's just FYI, I could be wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi there, @ilyaflaks! Thank you so much for pointing that out. I just wanted to clarify for you, @F-Adam-B, that the reason I added the useEffect hook was because I needed to check for infringements after the component had rendered. The existing code already takes care of checking the user's role for permissions. I really appreciate you taking the time to review my code, and I'm always open to any suggestions you may have. I'm still learning, so any feedback is super valuable to me! Thanks again!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
// This useEffect will check for any changes in the number of infringements | ||
useEffect(()=>{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You do have a point. There is already a variable "infringementsNum" initialized at the number of infringements in the userProfile prop (userProfile.infringements.length). This could be used to render modals conditionally too. I believe the major reason to have that useEffect run on first render, is to check if the user is an Admin or the Owner and not render those modals if so.
This is only my second week reviewing PR's just FYI, I could be wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure if it's supposed to be this way, but the user has to refresh for the yellow button and the blue button to appear as can be seen by my video.
pr.review.1715.mp4
…on and added hover, active and focus css styles
c865196
…n should open a modal with the explanation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello! @sucheta90 ! I've reviewed your PR and found that the initial functionality is working such as when logged in as a volunteer with more than 5 blue squares I am getting the yellow button and when logged in as an owner/admin I am still showing the "schedule blue square" button even when the user is beyond 5 squares. I've attached a video below.
Screen.Recording.2023-12-21.at.1.39.07.PM.mov
I start running into a couple things as an owner when deleting squares above 5 to bring the total to 4 or less I have to reload the page to get the schedule blue square button back and as a volunteer it is still allowing me to schedule time off that would take me over the threshold of 5 squares total. I've attached a video here for reference.
Screen.Recording.2023-12-21.at.1.49.44.PM.mov
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tested with volunteer/admin/new volunteer/assistant manager accounts. The "can't schedule" button works here. But when I was trying to schedule a blue square for an active account, no new blue square showed. You can watch the video here. Thank you!
1715.mov
Dear @this-journey, I would like to thank you for taking the time to review the code. I noticed that you pointed out the fact that the system still allows scheduling the Blue square, which will result in having more than 5 squares. I want to clarify that in this PR, it only checks for the existing blue squares and not the ones that will appear in the future. However, I believe that your point is valid and I would like to discuss it with the community. @one-community Please advise. Thank you. |
Hello @ljrirene, I believe the reason why the blue square is not assigned could be because the scheduled date is set in the future. I came to this assumption after checking the deployed app. However, to confirm that this is the expected behavior, I will try to recreate the scenario and inform you of the outcome. Once again, I appreciate your time for reviewing my code. |
Hi @sucheta90 I Logged in as volunteer. The initial functionality is working. However, if the page isn't refreshed, the button allows them to continue scheduling without limit. Will await further clarification from Jae on this matter. 2023-12-30.14-23-56-037.mp4 |
Great catch! It should not allow them to log more time off than they have available blue squares. |
This is another great catch! It should never allow them to log more weeks off than they have available blue squares. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @sucheta90 ! So I started in a volunteer account with more than 5 blue squares already assigned to it and was able to see the yellow button stating that I couldn't request time off .
Then I logged out and logged back in as an owner and deleted that same volunteer users blue squares until I was down to 4, but the yellow button didn't disappear until I reloaded the page. You can see in this photo that there are only 4 squares, but the yellow button is still present.
I then logged out as owner and logged back in as that same volunteer with only 4 blue squares. I was able to schedule time off for 2 subsequent weeks which would've taken my total above the 5 allowed and the yellow button still did not appear even on page reload.
Screen.Recording.2024-01-05.at.9.38.47.AM.mov
Hi @this-journey, thank you for reviewing the code. However, based on the screenshots and video, it seems that the changes haven't been reflected. To ensure that you have the most recent updates, please execute the following commands in your terminal: |
Hi @sucheta90 Thanks for the updates. Now I am running into this issue: I have four blue squares in 2023 and the message shows that I have used 4 blue squares. It seems my available Blue Squares for 2024 aren't updating correctly. 2024-01-06.19-51-07-171.mp4Hello @mianmiantea2019. Unfortunately, automatic updating of blue squares for the current year is out of scope for this PR. This PR only checks for any existing blue squares and any existing scheduled vacations. The Owner/ Administrator has permission to delete the existing blue squares. However, to remove the scheduled vacations, the developer has to remove those by going into the database for now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @sucheta90
I logged in as a volunteer. And I scheduled 5 times off, the Schedule Blue Square Reason button turned into yellow. Good Job! While I didn't see the '+' button to add the blue square.
I've tested your pr with volunteer role. It seems everything works as expected. PR6-.1715.4.blue.square.movThen I added a blue square using my owner role, and now the volunteer user have 5 blue squares and cannot see the blue scheduling button, but was able to see the yellow "Can't schedule time off" button: PR6.1715.5.blue.square.mov |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hi @sucheta90, It's not displaying the button 'Can't Schedule Time Off. Click to learn why.' I added more than 5 Blue Squares, but the button still reads 'Schedule Blue Square Reason
2024-01-12.18-06-52.mov
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, I tested this PR with the manager role. I noticed that after scheduling a fourth blue square reason and adding one Blue Square, the button changes to yellow with the message 'can't schedule blue square reason.' However, the '+' sign for adding a new blue square remains visible. I'm unsure if this is intended and whether people get that access to add more blue square. Please watch the video for more information.
Screen.Recording.2024-01-13.at.6.26.59.PM.online-video-cutter.com.mp4
Hello @Sophie-lei, thank you so much for taking the time to review the code. This behavior is not intended. I am glad you pointed this out. I will make the change right away! |
…to which the + button will rendered
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, I tested this PR with a volunteer role. After adding 5 blue squares, users are still able to add more blue squares without closing the modal. The button then changes to yellow and displays the message 'Can't schedule blue square: reason'. I am unsure if this behavior is an issue.
HGN.APP.-.Google.Chrome.2024-01-20.21-42-04.mp4
@@ -29,7 +29,7 @@ const ScheduleReasonModal = ({ | |||
const initialFetching = async () => { | |||
fetchDispatch({ type: 'FETCHING_STARTED' }); | |||
const response = await getReasonByDate(userId, date); | |||
console.log(response); | |||
// console.log(response); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good job commenting this out as it is not a good idea to have console.log()
statements in the codebase, but I would just remove it entirely. They are helpful when used in your local development environment, but serves no purpose in the actual app and can even cause security issues. Additionally, it can also be forgotten and cause tech debt to accumulate over time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello @rusalshrestha98, thank you for taking the time to review this PR. I will go ahead and remove the unnecessary logs and try to resolve any conflicts in the branch.
@@ -95,17 +158,19 @@ const BlueSquareLayout = props => { | |||
} else { //add/create reason | |||
fetchDispatch({ type: 'FETCHING_STARTED' }); | |||
const response = await addReason(userProfile._id, { date: date, message: reason }); | |||
console.log(response); | |||
// console.log(response); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove log
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove logs and resolve conflicts
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi Sucheta,
During my testing of the PR with both the volunteer and manager roles, I encountered an unexpected issue.
I found that after scheduling time off in the modal, the modal does not automatically close. This allows users to keep scheduling as many times as they want, even though the button changes to "Can't Schedule Time Off." If the modal is not closed, users can exceed the limit of 5 times.
Please refer to the video.
Screen.Recording.2024-01-22.at.14.33.25.mov
I have created a new PR with the updated code PR1874 |
Description
(PRIORITY HIGH) Jae: (WIP Sucheta ) Replace the blue square self-scheduler for anyone with 5 or more blue squares (anyone other than Owner/Admin)
Can’t Schedule Time Off
(click to learn why)
*You have X blue squares already and 5 are the maximum allowed per year. Please contact your Administrator if you need to request time off.
Note: Blue squares drop off 1 calendar year after they are issued. *
*Including your time already requested off, you have used the equivalent of X blue squares. 5 is the maximum allowed per year. Please remove a time-off request below or contact your Administrator if you need to request time off in addition to what is listed here:
Time off request 1
Time off request 2
Etc.
Note: Blue squares drop off 1 calendar year after they are issued. *
Related PRS (if any):
No backend PRs
…
Main changes explained:
Adds new handler functions to BlueSquareLayout.jsx, that opens modals based on user roles and the number of BlueSquares assigned or scheduled.
The button
Schedule Blue Square Reason
changes toCan't Schedule Time Off
if((isInfringementMoreThanFive || numberOfReasons >= 5 || (infringementsNum + numberOfReasons >= 5 )) && !(userProfile.role === "Administrator" || userProfile.role === "Owner"))
…
How to test:
npm install
and...
to run this PR locallySchedule Blue Square
button. Otherwise, the button changes toCan't Schedule Time Off Click to learn why
.Screenshots or videos of changes:
Before Change
https://github.com/OneCommunityGlobal/HighestGoodNetworkApp/assets/101291283/159ce01e-da12-4b2a-ac37-86c47a8e26cb
Updated Changes
PR1715_changeRequested.mp4
Note:
Please note nothing has changed for the user role Admin/Owner. Last updated 01/04/2024