Skip to content

Commit 82aee08

Browse files
committed
Add text to handle pagination
1 parent f98f21b commit 82aee08

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

public/locales/en/account.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
"userGuideLinkText": "User Guide",
5454
"demoServerLinkText": "Demo Site",
5555
"clearAll": "Clear All",
56+
"clearAllOnThisPage": "Clear All on This Page",
5657
"dismiss": "Dismiss",
5758
"noNotifications": "No notifications available.",
5859
"notification": {

src/sections/account/notifications-section/NotificationsSection.tsx

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,15 @@ export const NotificationsSection = ({ notificationRepository }: NotificationsSe
6262
if (isLoading) return <div>Loading...</div>
6363
if (error) return <div>{error}</div>
6464

65+
// compute display range
66+
const total = paginationInfo?.totalItems ?? notifications.length
67+
const page = Math.max(1, paginationInfo?.page ?? 1)
68+
const pageSize = Math.max(1, paginationInfo?.pageSize ?? (notifications.length || 1))
69+
const start = notifications.length === 0 ? 0 : (page - 1) * pageSize + 1
70+
const end = notifications.length === 0 ? 0 : Math.min(start + notifications.length - 1, total)
71+
const clearAllKey =
72+
total > pageSize ? 'notifications.clearAllOnThisPage' : 'notifications.clearAll'
73+
6574
return (
6675
<section>
6776
<div className="d-flex align-items-center gap-2 mb-2">
@@ -72,7 +81,7 @@ export const NotificationsSection = ({ notificationRepository }: NotificationsSe
7281
aria-label={t('notifications.clearAll')}
7382
onClick={handleClearAll}
7483
disabled={isLoading}>
75-
{t('notifications.clearAll')}
84+
{t(clearAllKey)}
7685
</Button>
7786
)}
7887

@@ -81,6 +90,11 @@ export const NotificationsSection = ({ notificationRepository }: NotificationsSe
8190

8291
{notifications.length > 0 ? (
8392
<div className="d-flex flex-column gap-2">
93+
<div
94+
className={
95+
styles['range-info']
96+
}>{`Displaying ${start}-${end} of ${total} Notifications`}</div>
97+
8498
{notifications.map((notification) => {
8599
const isRead = notification.displayAsRead || readIds.includes(notification.id)
86100
return (

0 commit comments

Comments
 (0)