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:
Riqwan Thamir
2025-06-12 20:12:03 +02:00
committed by GitHub
parent 65f9333501
commit 44d1d18689
21 changed files with 883 additions and 113 deletions

View File

@@ -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"

View File

@@ -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,
})
}

View 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 }
}