feat(dashboard,types): add credit lines + loyalty changes (#11885)
* feat(dashboard,types): add credit lines + loyalty changes * chore: fix types * chore: fix specs * chore: use correct plugin name * chore: use new currency input --------- Co-authored-by: Oli Juhl <59018053+olivermrbl@users.noreply.github.com>
This commit is contained in:
@@ -15,6 +15,7 @@ export * from "./notification"
|
||||
export * from "./orders"
|
||||
export * from "./payment-collections"
|
||||
export * from "./payments"
|
||||
export * from "./plugins"
|
||||
export * from "./price-lists"
|
||||
export * from "./product-types"
|
||||
export * from "./product-variants"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { FetchError } from "@medusajs/js-sdk"
|
||||
import { HttpTypes } from "@medusajs/types"
|
||||
import { CreateOrderCreditLineDTO, HttpTypes } from "@medusajs/types"
|
||||
import {
|
||||
QueryKey,
|
||||
useMutation,
|
||||
@@ -354,3 +354,28 @@ export const useCancelOrderTransfer = (
|
||||
...options,
|
||||
})
|
||||
}
|
||||
|
||||
export const useCreateOrderCreditLine = (
|
||||
orderId: string,
|
||||
options?: UseMutationOptions<
|
||||
HttpTypes.AdminOrderResponse,
|
||||
FetchError,
|
||||
Omit<CreateOrderCreditLineDTO, "order_id">
|
||||
>
|
||||
) => {
|
||||
return useMutation({
|
||||
mutationFn: (payload) => sdk.admin.order.createCreditLine(orderId, payload),
|
||||
onSuccess: (data, variables, context) => {
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: ordersQueryKeys.details(),
|
||||
})
|
||||
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: ordersQueryKeys.preview(orderId),
|
||||
})
|
||||
|
||||
options?.onSuccess?.(data, variables, context)
|
||||
},
|
||||
...options,
|
||||
})
|
||||
}
|
||||
|
||||
28
packages/admin/dashboard/src/hooks/api/plugins.tsx
Normal file
28
packages/admin/dashboard/src/hooks/api/plugins.tsx
Normal file
@@ -0,0 +1,28 @@
|
||||
import { FetchError } from "@medusajs/js-sdk"
|
||||
import { HttpTypes } from "@medusajs/types"
|
||||
import { QueryKey, UseQueryOptions, useQuery } from "@tanstack/react-query"
|
||||
import { sdk } from "../../lib/client"
|
||||
import { queryKeysFactory } from "../../lib/query-key-factory"
|
||||
|
||||
const PLUGINS_QUERY_KEY = "plugins" as const
|
||||
export const pluginsQueryKeys = queryKeysFactory(PLUGINS_QUERY_KEY)
|
||||
|
||||
export const usePlugins = (
|
||||
options?: Omit<
|
||||
UseQueryOptions<
|
||||
any,
|
||||
FetchError,
|
||||
HttpTypes.AdminPluginsListResponse,
|
||||
QueryKey
|
||||
>,
|
||||
"queryKey" | "queryFn"
|
||||
>
|
||||
) => {
|
||||
const { data, ...rest } = useQuery({
|
||||
queryFn: () => sdk.admin.plugin.list(),
|
||||
queryKey: pluginsQueryKeys.list(),
|
||||
...options,
|
||||
})
|
||||
|
||||
return { ...data, ...rest }
|
||||
}
|
||||
Reference in New Issue
Block a user