feat(medusa, medusa-js, medusa-react): Add endpoint to retrieve product tags from the storefront (#3051)
This commit is contained in:
@@ -1,16 +1,16 @@
|
||||
export * from "./products/"
|
||||
export * from "./product-types/"
|
||||
export * from "./carts/"
|
||||
export * from "./shipping-options/"
|
||||
export * from "./regions/"
|
||||
export * from "./return-reasons/"
|
||||
export * from "./swaps/"
|
||||
export * from "./carts/"
|
||||
export * from "./orders/"
|
||||
export * from "./order-edits"
|
||||
export * from "./collections"
|
||||
export * from "./customers/"
|
||||
export * from "./returns/"
|
||||
export * from "./gift-cards/"
|
||||
export * from "./line-items/"
|
||||
export * from "./collections"
|
||||
export * from "./order-edits"
|
||||
export * from "./orders/"
|
||||
export * from "./payment-collections"
|
||||
export * from "./product-tags"
|
||||
export * from "./product-types/"
|
||||
export * from "./products/"
|
||||
export * from "./regions/"
|
||||
export * from "./return-reasons/"
|
||||
export * from "./returns/"
|
||||
export * from "./shipping-options/"
|
||||
export * from "./swaps/"
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
export * from "./queries"
|
||||
@@ -0,0 +1,32 @@
|
||||
import {
|
||||
StoreGetProductTagsParams,
|
||||
StoreProductTagsListRes,
|
||||
} from "@medusajs/medusa"
|
||||
import { Response } from "@medusajs/medusa-js"
|
||||
import { useQuery } from "@tanstack/react-query"
|
||||
import { useMedusa } from "../../../contexts"
|
||||
import { UseQueryOptionsWrapper } from "../../../types"
|
||||
import { queryKeysFactory } from "../../utils"
|
||||
|
||||
const PRODUCT_TAGS_QUERY_KEY = `product_tags` as const
|
||||
|
||||
export const productTagKeys = queryKeysFactory(PRODUCT_TAGS_QUERY_KEY)
|
||||
|
||||
type ProductTypesQueryKeys = typeof productTagKeys
|
||||
|
||||
export const useProductTags = (
|
||||
query?: StoreGetProductTagsParams,
|
||||
options?: UseQueryOptionsWrapper<
|
||||
Response<StoreProductTagsListRes>,
|
||||
Error,
|
||||
ReturnType<ProductTypesQueryKeys["list"]>
|
||||
>
|
||||
) => {
|
||||
const { client } = useMedusa()
|
||||
const { data, ...rest } = useQuery(
|
||||
productTagKeys.list(query),
|
||||
() => client.productTags.list(query),
|
||||
options
|
||||
)
|
||||
return { ...data, ...rest } as const
|
||||
}
|
||||
Reference in New Issue
Block a user