This repository has been archived by the owner on Sep 5, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #75 from petitcl/gh-issue-72
Fix notifications settings that were not remembered
- Loading branch information
Showing
16 changed files
with
157 additions
and
128 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
67 changes: 67 additions & 0 deletions
67
src/app/Pages/ActiveDeals/Components/NotificationsSettings.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,67 @@ | ||
import { useAppSelector } from '@/app/redux/hooks'; | ||
import { Checkbox, FormControlLabel } from '@mui/material'; | ||
import React, { useState } from "react"; | ||
import { updateNotificationsSettingsGlobal } from '@/app/redux/configActions'; | ||
|
||
/** | ||
* | ||
* @returns Checkboxes for configuring the state of auto sync. | ||
*/ | ||
const NotificationsSettings = () => { | ||
|
||
const { enabled: storeEnabled, summary: storeSummary } = useAppSelector(state => state.config.config.globalSettings.notifications); | ||
|
||
const [summary, setSummary] = useState(() => storeEnabled) | ||
const [enabled, setEnabled] = useState(() => storeSummary) | ||
|
||
const changeSummary = (event: React.ChangeEvent<HTMLInputElement>) => { | ||
const checked = event.target.checked | ||
updateNotificationsSettingsGlobal({ summary: checked }) | ||
setSummary(checked) | ||
} | ||
|
||
const changeEnabled = (event: React.ChangeEvent<HTMLInputElement>) => { | ||
const checked = event.target.checked | ||
if(!checked) { | ||
updateNotificationsSettingsGlobal({ summary: false }) | ||
setSummary(false) | ||
} | ||
updateNotificationsSettingsGlobal({ enabled: checked }) | ||
setEnabled(checked) | ||
} | ||
|
||
return ( | ||
<div className="notificationsSettings"> | ||
<FormControlLabel | ||
control={ | ||
<Checkbox | ||
checked={enabled} | ||
onChange={changeEnabled} | ||
name="notifications" | ||
color="primary" | ||
style={{ color: 'var(--color-secondary)' }} | ||
|
||
/> | ||
} | ||
label="Enable Notifications" | ||
|
||
/> | ||
<FormControlLabel | ||
control={ | ||
<Checkbox | ||
checked={summary} | ||
onChange={changeSummary} | ||
name="summary" | ||
style={{ color: 'var(--color-secondary)' }} | ||
|
||
/> | ||
} | ||
label="Summarize Notifications" | ||
/> | ||
|
||
|
||
</div> | ||
) | ||
} | ||
|
||
export default NotificationsSettings; |
This file was deleted.
Oops, something went wrong.
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,8 +1,8 @@ | ||
|
||
import SyncToggles from "./SyncToggles"; | ||
import NotificationsSettings from "./NotificationsSettings"; | ||
import SubRowAsync from "./Subrow"; | ||
|
||
export { | ||
SyncToggles, | ||
NotificationsSettings, | ||
SubRowAsync | ||
} |
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
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.