Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
0797396
feat: update setup component for notification modal
kushagrasarathe Sep 9, 2025
dd31bc9
feat: notifications pop-up, ui and hook
kushagrasarathe Sep 9, 2025
c2bbb0d
feat: use react sdk methods from onesignal
kushagrasarathe Sep 9, 2025
4577606
Merge branch 'peanut-wallet-dev' into feat/notifications
kushagrasarathe Sep 10, 2025
5ec9b93
Merge branch 'peanut-wallet-dev' into feat/notifications
kushagrasarathe Sep 10, 2025
9623812
Merge branch 'peanut-wallet-dev' into feat/notifications
kushagrasarathe Sep 17, 2025
358d7d7
Merge branch 'peanut-wallet-dev' into feat/notifications
kushagrasarathe Sep 23, 2025
bc7a06a
feat: resolve cr comments
kushagrasarathe Sep 23, 2025
0b2f69b
Merge branch 'peanut-wallet-dev' into feat/notifications
kushagrasarathe Sep 23, 2025
8e01811
feat: notifications routes sevice
kushagrasarathe Sep 23, 2025
835f7b0
feat: homepage notification bell for navigation
kushagrasarathe Sep 23, 2025
c1baee2
feat: notificaitons page
kushagrasarathe Sep 23, 2025
b295e82
fix: resolve more cr comments
kushagrasarathe Sep 23, 2025
88af85c
fix: notif modal ux copy
kushagrasarathe Sep 23, 2025
940e0bb
Merge branch 'feat/notifications-fixed' into feat/notifications-center
kushagrasarathe Sep 23, 2025
345febd
chore: format
kushagrasarathe Sep 23, 2025
3eff7ad
fix: pr review comments #1
kushagrasarathe Sep 24, 2025
e89783c
fix: more pr review comments #2
kushagrasarathe Sep 24, 2025
351e9fe
Merge branch 'feat/notifications-fixed' into feat/notifications-center
kushagrasarathe Sep 24, 2025
c9774fb
feat: add error state in notis page
kushagrasarathe Sep 24, 2025
2ffda52
chore: style
kushagrasarathe Sep 24, 2025
c49c5d7
fix: resolve cr comment
kushagrasarathe Sep 24, 2025
e352b5f
Merge pull request #1248 from peanutprotocol/feat/notifications-center
kushagrasarathe Sep 24, 2025
9c8dad4
feat: auto mark notif on read when user visits notifs page
kushagrasarathe Sep 29, 2025
a5a9397
Merge branch 'peanut-wallet-dev' into feat/notifications-fixed
kushagrasarathe Sep 30, 2025
1b8f4ae
Merge branch 'peanut-wallet-dev' into feat/notifications-fixed
kushagrasarathe Oct 1, 2025
99358f3
fix: update notifications setup modal ui
kushagrasarathe Oct 1, 2025
bc8e290
feat: use banners corousel for notifs banner
kushagrasarathe Oct 1, 2025
276f416
fix: notif hub responsiveness
kushagrasarathe Oct 1, 2025
7281c38
feat: mark notif read on click
kushagrasarathe Oct 2, 2025
8ae0b8d
Merge branch 'peanut-wallet-dev' into feat/notifications-fixed
kushagrasarathe Oct 2, 2025
5dc62d2
fix: notifs modal/banner state related issues
kushagrasarathe Oct 6, 2025
1683e4f
Merge branch 'peanut-wallet-dev' into feat/notifications-fixed
kushagrasarathe Oct 6, 2025
e13e7dc
fix: try short delays for banner
kushagrasarathe Oct 6, 2025
55a8b96
fix: double click issue
kushagrasarathe Oct 6, 2025
90c72c8
fix: show only one modal at a time
kushagrasarathe Oct 6, 2025
a76fea8
Merge branch 'peanut-wallet-dev' into feat/notifications-fixed
kushagrasarathe Oct 7, 2025
7f953ef
fix: remove search from homepage
kushagrasarathe Oct 8, 2025
6140301
Merge branch 'peanut-wallet-dev' into feat/notifications-fixed
kushagrasarathe Oct 8, 2025
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
5 changes: 5 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,8 @@ export NEXT_PUBLIC_VAPID_PUBLIC_KEY=
export VAPID_PRIVATE_KEY=
export NEXT_PUBLIC_VAPID_SUBJECT="mailto:hello@peanut.to"
export NEXT_PUBLIC_FETCH_TIMEOUT_MS=10000

