-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Vacation Mode feature to turn off notifications.
- Loading branch information
Showing
27 changed files
with
335 additions
and
35 deletions.
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
Binary file renamed
BIN
+2 MB
...ore-npm-0.1.134-7afa150efe-7c70811a33.zip → ...e/tno-core-file-43eb2cf690-8288ebf2bf.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
76 changes: 76 additions & 0 deletions
76
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,76 @@ | ||
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 }, { storeMyProfile, storeImpersonate }] = useProfileStore(); | ||
const isVacationMode: boolean = !!impersonate | ||
? impersonate?.preferences?.isVacationMode ?? false | ||
: profile?.preferences?.isVacationMode ?? false; | ||
|
||
const toggleVacationMode = React.useCallback(async () => { | ||
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 { | ||
!!impersonate ? storeImpersonate(user) : storeMyProfile(user); | ||
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); | ||
} | ||
}, [profile, impersonate, isVacationMode, storeImpersonate, storeMyProfile, 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} | ||
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'; |
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
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 |
---|---|---|
|
@@ -562,4 +562,4 @@ join u in this.Context.Users on ud.LinkedUserId equals u.Id | |
select u).ToArray(); | ||
} | ||
#endregion | ||
} | ||
} |
Oops, something went wrong.