+
{userData.displayName}
diff --git a/src/components/header/data.tsx b/src/components/header/data.tsx
index 59fe0207..c95e1a11 100644
--- a/src/components/header/data.tsx
+++ b/src/components/header/data.tsx
@@ -1,3 +1,4 @@
+'use client'
import {
CalendarIcon,
CircleUserIcon,
diff --git a/src/components/header/header-server.tsx b/src/components/header/header-server.tsx
index 56d0d38b..e8481987 100644
--- a/src/components/header/header-server.tsx
+++ b/src/components/header/header-server.tsx
@@ -3,6 +3,8 @@ import SidebarResizable from '@/components/header/header-resizable'
import MobileNav from '@/components/header/mobile-nav'
import { createSessionServerClient } from '@/app/appwrite-session'
+export const dynamic = 'force-dynamic'
+
export default async function HeaderServer({
children,
locale,
diff --git a/src/utils/server-api/account/user.ts b/src/utils/server-api/account/user.ts
index 28d2930c..ec6da6a5 100644
--- a/src/utils/server-api/account/user.ts
+++ b/src/utils/server-api/account/user.ts
@@ -1,3 +1,4 @@
+'use server'
import { createSessionServerClient } from '@/app/appwrite-session'
import { Models } from 'node-appwrite'
import { Account } from '@/utils/types/models'
diff --git a/src/utils/server-api/notifications/getUserNotifications.ts b/src/utils/server-api/notifications/getUserNotifications.ts
new file mode 100644
index 00000000..03f0b809
--- /dev/null
+++ b/src/utils/server-api/notifications/getUserNotifications.ts
@@ -0,0 +1,7 @@
+import { createSessionServerClient } from '@/app/appwrite-session'
+import { Notifications } from '@/utils/types/models'
+
+export async function getUserNotifications(): Promise {
+ const { databases } = await createSessionServerClient()
+ return await databases.listDocuments('hp_db', 'user-notifications')
+}
diff --git a/src/utils/server-api/user/getUserData.ts b/src/utils/server-api/user/getUserData.ts
index be0f1798..3cf688ad 100644
--- a/src/utils/server-api/user/getUserData.ts
+++ b/src/utils/server-api/user/getUserData.ts
@@ -1,6 +1,8 @@
import { createSessionServerClient } from '@/app/appwrite-session'
import { UserData } from '@/utils/types/models'
import { Query } from 'node-appwrite'
+import { getUser } from '@/utils/server-api/account/user'
+import { unstable_noStore } from 'next/cache'
/**
* This function is used to get the user data.
@@ -10,6 +12,7 @@ import { Query } from 'node-appwrite'
export async function getUserDataFromProfileUrl(
profileUrl: string
): Promise {
+ unstable_noStore()
const { databases } = await createSessionServerClient()
return await databases
.listDocuments('hp_db', 'userdata', [Query.equal('profileUrl', profileUrl)])
@@ -18,16 +21,32 @@ export async function getUserDataFromProfileUrl(
})
}
+/**
+ * This function is used to get the user data from the user id.
+ * @example
+ * const userData = await getUserDataSingle('userId')
+ */
+export async function getUserDataSingle(
+ userId: string
+): Promise {
+ unstable_noStore()
+ const { databases } = await createSessionServerClient()
+ return await databases
+ .getDocument('hp_db', 'userdata', `${userId}`)
+ .catch((error) => {
+ return error
+ })
+}
+
/**
* This function is used to get the user data.
* @example
* const userData = await getUserData()
*/
export async function getUserData(): Promise {
- const { account, databases } = await createSessionServerClient()
- const accountData = await account.get().catch((error) => {
- return error
- })
+ unstable_noStore()
+ const { databases } = await createSessionServerClient()
+ const accountData = await getUser()
return await databases
.getDocument('hp_db', 'userdata', `${accountData.$id}`)
.catch((error) => {
@@ -41,6 +60,7 @@ export async function getUserData(): Promise {
* const userData = await getUserDataList()
*/
export async function getUserDataList(): Promise {
+ unstable_noStore()
const { databases } = await createSessionServerClient()
return await databases.listDocuments('hp_db', 'userdata').catch((error) => {
return error
diff --git a/src/utils/types/models.ts b/src/utils/types/models.ts
index 8a9f39bc..37ea764c 100644
--- a/src/utils/types/models.ts
+++ b/src/utils/types/models.ts
@@ -358,3 +358,29 @@ export namespace Community {
communityId: string
}
}
+
+export namespace Notifications {
+ export interface NotificationsType {
+ total: number
+ documents: NotificationsDocumentsType[]
+ }
+
+ export interface NotificationsDocumentsType extends Models.Document {
+ /**
+ * The title of the notification.
+ */
+ message: string
+ /**
+ * The user ID of the user that received the notification.
+ */
+ userId: string
+ /**
+ * The description of the notification.
+ */
+ read: boolean
+ /**
+ * The date the notification was created.
+ */
+ type: 'newFollower'
+ }
+}