-
Notifications
You must be signed in to change notification settings - Fork 39
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
1 parent
1b2002f
commit 3882900
Showing
7 changed files
with
219 additions
and
78 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { BellIcon } from "@/components/icons"; | ||
import ActiveIconButtonLink from "./ActiveIconButtonLink"; | ||
import { useEffect, useState } from "react"; | ||
|
||
import { getUserNotificationCount } from "@/lib/api"; | ||
|
||
const NotificationButton = ({ user }) => { | ||
const [notificationCount, setNotificationCount] = useState(0); | ||
|
||
useEffect(() => { | ||
const fetchNotificationCount = async () => { | ||
const nc = await getUserNotificationCount({ | ||
user, | ||
pageSize: 10, | ||
offset: 0, | ||
}); | ||
|
||
if (nc?.userNotifications?.count || nc?.userNotifications?.count===0) { | ||
setNotificationCount(nc?.userNotifications?.count); | ||
} | ||
}; | ||
|
||
if (user?.isLoggedIn) { | ||
fetchNotificationCount(); | ||
} | ||
}, [user?.isLoggedIn]); | ||
|
||
return ( | ||
<div className="mr-3"> | ||
<ActiveIconButtonLink href="/notifications"> | ||
<BellIcon className={"mx-auto"} size={22} /> | ||
{notificationCount > 0 && ( | ||
<div className="absolute -top-0 mt-[3px] right-1 flex flex-col justify-center bg-blue-600 text-center mr-[10px] text-white text-[10px] rounded-full h-[14px] w-[14px] leading-none"> | ||
<div className="leading-none my-auto text-center">{notificationCount>10?'10+':notificationCount}</div> | ||
</div> | ||
)} | ||
</ActiveIconButtonLink> | ||
</div> | ||
); | ||
}; | ||
export default NotificationButton; |
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,19 @@ | ||
const NotificationEmptyState = () =>{ | ||
return( | ||
<div className="mx-auto w-full rounded-lg border border-gray-300"> | ||
<div className="pt-20 pb-20 px-6"> | ||
<img | ||
width="150" | ||
className=" mx-auto" | ||
src="https://letter-so.s3.amazonaws.com/prototypr/6dd2bd90-2c61-4163-bd5d-720567a692e6.png" | ||
style={{ opacity: "0.92" }} | ||
/> | ||
<h1 className="text-lg text-gray-500 pt-0 mt-4 mb-8 text-center"> | ||
No notifications yet. | ||
</h1> | ||
</div> | ||
</div> | ||
) | ||
} | ||
|
||
export default NotificationEmptyState |
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.