-
Notifications
You must be signed in to change notification settings - Fork 1
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
e944099
commit 75b4251
Showing
1 changed file
with
53 additions
and
53 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,58 +1,58 @@ | ||
import axios from "axios"; | ||
// import axios from "axios"; | ||
|
||
interface Notification { | ||
notifyId: number; | ||
title: string; | ||
content: string | null; | ||
senderProfileImgAccessUri: string; | ||
senderNickName: string; | ||
notificationType: "LIKE" | "COMMENT" | "FOLLOW"; | ||
createdAt: string; | ||
read: boolean; | ||
} | ||
let accessToken = ""; | ||
// interface Notification { | ||
// notifyId: number; | ||
// title: string; | ||
// content: string | null; | ||
// senderProfileImgAccessUri: string; | ||
// senderNickName: string; | ||
// notificationType: "LIKE" | "COMMENT" | "FOLLOW"; | ||
// createdAt: string; | ||
// read: boolean; | ||
// } | ||
// let accessToken = ""; | ||
|
||
async function fetchNotifications(): Promise<Notification[]> { | ||
const response = await axios.get( | ||
`${process.env.NEXT_PUBLIC_API_URL}/api/notify` | ||
); | ||
return response.data; | ||
} | ||
// async function fetchNotifications(): Promise<Notification[]> { | ||
// const response = await axios.get( | ||
// `${process.env.NEXT_PUBLIC_API_URL}/api/notify` | ||
// ); | ||
// return response.data; | ||
// } | ||
|
||
export default async function NotificationsPage() { | ||
const notifications = await fetchNotifications(); | ||
// export default async function NotificationsPage() { | ||
// const notifications = await fetchNotifications(); | ||
|
||
return ( | ||
<div className="p-4"> | ||
<h1 className="text-2xl font-bold mb-4">All Notifications</h1> | ||
<ul> | ||
{notifications.map((notification) => ( | ||
<li | ||
key={notification.notifyId} | ||
className="flex items-center mb-4 p-4 rounded-md shadow-lg" | ||
> | ||
<img | ||
src={notification.senderProfileImgAccessUri} | ||
alt="Profile" | ||
className="w-10 h-10 rounded-full mr-4" | ||
/> | ||
<div> | ||
<p className="font-semibold">{notification.title}</p> | ||
{notification.notificationType === "COMMENT" && | ||
notification.content && ( | ||
<p className="text-sm text-gray-600"> | ||
{truncateText(notification.content, 30)} | ||
</p> | ||
)} | ||
</div> | ||
</li> | ||
))} | ||
</ul> | ||
</div> | ||
); | ||
} | ||
// return ( | ||
// <div className="p-4"> | ||
// <h1 className="text-2xl font-bold mb-4">All Notifications</h1> | ||
// <ul> | ||
// {notifications.map((notification) => ( | ||
// <li | ||
// key={notification.notifyId} | ||
// className="flex items-center mb-4 p-4 rounded-md shadow-lg" | ||
// > | ||
// <img | ||
// src={notification.senderProfileImgAccessUri} | ||
// alt="Profile" | ||
// className="w-10 h-10 rounded-full mr-4" | ||
// /> | ||
// <div> | ||
// <p className="font-semibold">{notification.title}</p> | ||
// {notification.notificationType === "COMMENT" && | ||
// notification.content && ( | ||
// <p className="text-sm text-gray-600"> | ||
// {truncateText(notification.content, 30)} | ||
// </p> | ||
// )} | ||
// </div> | ||
// </li> | ||
// ))} | ||
// </ul> | ||
// </div> | ||
// ); | ||
// } | ||
|
||
const truncateText = (text: string, length: number) => { | ||
if (text.length <= length) return text; | ||
return text.substring(0, length) + "..."; | ||
}; | ||
// const truncateText = (text: string, length: number) => { | ||
// if (text.length <= length) return text; | ||
// return text.substring(0, length) + "..."; | ||
// }; |