-
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
Closed
sucheta90
wants to merge
15
commits into
development
from
Sucheta_replace_blue_square_self_scheduler
Closed
Changes from 9 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
1f96578
Checks for infringements, if more than 5, the button content changes …
sucheta90 d953231
adds modal functionality showing the number of blue squares and advis…
sucheta90 a58754d
commit checks for the counts of blue squares and accordingly allows u…
sucheta90 58453c6
this commit adds a checks user roles and accordingly renders the blue…
sucheta90 49cef68
adds handler function and opnes modal to explain the reason for not l…
sucheta90 1059daf
Implemented checks to see the infringementsAuthorizer has less than 5…
sucheta90 8bf898d
removed unnecessary import form componnet
sucheta90 c865196
changed content of the new button and removed the link below the butt…
sucheta90 492daf3
removed unnecessary imports
sucheta90 2dd3e5c
modified content in SchedulerExplanationModal component and the butto…
sucheta90 31849f7
removes unused states from BlueSquareLayout.jsx
sucheta90 855a92a
adds a function to check for previously scheduled reasons for blueSqu…
sucheta90 1e87dbd
adds checks for scheduled reasons, shows blue square reasons and the …
sucheta90 7f33d9e
adds dependency to useEffect hook in BlueSquareLayout.jsx, function c…
sucheta90 326ae12
adds a check for total infringements and scheduled raesons according …
sucheta90 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
src/components/UserProfile/SchedulerExplanationModal/SchedulerExplanationModal.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import Button from 'react-bootstrap/Button'; | ||
import Modal from 'react-bootstrap/Modal'; | ||
import { boxStyle } from 'styles'; | ||
|
||
function SchedulerExplanationModal({infringementsNum,handleClose, infringements}) { | ||
|
||
return ( | ||
<div | ||
className="modal show" | ||
style={{ display: 'block', position: 'initial' }} | ||
> | ||
<Modal.Dialog> | ||
<Modal.Header closeButton> | ||
<Modal.Title>Please Refer To The Explanation </Modal.Title> | ||
</Modal.Header> | ||
|
||
<Modal.Body scrollable> | ||
<p> Including your time already requested off, you have used the equivalent of <span style={{color:"red",fontWeight:500}}>{infringementsNum}</span> blue squares. <span style={{fontWeight:500, color:"green"}}>5</span> is the maximum allowed per year.</p> | ||
<p> | ||
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:</p> | ||
<ol>{infringements.map((el,index)=>{ | ||
return <li key={el._id}>{el.description}</li> | ||
})}</ol> | ||
|
||
|
||
<p><em>Note</em>: Blue squares expire after 1 calendar year from their issuance date.</p> | ||
|
||
</Modal.Body> | ||
|
||
<Modal.Footer> | ||
<Button variant="secondary" onClick={handleClose} style={boxStyle}>Close</Button> | ||
</Modal.Footer> | ||
</Modal.Dialog> | ||
</div> | ||
); | ||
} | ||
|
||
export default SchedulerExplanationModal; |
Empty file.
29 changes: 29 additions & 0 deletions
29
src/components/UserProfile/StopSelfSchedulerModal/StopSelfSchedulerModal.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import Button from 'react-bootstrap/Button'; | ||
import Modal from 'react-bootstrap/Modal'; | ||
import { boxStyle } from 'styles'; | ||
|
||
function StopSelfSchedulerModal({infringementsNum,handleClose}) { | ||
return ( | ||
<div | ||
className="modal show" | ||
style={{ display: 'block', position: 'initial' }} | ||
> | ||
<Modal.Dialog> | ||
<Modal.Header closeButton> | ||
<Modal.Title>Can Not Schedule Time Off</Modal.Title> | ||
</Modal.Header> | ||
|
||
<Modal.Body> | ||
<p>You currently possess <span style={{color:"red",fontWeight:500}}>{infringementsNum}</span> blue squares, with an annual limit of <span style={{fontWeight:500, color:"green"}}>5</span>. If you require time off, kindly reach out to your Administrator. </p> | ||
<p><em>Note</em>: Blue squares expire after 1 calendar year from their issuance date.</p> | ||
</Modal.Body> | ||
|
||
<Modal.Footer> | ||
<Button variant="secondary" onClick={handleClose} style={boxStyle}>Close</Button> | ||
</Modal.Footer> | ||
</Modal.Dialog> | ||
</div> | ||
); | ||
} | ||
|
||
export default StopSelfSchedulerModal; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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!