-
Notifications
You must be signed in to change notification settings - Fork 17
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
TNO-2831: Vacation Switch feature #2203
Merged
Merged
Changes from 2 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
edae7f0
Vacation Mode feature to turn off notifications.
areyeslo 71182ab
Changes due to code review
areyeslo 3dda3ca
Adding bottom padding to show the toggle button in mobile devices.
areyeslo a0ba8d6
removing extra filtering in reportingManager
areyeslo 7b2c454
Upgrade tno-core version to 0.1.136
areyeslo 44324e5
Remove tgz files.
areyeslo 37c2e9e
make pack with 0.1.136 version.
areyeslo a8a6b06
update package.json
areyeslo d14408d
Modiying yarn file for subscriber and editor.
areyeslo 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
Binary file renamed
BIN
+2 MB
...e/tno-core-file-c87ea57144-065f8e9ffa.zip → ...e/tno-core-file-b0d54f0986-173bc87383.zip
Binary file not shown.
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
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. remove |
Binary file not shown.
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
Binary file removed
BIN
-19.9 KB
app/subscriber/.yarn/cache/react-chartjs-2-npm-5.2.0-03632f5179-ace702185b.zip
Binary file not shown.
Binary file renamed
BIN
+2 MB
...e/tno-core-file-43eb2cf690-065f8e9ffa.zip → ...e/tno-core-file-3ef86f24ce-173bc87383.zip
Binary file not shown.
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
82 changes: 82 additions & 0 deletions
82
app/subscriber/src/features/settings/MyAccountSettings.tsx
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,82 @@ | ||
import React from 'react'; | ||
import { FaEnvelope, FaToggleOff, FaToggleOn, FaUmbrellaBeach } from 'react-icons/fa'; | ||
import { toast } from 'react-toastify'; | ||
import { useUsers } from 'store/hooks'; | ||
import { useProfileStore } from 'store/slices'; | ||
import { ISubscriberUserModel, ToggleButton } from 'tno-core'; | ||
|
||
import * as styled from './styled'; | ||
|
||
const MyAccountSettings = () => { | ||
const { updateUser } = useUsers(); | ||
const [{ profile, impersonate }] = useProfileStore(); | ||
const isVacationMode: boolean = !!impersonate | ||
? impersonate?.preferences?.isVacationMode ?? false | ||
: profile?.preferences?.isVacationMode ?? false; | ||
|
||
const toggleVacationMode = React.useCallback( | ||
async ( | ||
profile: ISubscriberUserModel | undefined, | ||
impersonate: ISubscriberUserModel | undefined, | ||
isVacationMode: boolean, | ||
) => { | ||
if (!profile) { | ||
toast.error('User information is missing. Please try again later'); | ||
return; | ||
} | ||
const baseProfile = impersonate ?? profile; | ||
const createUser = (): ISubscriberUserModel => { | ||
// use impersonate if it exists, otherwise use profile | ||
return { | ||
...baseProfile, | ||
preferences: { | ||
...baseProfile.preferences, | ||
isVacationMode: isVacationMode, | ||
}, | ||
}; | ||
}; | ||
const user = createUser(); | ||
|
||
try { | ||
await updateUser(user, !!impersonate); | ||
toast.success('Vacation mode has successfully been updated.'); | ||
} catch (error) { | ||
// Handle the error, if needed | ||
console.error('Failed to update user:', error); | ||
} | ||
}, | ||
[updateUser], | ||
); | ||
|
||
return ( | ||
<styled.MyAccountSettings> | ||
<div className="header-row"> | ||
<FaEnvelope className="icon" /> | ||
<span className="header-text">E-mail notifications</span> | ||
</div> | ||
<p className="description"> | ||
Enabling vacation mode will <strong>turn off</strong> all MMI emails to you, until you | ||
disable vacation mode. This will include subscriptions to MMI Products, Alerts and Reports. | ||
</p> | ||
<div className="toggleContainer"> | ||
<ToggleButton | ||
on={<FaToggleOn />} | ||
off={<FaToggleOff />} | ||
onClick={() => toggleVacationMode(profile, impersonate, !isVacationMode)} | ||
width="25px" | ||
height="25px" | ||
color="#008000" | ||
label={ | ||
<span className="vacation-mode-label"> | ||
<FaUmbrellaBeach className="icon" /> | ||
Vacation Mode | ||
</span> | ||
} | ||
value={isVacationMode} | ||
/> | ||
</div> | ||
</styled.MyAccountSettings> | ||
); | ||
}; | ||
|
||
export default MyAccountSettings; |
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
1 change: 1 addition & 0 deletions
1
app/subscriber/src/features/settings/constants/SettingsSessionEnum.ts
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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
export enum SettingsSessionEnum { | ||
MyAccount = 'MyAccount', | ||
MyMinister = 'MyMinister', | ||
MyColleagues = 'MyColleagues', | ||
} |
47 changes: 47 additions & 0 deletions
47
app/subscriber/src/features/settings/styled/MyAccountSettings.tsx
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,47 @@ | ||
import styled from 'styled-components'; | ||
import { Col } from 'tno-core'; | ||
|
||
export const MyAccountSettings = styled(Col)` | ||
padding: 0.6em; | ||
|
||
.header-row { | ||
display: flex; | ||
align-items: center; | ||
font-size: 1rem; | ||
color: #333; | ||
margin-top: 0.5rem; | ||
margin-bottom: 0.25rem; | ||
margin-left: 0.75rem; | ||
border-bottom: 1px solid #ccc; | ||
|
||
.icon { | ||
font-size: 1.2rem; | ||
margin-right: 0.75rem; | ||
} | ||
|
||
.header-text { | ||
font-weight: bold; | ||
font-size: 1.1rem; | ||
} | ||
} | ||
|
||
.description { | ||
margin-left: 2.8rem; | ||
} | ||
|
||
.toggleContainer { | ||
display: flex; | ||
align-items: center; | ||
margin-left: 3rem; | ||
|
||
.vacation-mode-label { | ||
color: #008000; | ||
display: flex; | ||
align-items: center; | ||
} | ||
|
||
.icon { | ||
margin-right: 5px; | ||
} | ||
} | ||
`; |
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 |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export * from './MyAccountSettings'; | ||
export * from './MyMinisterSettings'; | ||
export * from './SettingsLanding'; |
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. remove |
Binary file not shown.
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. remove |
Binary file not shown.
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.
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.
Not needed. Vacation mode is just to turn off emails.
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 understood this part would send email using the email account of
To
property. So I checked the email account is not under VacationMode.