# one signal
export NEXT_PUBLIC_ONESIGNAL_APP_ID=
export NEXT_PUBLIC_SAFARI_WEB_ID=
export NEXT_PUBLIC_ONESIGNAL_WEBHOOK=
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
"react-fast-marquee": "^1.6.5",
"react-ga4": "^2.1.0",
"react-hook-form": "^7.53.2",
"react-onesignal": "^3.2.3",
"react-qr-code": "^2.0.15",
"react-redux": "^9.2.0",
"react-tooltip": "^5.28.0",
Expand Down
319 changes: 165 additions & 154 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions public/onesignal/OneSignalSDKWorker.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// use the stable v16 service worker path per onesignal docs
// note: onesignal does not publish minor-pinned sw paths; use v16 channel
importScripts('https://cdn.onesignal.com/sdks/web/v16/OneSignalSDK.sw.js')
94 changes: 57 additions & 37 deletions src/app/(mobile-ui)/home/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import PeanutLoading from '@/components/Global/PeanutLoading'
//import RewardsModal from '@/components/Global/RewardsModal'
import HomeHistory from '@/components/Home/HomeHistory'
//import RewardsCardModal from '@/components/Home/RewardsCardModal'
import { SearchUsers } from '@/components/SearchUsers'
import { UserHeader } from '@/components/UserHeader'
import { useAuth } from '@/context/authContext'
import { useWallet } from '@/hooks/wallet/useWallet'
Expand Down Expand Up @@ -38,6 +37,9 @@ import { PostSignupActionManager } from '@/components/Global/PostSignupActionMan
import { useWithdrawFlow } from '@/context/WithdrawFlowContext'
import { useClaimBankFlow } from '@/context/ClaimBankFlowContext'
import { useDeviceType, DeviceType } from '@/hooks/useGetDeviceType'
import SetupNotificationsModal from '@/components/Notifications/SetupNotificationsModal'
import { useNotifications } from '@/hooks/useNotifications'
import NotificationNavigation from '@/components/Notifications/NotificationNavigation'
import useKycStatus from '@/hooks/useKycStatus'
import HomeBanners from '@/components/Home/HomeBanners'
import InvitesIcon from '@/components/Home/InvitesIcon'
Expand All @@ -48,6 +50,7 @@ const BALANCE_WARNING_THRESHOLD = parseInt(process.env.NEXT_PUBLIC_BALANCE_WARNI
const BALANCE_WARNING_EXPIRY = parseInt(process.env.NEXT_PUBLIC_BALANCE_WARNING_EXPIRY ?? '1814400') // 21 days in seconds

export default function Home() {
const { showPermissionModal } = useNotifications()
const { balance, address, isFetchingBalance } = useWallet()
Comment thread
kushagrasarathe marked this conversation as resolved.
const { resetFlow: resetClaimBankFlow } = useClaimBankFlow()
const { resetWithdrawFlow } = useWithdrawFlow()
Expand All @@ -68,7 +71,7 @@ export default function Home() {
const [showAddMoneyPromptModal, setShowAddMoneyPromptModal] = useState(false)
const [showBalanceWarningModal, setShowBalanceWarningModal] = useState(false)
// const [showReferralCampaignModal, setShowReferralCampaignModal] = useState(false)
const [showPostSignupActionModal, setShowPostSignupActionModal] = useState(false)
const [isPostSignupActionModalVisible, setIsPostSignupActionModalVisible] = useState(false)

const userFullName = useMemo(() => {
if (!user) return
Expand Down Expand Up @@ -129,7 +132,7 @@ export default function Home() {
!isStandalone &&
!hasSeenModalThisSession &&
!user?.hasPwaInstalled &&
!showPostSignupActionModal &&
!isPostSignupActionModalVisible &&
!redirectUrl
) {
setShowIOSPWAInstallModal(true)
Expand All @@ -138,7 +141,7 @@ export default function Home() {
setShowIOSPWAInstallModal(false)
}
}
}, [user?.hasPwaInstalled, showPostSignupActionModal, deviceType])
}, [user?.hasPwaInstalled, isPostSignupActionModalVisible, deviceType])

// effect for showing balance warning modal
useEffect(() => {
Expand All @@ -157,7 +160,7 @@ export default function Home() {
!hasSeenBalanceWarning &&
!showIOSPWAInstallModal &&
!showAddMoneyPromptModal &&
!showPostSignupActionModal
!isPostSignupActionModalVisible
) {
setShowBalanceWarningModal(true)
}
Expand Down Expand Up @@ -189,33 +192,46 @@ export default function Home() {

// effect for showing add money prompt modal
useEffect(() => {
if (typeof window !== 'undefined' && !isFetchingBalance) {
const hasSeenAddMoneyPromptThisSession = sessionStorage.getItem('hasSeenAddMoneyPromptThisSession')
const showNoMoreJailModal = sessionStorage.getItem('showNoMoreJailModal')

// show if:
// 1. balance is zero.
// 2. user hasn't seen this prompt in the current session.
// 3. the iOS PWA install modal is not currently active.
// 4. the balance warning modal is not currently active.
// 5. the early user modal is not currently active.
// 6. the no more jail modal is not currently active.
// this allows the modal on any device (iOS/Android) and in any display mode (PWA/browser),
// as long as the PWA modal (which is iOS & browser-specific) isn't taking precedence.
if (
balance === 0n &&
!hasSeenAddMoneyPromptThisSession &&
!showIOSPWAInstallModal &&
!showBalanceWarningModal &&
!showPostSignupActionModal &&
showNoMoreJailModal !== 'true' &&
!user?.showEarlyUserModal // Give Early User and No more jail modal precedence, showing two modals together isn't ideal and it messes up their functionality
) {
setShowAddMoneyPromptModal(true)
sessionStorage.setItem('hasSeenAddMoneyPromptThisSession', 'true')
}
if (typeof window === 'undefined' || isFetchingBalance || !user) return
const hasSeenAddMoneyPromptThisSession = sessionStorage.getItem('hasSeenAddMoneyPromptThisSession')
const showNoMoreJailModal = sessionStorage.getItem('showNoMoreJailModal')

// determine if we should show the add money modal based on all conditions
// show if:
// 1. balance is zero.
// 2. user hasn't seen this prompt in the current session.
// 3. setup notifications modal is not visible (priority: setup modal > add money prompt)
// 4. the iOS PWA install modal is not currently active.
// 5. the balance warning modal is not currently active.
// 6. no other post-signup modal is active
const shouldShow =
balance === 0n &&
!hasSeenAddMoneyPromptThisSession &&
!showPermissionModal &&
!showIOSPWAInstallModal &&
!showBalanceWarningModal &&
!isPostSignupActionModalVisible &&
showNoMoreJailModal !== 'true' &&
!user?.showEarlyUserModal // Give Early User and No more jail modal precedence, showing two modals together isn't ideal and it messes up their functionality

if (shouldShow) {
setShowAddMoneyPromptModal(true)
sessionStorage.setItem('hasSeenAddMoneyPromptThisSession', 'true')
} else if (showAddMoneyPromptModal && showPermissionModal) {
// priority enforcement: hide add money modal if notification modal appears
// this handles race conditions where both modals try to show simultaneously
setShowAddMoneyPromptModal(false)
}
}, [balance, isFetchingBalance, showIOSPWAInstallModal, showBalanceWarningModal])
}, [
balance,
isFetchingBalance,
showPermissionModal,
showIOSPWAInstallModal,
showBalanceWarningModal,
isPostSignupActionModalVisible,
showAddMoneyPromptModal,
user,
])

if (isLoading) {
return <PeanutLoading coverFullScreen />
Expand All @@ -226,11 +242,13 @@ export default function Home() {
<div className="h-full w-full space-y-6 p-5">
<div className="flex items-center justify-between gap-2">
<UserHeader username={username!} fullName={userFullName} isVerified={isUserKycApproved} />
<div className="flex items-center gap-2">
<Link href="/points">
<InvitesIcon />
</Link>
<SearchUsers />
<div className="flex items-center">
<div className="flex items-center gap-2">
<Link href="/points">
<InvitesIcon />
</Link>
<NotificationNavigation />
</div>
</div>
</div>
<div className="space-y-4">
Expand Down Expand Up @@ -260,6 +278,8 @@ export default function Home() {

<HomeBanners />

{showPermissionModal && <SetupNotificationsModal />}

<HomeHistory username={username ?? undefined} />
{/* Render the new Rewards Modal
<RewardsModal />
Expand Down Expand Up @@ -298,7 +318,7 @@ export default function Home() {
{/* <FloatingReferralButton onClick={() => setShowReferralCampaignModal(true)} /> */}

{/* Post Signup Action Modal */}
<PostSignupActionManager onActionModalVisibilityChange={setShowPostSignupActionModal} />
<PostSignupActionManager onActionModalVisibilityChange={setIsPostSignupActionModalVisible} />
</PageContainer>
)
}
Expand Down
Loading
Loading