From 542c64d3c68e43a31b4319d999c510bdee803666 Mon Sep 17 00:00:00 2001 From: Mohammed JBILOU <95973236+Molaryy@users.noreply.github.com> Date: Sun, 17 Dec 2023 17:52:04 +0100 Subject: [PATCH] feat: adding notification --- frontend/src/components/BreakTime.tsx | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/frontend/src/components/BreakTime.tsx b/frontend/src/components/BreakTime.tsx index ff38bfe..638c8a5 100644 --- a/frontend/src/components/BreakTime.tsx +++ b/frontend/src/components/BreakTime.tsx @@ -1,31 +1,29 @@ -/* -import { useEffect, useState } from 'react' +import { useEffect, useState } from 'react'; const requestNotificationPermission = () => { if (Notification.permission !== 'granted') { Notification.requestPermission().then((permission: NotificationPermission) => { if (permission !== 'granted') { - console.error('Notification permission granted.') + console.error('Notification permission granted.'); } - }) + }); } -} +}; const sendNotification = () => { - const [canSendNotification, setCanSendNotification] = useState(true) + const [canSendNotification, setCanSendNotification] = useState(true); if (Notification.permission === 'granted' && canSendNotification) { - new Notification('Take a break time') - setCanSendNotification(false) + new Notification('Take a break time'); + setCanSendNotification(false); } -} -*/ +}; const BreakTime = () => { - /* useEffect(() => { - requestNotificationPermission() - }, []) - sendNotification() */ + useEffect(() => { + requestNotificationPermission(); + }, []); + sendNotification(); return <>; };