-
Notifications
You must be signed in to change notification settings - Fork 2
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
TEC email reminders feature #536
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
d03d25a
new tec email reminders feature
418fc93
run prettier
98a957e
add more detail to email + other minor fixes
8a51092
account for db schema change + other minor fixes
f663cc9
fix nitpicks
958db63
Merge branch 'main' into tec-email-reminders
patriciaahuang 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
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 |
---|---|---|
|
@@ -5,6 +5,10 @@ export default class PermissionsManager { | |
return this.isLeadOrAdmin(mem); | ||
} | ||
|
||
static async canNotifyMembers(mem: IdolMember): Promise<boolean> { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
return this.isLeadOrAdmin(mem); | ||
} | ||
|
||
static async canDeploySite(mem: IdolMember): Promise<boolean> { | ||
return this.isLeadOrAdmin(mem); | ||
} | ||
|
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
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,5 @@ | ||
.buttonsWrapper { | ||
display: flex; | ||
justify-content: flex-end; | ||
padding-top: 15px; | ||
} |
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,69 @@ | ||
import React, { useState } from 'react'; | ||
import { Modal, Form } from 'semantic-ui-react'; | ||
import styles from './NotifyMemberModal.module.css'; | ||
import { Member, MembersAPI } from '../../API/MembersAPI'; | ||
import { Emitters } from '../../utils'; | ||
|
||
const NotifyMemberModal = (props: { | ||
all: boolean; | ||
member?: Member; | ||
members?: Member[]; | ||
trigger: JSX.Element; | ||
}): JSX.Element => { | ||
const { member, members, all, trigger } = props; | ||
const [open, setOpen] = useState(false); | ||
const subject = !all && member ? `${member.firstName} ${member.lastName}` : 'everyone'; | ||
|
||
const handleSubmit = () => { | ||
if (!all && member) { | ||
MembersAPI.notifyMember(member).then((val) => { | ||
Emitters.generalSuccess.emit({ | ||
headerMsg: 'Reminder sent!', | ||
contentMsg: `An email reminder was successfully sent to ${member.firstName} ${member.lastName}!` | ||
}); | ||
}); | ||
} | ||
|
||
if (all && members) { | ||
members.forEach(async (member) => { | ||
await MembersAPI.notifyMember(member); | ||
}); | ||
Emitters.generalSuccess.emit({ | ||
headerMsg: 'Reminder sent!', | ||
contentMsg: `An email reminder was successfully sent to everyone!` | ||
}); | ||
} | ||
|
||
setOpen(false); | ||
}; | ||
|
||
return ( | ||
<Modal | ||
onClose={() => setOpen(false)} | ||
onOpen={() => setOpen(true)} | ||
open={open} | ||
trigger={trigger} | ||
> | ||
<Modal.Header> Are you sure you want to notify {subject}?</Modal.Header> | ||
<Modal.Content> | ||
This will send an email to {subject} reminding them that they do not have enough TEC Credits | ||
completed yet this semester. | ||
<Form> | ||
<div className={styles.buttonsWrapper}> | ||
<Form.Button onClick={() => setOpen(false)}>Cancel</Form.Button> | ||
<Form.Button | ||
content="Yes" | ||
labelPosition="right" | ||
icon="checkmark" | ||
onClick={() => { | ||
handleSubmit(); | ||
}} | ||
positive | ||
/> | ||
</div> | ||
</Form> | ||
</Modal.Content> | ||
</Modal> | ||
); | ||
}; | ||
export default NotifyMemberModal; |
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.
Since you are creating variables with promises, I'd await them first instead of inlining the
await
, otherwise you might as well just inline the value and delete the variable entirely.So instead of
try
Same with
memberEvents
, although I'd personally rename this tomemberEventAttendance