Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
sweepstake
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Arjun Jhukal
sweepstake
Commits
f8ad2c84
Commit
f8ad2c84
authored
Oct 07, 2025
by
Arjun Jhukal
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
updated the notification read functionality
parent
0f9f3779
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
40 additions
and
10 deletions
+40
-10
Notification.tsx
src/components/organism/Header/Notification.tsx
+35
-7
notificationApi.tsx
src/services/notificationApi.tsx
+4
-3
notification.ts
src/types/notification.ts
+1
-0
No files found.
src/components/organism/Header/Notification.tsx
View file @
f8ad2c84
...
...
@@ -17,6 +17,10 @@ import { Notification } from '@wandersonalwes/iconsax-react';
import
Link
from
'next/link'
;
import
{
NotificationProps
}
from
'@/types/notification'
;
import
{
Pagination
}
from
'@/types/game'
;
import
{
useReadNotificationMutation
}
from
'@/services/notificationApi'
;
import
{
useAppDispatch
}
from
'@/hooks/hook'
;
import
{
showToast
,
ToastVariant
}
from
'@/slice/toastSlice'
;
import
{
formatDateTime
}
from
'@/utils/formatDateTime'
;
export
default
function
NotificationPage
({
...
...
@@ -37,8 +41,28 @@ export default function NotificationPage({
};
const
id
=
open
?
'popper'
:
undefined
;
const
dispatch
=
useAppDispatch
();
// const [readNotification,{isLoading}]
const
[
readNotification
,
{
isLoading
}]
=
useReadNotificationMutation
();
const
handleNotificationClick
=
async
(
id
:
string
)
=>
{
try
{
const
response
=
await
readNotification
({
id
}).
unwrap
();
// dispatch(
// showToast({
// message: "Notification read successfully",
// variant: ToastVariant.SUCCESS
// })
// )
}
catch
(
e
:
any
)
{
dispatch
(
showToast
({
message
:
e
.
message
||
"Unable to read notification"
,
variant
:
ToastVariant
.
ERROR
})
)
}
}
return
(
<
Box
>
<
IconButton
...
...
@@ -48,7 +72,7 @@ export default function NotificationPage({
className=
"!bg-light-gray"
>
<
Badge
badgeContent=
{
notifications
.
length
}
badgeContent=
{
notifications
.
filter
((
item
)
=>
item
.
has_read
===
false
).
length
}
color=
"success"
sx=
{
{
'& .MuiBadge-badge'
:
{
top
:
2
,
right
:
4
}
}
}
>
...
...
@@ -86,11 +110,15 @@ export default function NotificationPage({
notifications
.
length
?
(
<
List
className=
'max-h-[320px] overflow-auto px-1'
>
{
notifications
.
map
((
notification
,
index
)
=>
(
<
ListItem
className=
{
`border-b-solid border-b-gray-100 border-b-[1px] rounded-sm !p-2 cursor-pointer ${notification.has_read ? "" : "bg-gray-100"} ${index > 0 ? "mb-2 " : ""}`
}
key=
{
notification
.
id
}
>
<
p
className=
'text-[12px] lg:text-[14px] leading-[120%] text-title'
>
{
notification
.
message
}
</
p
>
</
ListItem
>
))
notifications
.
map
((
notification
,
index
)
=>
{
const
{
date
,
time
}
=
formatDateTime
(
notification
.
created_at
);
return
(
<
ListItem
className=
{
`border-b-solid border-b-gray-100 border-b-[1px] rounded-sm !p-2 cursor-pointer ${notification.has_read ? "" : "bg-gray-100"} ${index > 0 ? "mb-2 " : ""}`
}
key=
{
notification
.
id
}
onClick=
{
()
=>
handleNotificationClick
(
notification
.
id
)
}
>
<
p
className=
'text-[12px] lg:text-[14px] leading-[120%] text-title'
>
{
notification
.
message
}
</
p
>
<
p
className=
'text-[8px] mt-1 lg:text-[14px] leading-[120%] text-para-light'
>
{
date
}
</
p
>
</
ListItem
>
)
})
}
</
List
>
)
:
(
...
...
src/services/notificationApi.tsx
View file @
f8ad2c84
...
...
@@ -26,9 +26,10 @@ export const notificationApi = createApi({
query
:
({
id
})
=>
({
url
:
`/api/admin/notification/
${
id
}
`
,
method
:
"POST"
,
})
}),
invalidatesTags
:
[
"Notification"
]
})
})
})
export
const
{
useGetAllNotificationQuery
}
=
notificationApi
\ No newline at end of file
export
const
{
useGetAllNotificationQuery
,
useReadNotificationMutation
}
=
notificationApi
\ No newline at end of file
src/types/notification.ts
View file @
f8ad2c84
...
...
@@ -4,6 +4,7 @@ export interface NotificationProps {
id
:
string
;
message
:
string
,
has_read
:
boolean
created_at
?:
string
;
}
export
interface
NotificationResponse
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment