fix: adds order by functionality to products (#1021)
* fix: adds order by functionality to products * feat: adds product tags list * fix: adds client and react support for product tags * fix: unit test * Update packages/medusa/src/services/product-tag.ts Co-authored-by: Oliver Windall Juhl <59018053+olivermrbl@users.noreply.github.com> * Update packages/medusa/src/services/product-tag.ts Co-authored-by: Oliver Windall Juhl <59018053+olivermrbl@users.noreply.github.com> * Update packages/medusa/src/services/product-tag.ts Co-authored-by: Oliver Windall Juhl <59018053+olivermrbl@users.noreply.github.com> * Update packages/medusa/src/services/product-tag.ts Co-authored-by: Oliver Windall Juhl <59018053+olivermrbl@users.noreply.github.com> * Update packages/medusa/src/services/product-tag.ts Co-authored-by: Oliver Windall Juhl <59018053+olivermrbl@users.noreply.github.com> * Update packages/medusa/src/services/product-tag.ts Co-authored-by: Oliver Windall Juhl <59018053+olivermrbl@users.noreply.github.com> Co-authored-by: Oliver Windall Juhl <59018053+olivermrbl@users.noreply.github.com>
This commit is contained in:
co-authored by
Oliver Windall Juhl
parent
a81227fa74
commit
3bf32e5dc9
@@ -7,6 +7,7 @@ export * from "./draft-orders"
|
||||
export * from "./gift-cards"
|
||||
export * from "./orders"
|
||||
export * from "./products"
|
||||
export * from "./product-tags"
|
||||
export * from "./return-reasons"
|
||||
export * from "./regions"
|
||||
export * from "./shipping-options"
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
export * from "./queries"
|
||||
@@ -0,0 +1,34 @@
|
||||
import {
|
||||
AdminProductTagsListRes,
|
||||
AdminGetProductTagsParams,
|
||||
} from "@medusajs/medusa"
|
||||
import { Response } from "@medusajs/medusa-js"
|
||||
import { useQuery } from "react-query"
|
||||
import { useMedusa } from "../../../contexts"
|
||||
import { UseQueryOptionsWrapper } from "../../../types"
|
||||
import { queryKeysFactory } from "../../utils/index"
|
||||
|
||||
const ADMIN_PRODUCT_TAGS_QUERY_KEY = `admin_product_tags` as const
|
||||
|
||||
export const adminProductTagKeys = queryKeysFactory(
|
||||
ADMIN_PRODUCT_TAGS_QUERY_KEY
|
||||
)
|
||||
|
||||
type ProductQueryKeys = typeof adminProductTagKeys
|
||||
|
||||
export const useAdminProductTags = (
|
||||
query?: AdminGetProductTagsParams,
|
||||
options?: UseQueryOptionsWrapper<
|
||||
Response<AdminProductTagsListRes>,
|
||||
Error,
|
||||
ReturnType<ProductQueryKeys["list"]>
|
||||
>
|
||||
) => {
|
||||
const { client } = useMedusa()
|
||||
const { data, ...rest } = useQuery(
|
||||
adminProductTagKeys.list(query),
|
||||
() => client.admin.productTags.list(query),
|
||||
options
|
||||
)
|
||||
return { ...data, ...rest } as const
|
||||
}
|
||||
@@ -67,7 +67,7 @@ export const useAdminProductTypes = (
|
||||
return { ...data, ...rest } as const
|
||||
}
|
||||
|
||||
export const useAdminProductTags = (
|
||||
export const useAdminProductTagUsage = (
|
||||
options?: UseQueryOptionsWrapper<
|
||||
Response<AdminProductsListTagsRes>,
|
||||
Error,
|
||||
|
||||
Reference in New Issue
Block a user