-
Notifications
You must be signed in to change notification settings - Fork 468
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
21 changed files
with
1,457 additions
and
338 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
53 changes: 53 additions & 0 deletions
53
apps/web/src/components/notification-center/NotificationRenewal/index.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,53 @@ | ||
import { useState, type ReactElement } from 'react' | ||
import { Alert, Box, Button, Typography } from '@mui/material' | ||
import useSafeInfo from '@/hooks/useSafeInfo' | ||
import CheckWallet from '@/components/common/CheckWallet' | ||
import { useNotificationsRenewal } from '@/components/settings/PushNotifications/hooks/useNotificationsRenewal' | ||
import { useIsNotificationsRenewalEnabled } from '@/components/settings/PushNotifications/hooks/useNotificationsTokenVersion' | ||
import { RENEWAL_MESSAGE } from '@/components/settings/PushNotifications/constants' | ||
|
||
const NotificationRenewal = (): ReactElement => { | ||
const { safe } = useSafeInfo() | ||
const [isRegistering, setIsRegistering] = useState(false) | ||
const { renewNotifications, needsRenewal } = useNotificationsRenewal() | ||
const isNotificationsRenewalEnabled = useIsNotificationsRenewalEnabled() | ||
|
||
if (!needsRenewal || !isNotificationsRenewalEnabled) { | ||
// No need to renew any Safe's notifications | ||
return <></> | ||
} | ||
|
||
const handeSignClick = async () => { | ||
setIsRegistering(true) | ||
await renewNotifications() | ||
setIsRegistering(false) | ||
} | ||
|
||
return ( | ||
<> | ||
<Alert severity="warning"> | ||
<Typography variant="body2" fontWeight={700} mb={1}> | ||
Signature needed | ||
</Typography> | ||
<Typography variant="body2">{RENEWAL_MESSAGE}</Typography> | ||
</Alert> | ||
<Box> | ||
<CheckWallet allowNonOwner checkNetwork={!isRegistering && safe.deployed}> | ||
{(isOk) => ( | ||
<Button | ||
variant="contained" | ||
size="small" | ||
sx={{ width: '200px' }} | ||
onClick={handeSignClick} | ||
disabled={!isOk || isRegistering || !safe.deployed} | ||
> | ||
Sign now | ||
</Button> | ||
)} | ||
</CheckWallet> | ||
</Box> | ||
</> | ||
) | ||
} | ||
|
||
export default NotificationRenewal |
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
3 changes: 3 additions & 0 deletions
3
apps/web/src/components/settings/PushNotifications/constants.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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export const RENEWAL_NOTIFICATION_KEY = 'renewal' | ||
export const RENEWAL_MESSAGE = | ||
'We’ve upgraded your notification experience! To continue receiving important updates seamlessly, you’ll need to sign this message on every chain you use.' |
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.