feat: Implement notifications feed (#8224)
Designs: https://www.figma.com/design/z3aUuOVWUKmdHH0ofmMpEV/Web-app-3.0?node-id=10-50&t=9k6K9k7oJh5tIi09-0  CLOSES CC-219
This commit is contained in:
@@ -29,3 +29,4 @@ export * from "./tax-rates"
|
||||
export * from "./tax-regions"
|
||||
export * from "./users"
|
||||
export * from "./workflow-executions"
|
||||
export * from "./notification"
|
||||
|
||||
51
packages/admin-next/dashboard/src/hooks/api/notification.tsx
Normal file
51
packages/admin-next/dashboard/src/hooks/api/notification.tsx
Normal file
@@ -0,0 +1,51 @@
|
||||
import { QueryKey, UseQueryOptions, useQuery } from "@tanstack/react-query"
|
||||
|
||||
import { HttpTypes } from "@medusajs/types"
|
||||
import { sdk } from "../../lib/client"
|
||||
import { queryKeysFactory } from "../../lib/query-key-factory"
|
||||
|
||||
const NOTIFICATION_QUERY_KEY = "notification" as const
|
||||
export const notificationQueryKeys = queryKeysFactory(NOTIFICATION_QUERY_KEY)
|
||||
|
||||
export const useNotification = (
|
||||
id: string,
|
||||
query?: Record<string, any>,
|
||||
options?: Omit<
|
||||
UseQueryOptions<
|
||||
HttpTypes.AdminNotificationResponse,
|
||||
Error,
|
||||
HttpTypes.AdminNotificationResponse,
|
||||
QueryKey
|
||||
>,
|
||||
"queryFn" | "queryKey"
|
||||
>
|
||||
) => {
|
||||
const { data, ...rest } = useQuery({
|
||||
queryKey: notificationQueryKeys.detail(id),
|
||||
queryFn: async () => sdk.admin.notification.retrieve(id, query),
|
||||
...options,
|
||||
})
|
||||
|
||||
return { ...data, ...rest }
|
||||
}
|
||||
|
||||
export const useNotifications = (
|
||||
query?: HttpTypes.AdminNotificationListParams,
|
||||
options?: Omit<
|
||||
UseQueryOptions<
|
||||
HttpTypes.AdminNotificationListResponse,
|
||||
Error,
|
||||
HttpTypes.AdminNotificationListResponse,
|
||||
QueryKey
|
||||
>,
|
||||
"queryFn" | "queryKey"
|
||||
>
|
||||
) => {
|
||||
const { data, ...rest } = useQuery({
|
||||
queryFn: () => sdk.admin.notification.list(query),
|
||||
queryKey: notificationQueryKeys.list(query),
|
||||
...options,
|
||||
})
|
||||
|
||||
return { ...data, ...rest }
|
||||
}
|
||||
Reference in New Issue
Block a user