-
Notifications
You must be signed in to change notification settings - Fork 111
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 #235 from Ibinola/feat/notification-window
(wip)feat: add notification window
- Loading branch information
Showing
6 changed files
with
271 additions
and
4 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
48 changes: 48 additions & 0 deletions
48
frontend/src/components/TelegramNotificationModal/TelegramNotificationModal.jsx
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,48 @@ | ||
import React from 'react'; | ||
import './telegramNotificationModal.css'; | ||
import useTelegramNotification from 'hooks/useTelegramNotification'; | ||
import { Notifier } from 'components/Notifier/Notifier'; | ||
|
||
const TelegramNotificationModal = ({ onClose, telegramId, walletId }) => { | ||
const { subscribe, isLoading } = useTelegramNotification(); | ||
|
||
const handleSubscribe = () => { | ||
subscribe({ telegramId, walletId }); | ||
}; | ||
|
||
return ( | ||
<div className="notification-overlay"> | ||
<Notifier /> | ||
<div className="notification-backdrop" onClick={onClose} /> | ||
<div className="notification-wrapper"> | ||
<div className="notification-box"> | ||
<div className="notification-content"> | ||
<div className="notification-title">Telegram Notification</div> | ||
<h2> | ||
Do you want to enable telegram <br /> | ||
notification bot? | ||
</h2> | ||
<p> | ||
This will allow you to receive quick notifications on your telegram line in realtime. You can disable this | ||
setting anytime. | ||
</p> | ||
</div> | ||
<div className="notification-actions"> | ||
<button onClick={onClose} className="notification-btn notification-cancel-btn" disabled={isLoading}> | ||
Cancel | ||
</button> | ||
<button | ||
onClick={handleSubscribe} | ||
className="notification-btn notification-confirm-btn" | ||
disabled={isLoading} | ||
> | ||
{isLoading ? 'Subscribing...' : 'Yes, Sure'} | ||
</button> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default TelegramNotificationModal; |
163 changes: 163 additions & 0 deletions
163
frontend/src/components/TelegramNotificationModal/telegramNotificationModal.css
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,163 @@ | ||
.notification-overlay { | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
position: fixed; | ||
top: 0; | ||
left: 0; | ||
width: 100%; | ||
height: 100%; | ||
background: var(--spinner-bgn); | ||
z-index: 9999; | ||
} | ||
|
||
.notification-backdrop { | ||
position: absolute; | ||
top: 0; | ||
left: 0; | ||
right: 0; | ||
bottom: 0; | ||
} | ||
|
||
.notification-wrapper { | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
max-width: 800px; | ||
width: 90%; | ||
box-shadow: var(--primary-color); | ||
overflow: hidden; | ||
} | ||
|
||
.notification-box { | ||
border-radius: 16px; | ||
max-width: 642px; | ||
width: 100%; | ||
display: flex; | ||
flex-direction: column; | ||
gap: 24px; | ||
text-align: center; | ||
} | ||
|
||
.notification-content { | ||
text-align: center; | ||
padding: 24px; | ||
border: var(--nav-divider-bg) 1px solid; | ||
background-color: var(--header-button-bg); | ||
border-radius: 48px; | ||
} | ||
|
||
.notification-title { | ||
color: var(--primary); | ||
text-align: center; | ||
font-size: 16px; | ||
padding-bottom: 10px; | ||
border-bottom: 1px solid rgba(255, 255, 255, 0.1); | ||
margin-bottom: 24px; | ||
} | ||
|
||
.notification-content h2 { | ||
color: var(--primary); | ||
font-size: 24px; | ||
font-weight: 500; | ||
margin-bottom: 16px; | ||
line-height: 1.3; | ||
} | ||
|
||
.notification-content p { | ||
color: var(--second-primary); | ||
font-size: 16px; | ||
line-height: 1.5; | ||
max-width: 380px; | ||
margin: 0 auto; | ||
} | ||
|
||
.notification-actions { | ||
display: flex; | ||
gap: 16px; | ||
} | ||
|
||
.notification-btn { | ||
flex: 1; | ||
padding: 20px 16px; | ||
border-radius: 40px; | ||
font-size: 16px; | ||
font-weight: bold; | ||
background-color: var(--plain-button-bg); | ||
cursor: pointer; | ||
} | ||
|
||
.notification-cancel-btn { | ||
color: var(--primary); | ||
position: relative; | ||
border: none; | ||
} | ||
|
||
.notification-cancel-btn::before { | ||
content: ''; | ||
position: absolute; | ||
top: 0; | ||
left: 0; | ||
right: 0; | ||
bottom: 0; | ||
border-radius: 40px; | ||
padding: 1px; | ||
background: var(--button-gradient); | ||
mask: | ||
linear-gradient(#fff 0 0) content-box, | ||
linear-gradient(#fff 0 0); | ||
-webkit-mask: | ||
linear-gradient(#fff 0 0) content-box, | ||
linear-gradient(#fff 0 0); | ||
-webkit-mask-composite: xor; | ||
mask-composite: exclude; | ||
} | ||
|
||
.notification-confirm-btn { | ||
color: var(--primary); | ||
background: var(--second-gradient); | ||
border: none; | ||
} | ||
|
||
/* Mobile Styles */ | ||
@media screen and (max-width: 768px) { | ||
.notification-wrapper { | ||
max-width: 390px; | ||
width: 100%; | ||
padding: 20px; | ||
} | ||
|
||
.notification-title { | ||
font-size: 14px; | ||
padding-bottom: 8px; | ||
margin-bottom: 16px; | ||
} | ||
|
||
.notification-content h2 { | ||
font-size: 16px; | ||
margin-bottom: 12px; | ||
} | ||
|
||
.notification-content p { | ||
font-size: 14px; | ||
max-width: 320px; | ||
} | ||
|
||
.notification-actions { | ||
gap: 8px; | ||
} | ||
|
||
.notification-btn { | ||
padding: 20px 8px; | ||
border-radius: 16px; | ||
font-size: 14px; | ||
} | ||
|
||
.notification-cancel-btn::before { | ||
border-radius: 16px; | ||
} | ||
|
||
.notification-confirm-btn { | ||
font-size: 14px; | ||
} | ||
} |
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,23 @@ | ||
import { useMutation } from "@tanstack/react-query"; | ||
import { subscribeToNotification } from "services/telegram"; | ||
import { notifyError, notifySuccess } from "utils/notification"; | ||
|
||
const useTelegramNotification = () => { | ||
const mutation = useMutation({ | ||
mutationFn: ({ telegramId, walletId }) => | ||
subscribeToNotification(telegramId, walletId), | ||
onSuccess: () => { | ||
notifySuccess("Subscribed to notifications successfully!"); | ||
}, | ||
onError: (error) => { | ||
notifyError(error?.message || "Failed to subscribe. Please try again."); | ||
}, | ||
}); | ||
|
||
return { | ||
subscribe: mutation.mutate, | ||
isLoading: mutation.isPending, | ||
}; | ||
}; | ||
|
||
export default useTelegramNotification; |
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