Skip to content
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

Added button to disable all alarms #19

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions components/modals/AlarmConfigModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { alert1, alert2, alert3, alert4, alert5, alert6 } from '../../sounds'
import useLocalStorage from '@olerichter00/use-localstorage'
import { IconVolume2, IconVolume3 } from '@tabler/icons'
import { useTranslation } from 'next-i18next'
import { DateTime } from 'luxon'

const sounds = {
'Alert 1': alert1,
Expand Down Expand Up @@ -54,6 +55,18 @@ const AlarmConfigModal = () => {
const [disabledAlarms, setDisabledAlarms] = useLocalStorage<{
[key: string]: number
}>('disabledAlarms', {})
const disableAllAlarms = () => {
Object.entries(
require('../../data/events.json')
).forEach((e) => {
const [id] = e;
disabledAlarms[id] = DateTime.now().plus({ hours: 336 }).toMillis();

setDisabledAlarms({
...disabledAlarms,
});
})
}
const [volume, setVolume] = useLocalStorage('volume', 0.4)
return (
<>
Expand Down Expand Up @@ -119,6 +132,14 @@ const AlarmConfigModal = () => {
{t('reset-disabled-events')}
</button>
</div>
<div className="flex w-full items-center">
<button
className="btn btn-error btn-xs mx-auto mt-2"
onClick={(e) => disableAllAlarms()}
>
{t('disable-all-events')}
</button>
</div>
</div>
<div className="w-full">
<label className="label mr-2 cursor-pointer">
Expand Down
3 changes: 2 additions & 1 deletion public/locales/en/alarmConfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@
"reset-disabled-events": "Reset Disabled Events",
"alert-sound": "Alert Sound",
"muted": "Muted",
"enable-desktop-notifications": "Enable Desktop Notifications"
"enable-desktop-notifications": "Enable Desktop Notifications",
"disable-all-events": "Disable All Events"
}