-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
66 additions
and
19 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
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 |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// React and other libraries | ||
import { useState, useEffect } from 'react'; | ||
import { useNavigate } from 'react-router-dom'; | ||
|
||
// components | ||
import { notification, RewardPoints } from 'blocks'; | ||
|
||
export const useRewardsNotification = () => { | ||
const navigate = useNavigate(); | ||
const [showNotif, setShowNotif] = useState(false); | ||
|
||
const notificationAlreadyShown = localStorage.getItem('notificationShown') === 'true'; | ||
const isPointsPage = location?.pathname.includes('/points'); | ||
|
||
const showNotification = () => { | ||
notification.show({ | ||
title: 'Push Points are Live', | ||
description: 'Complete Tasks on Push. Check-in, Earn Push Points, Unlock Rewards and Level up!', | ||
image: <RewardPoints />, | ||
onClick: () => { | ||
navigate('/points'); | ||
localStorage.setItem('notificationShown', 'true'); | ||
notification.hide(); | ||
}, | ||
onClose: () => { | ||
localStorage.setItem('notificationShown', 'true'); | ||
}, | ||
}); | ||
setShowNotif(true); | ||
}; | ||
|
||
useEffect(() => { | ||
if (!isPointsPage && !notificationAlreadyShown) { | ||
if (!showNotif) showNotification(); | ||
} else { | ||
notification.hide(); | ||
setShowNotif(false); | ||
} | ||
}, [location?.pathname]); | ||
}; |
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