chore: Remove unused clients in admin + clean up js-sdk (#8839)
* feat(js-sdk): Add API key * chore: Remove unused clients in admin + clean up js-sdk * fix sales channel hooks
This commit is contained in:
@@ -14,7 +14,7 @@ export const useCreateFulfillment = (
|
||||
options?: UseMutationOptions<any, Error, any>
|
||||
) => {
|
||||
return useMutation({
|
||||
mutationFn: (payload: any) => client.fulfillments.create(payload),
|
||||
mutationFn: (payload: any) => sdk.admin.fulfillment.create(payload),
|
||||
onSuccess: (data: any, variables: any, context: any) => {
|
||||
queryClient.invalidateQueries({ queryKey: fulfillmentsQueryKeys.lists() })
|
||||
queryClient.invalidateQueries({
|
||||
@@ -31,7 +31,7 @@ export const useCancelFulfillment = (
|
||||
options?: UseMutationOptions<any, Error, any>
|
||||
) => {
|
||||
return useMutation({
|
||||
mutationFn: () => client.fulfillments.cancel(id),
|
||||
mutationFn: () => sdk.admin.fulfillment.cancel(id),
|
||||
onSuccess: (data: any, variables: any, context: any) => {
|
||||
queryClient.invalidateQueries({ queryKey: fulfillmentsQueryKeys.lists() })
|
||||
queryClient.invalidateQueries({
|
||||
|
||||
@@ -6,29 +6,28 @@ import {
|
||||
useQuery,
|
||||
UseQueryOptions,
|
||||
} from "@tanstack/react-query"
|
||||
import { client, sdk } from "../../lib/client"
|
||||
import { sdk } from "../../lib/client"
|
||||
import { queryClient } from "../../lib/query-client"
|
||||
import { queryKeysFactory } from "../../lib/query-key-factory"
|
||||
import { PaymentProvidersListRes } from "../../types/api-responses"
|
||||
import { ordersQueryKeys } from "./orders"
|
||||
|
||||
const PAYMENT_QUERY_KEY = "payment" as const
|
||||
export const paymentQueryKeys = queryKeysFactory(PAYMENT_QUERY_KEY)
|
||||
|
||||
export const usePaymentProviders = (
|
||||
query?: Record<string, any>,
|
||||
query?: HttpTypes.AdminGetPaymentProvidersParams,
|
||||
options?: Omit<
|
||||
UseQueryOptions<
|
||||
PaymentProvidersListRes,
|
||||
HttpTypes.AdminGetPaymentProvidersParams,
|
||||
Error,
|
||||
PaymentProvidersListRes,
|
||||
HttpTypes.AdminPaymentProviderListResponse,
|
||||
QueryKey
|
||||
>,
|
||||
"queryKey" | "queryFn"
|
||||
>
|
||||
) => {
|
||||
const { data, ...rest } = useQuery({
|
||||
queryFn: async () => client.payments.listPaymentProviders(query),
|
||||
queryFn: async () => sdk.admin.payment.listPaymentProviders(query),
|
||||
queryKey: [],
|
||||
...options,
|
||||
})
|
||||
|
||||
@@ -5,21 +5,14 @@ import {
|
||||
useMutation,
|
||||
useQuery,
|
||||
} from "@tanstack/react-query"
|
||||
|
||||
import {
|
||||
AdminSalesChannelListResponse,
|
||||
AdminSalesChannelResponse,
|
||||
HttpTypes,
|
||||
} from "@medusajs/types"
|
||||
import { client } from "../../lib/client"
|
||||
import { sdk } from "../../lib/client"
|
||||
import { queryClient } from "../../lib/query-client"
|
||||
import { queryKeysFactory } from "../../lib/query-key-factory"
|
||||
import {
|
||||
AddProductsSalesChannelReq,
|
||||
CreateSalesChannelReq,
|
||||
RemoveProductsSalesChannelReq,
|
||||
UpdateSalesChannelReq,
|
||||
} from "../../types/api-payloads"
|
||||
import { SalesChannelDeleteRes } from "../../types/api-responses"
|
||||
import { productsQueryKeys } from "./products"
|
||||
|
||||
const SALES_CHANNELS_QUERY_KEY = "sales-channels" as const
|
||||
@@ -39,7 +32,7 @@ export const useSalesChannel = (
|
||||
) => {
|
||||
const { data, ...rest } = useQuery({
|
||||
queryKey: salesChannelsQueryKeys.detail(id),
|
||||
queryFn: async () => client.salesChannels.retrieve(id),
|
||||
queryFn: async () => sdk.admin.salesChannel.retrieve(id),
|
||||
...options,
|
||||
})
|
||||
|
||||
@@ -59,7 +52,7 @@ export const useSalesChannels = (
|
||||
>
|
||||
) => {
|
||||
const { data, ...rest } = useQuery({
|
||||
queryFn: () => client.salesChannels.list(query),
|
||||
queryFn: () => sdk.admin.salesChannel.list(query),
|
||||
queryKey: salesChannelsQueryKeys.list(query),
|
||||
...options,
|
||||
})
|
||||
@@ -71,11 +64,11 @@ export const useCreateSalesChannel = (
|
||||
options?: UseMutationOptions<
|
||||
AdminSalesChannelResponse,
|
||||
Error,
|
||||
CreateSalesChannelReq
|
||||
HttpTypes.AdminCreateSalesChannel
|
||||
>
|
||||
) => {
|
||||
return useMutation({
|
||||
mutationFn: (payload) => client.salesChannels.create(payload),
|
||||
mutationFn: (payload) => sdk.admin.salesChannel.create(payload),
|
||||
onSuccess: (data, variables, context) => {
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: salesChannelsQueryKeys.lists(),
|
||||
@@ -91,11 +84,11 @@ export const useUpdateSalesChannel = (
|
||||
options?: UseMutationOptions<
|
||||
AdminSalesChannelResponse,
|
||||
Error,
|
||||
UpdateSalesChannelReq
|
||||
HttpTypes.AdminUpdateSalesChannel
|
||||
>
|
||||
) => {
|
||||
return useMutation({
|
||||
mutationFn: (payload) => client.salesChannels.update(id, payload),
|
||||
mutationFn: (payload) => sdk.admin.salesChannel.update(id, payload),
|
||||
onSuccess: (data, variables, context) => {
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: salesChannelsQueryKeys.lists(),
|
||||
@@ -112,10 +105,14 @@ export const useUpdateSalesChannel = (
|
||||
|
||||
export const useDeleteSalesChannel = (
|
||||
id: string,
|
||||
options?: UseMutationOptions<SalesChannelDeleteRes, Error, void>
|
||||
options?: UseMutationOptions<
|
||||
HttpTypes.AdminSalesChannelDeleteResponse,
|
||||
Error,
|
||||
void
|
||||
>
|
||||
) => {
|
||||
return useMutation({
|
||||
mutationFn: () => client.salesChannels.delete(id),
|
||||
mutationFn: () => sdk.admin.salesChannel.delete(id),
|
||||
onSuccess: (data, variables, context) => {
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: salesChannelsQueryKeys.lists(),
|
||||
@@ -140,11 +137,12 @@ export const useSalesChannelRemoveProducts = (
|
||||
options?: UseMutationOptions<
|
||||
AdminSalesChannelResponse,
|
||||
Error,
|
||||
RemoveProductsSalesChannelReq
|
||||
HttpTypes.AdminBatchLink["remove"]
|
||||
>
|
||||
) => {
|
||||
return useMutation({
|
||||
mutationFn: (payload) => client.salesChannels.removeProducts(id, payload),
|
||||
mutationFn: (payload) =>
|
||||
sdk.admin.salesChannel.batchProducts(id, { remove: payload }),
|
||||
onSuccess: (data, variables, context) => {
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: salesChannelsQueryKeys.lists(),
|
||||
@@ -154,7 +152,7 @@ export const useSalesChannelRemoveProducts = (
|
||||
})
|
||||
|
||||
// Invalidate the products that were removed
|
||||
for (const product of variables?.product_ids || []) {
|
||||
for (const product of variables || []) {
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: productsQueryKeys.detail(product),
|
||||
})
|
||||
@@ -176,11 +174,12 @@ export const useSalesChannelAddProducts = (
|
||||
options?: UseMutationOptions<
|
||||
AdminSalesChannelResponse,
|
||||
Error,
|
||||
AddProductsSalesChannelReq
|
||||
HttpTypes.AdminBatchLink["add"]
|
||||
>
|
||||
) => {
|
||||
return useMutation({
|
||||
mutationFn: (payload) => client.salesChannels.addProducts(id, payload),
|
||||
mutationFn: (payload) =>
|
||||
sdk.admin.salesChannel.batchProducts(id, { add: payload }),
|
||||
onSuccess: (data, variables, context) => {
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: salesChannelsQueryKeys.lists(),
|
||||
@@ -190,7 +189,7 @@ export const useSalesChannelAddProducts = (
|
||||
})
|
||||
|
||||
// Invalidate the products that were removed
|
||||
for (const product of variables?.product_ids || []) {
|
||||
for (const product of variables || []) {
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: productsQueryKeys.detail(product),
|
||||
})
|
||||
|
||||
@@ -1,23 +1,11 @@
|
||||
import Medusa from "@medusajs/js-sdk"
|
||||
import { campaigns } from "./campaigns"
|
||||
import { categories } from "./categories"
|
||||
import { currencies } from "./currencies"
|
||||
import { customerGroups } from "./customer-groups"
|
||||
import { fulfillmentProviders } from "./fulfillment-providers"
|
||||
import { fulfillments } from "./fulfillments"
|
||||
import { invites } from "./invites"
|
||||
import { payments } from "./payments"
|
||||
import { priceLists } from "./price-lists"
|
||||
import { productTypes } from "./product-types"
|
||||
import { promotions } from "./promotions"
|
||||
import { reservations } from "./reservations"
|
||||
import { salesChannels } from "./sales-channels"
|
||||
import { shippingOptions } from "./shipping-options"
|
||||
import { shippingProfiles } from "./shipping-profiles"
|
||||
import { stockLocations } from "./stock-locations"
|
||||
import { stores } from "./stores"
|
||||
import { tags } from "./tags"
|
||||
import { users } from "./users"
|
||||
import { workflowExecutions } from "./workflow-executions"
|
||||
|
||||
export const backendUrl = __BACKEND_URL__ ?? "http://localhost:9000"
|
||||
@@ -26,21 +14,9 @@ export const client = {
|
||||
campaigns: campaigns,
|
||||
categories: categories,
|
||||
customerGroups: customerGroups,
|
||||
currencies: currencies,
|
||||
promotions: promotions,
|
||||
payments: payments,
|
||||
stores: stores,
|
||||
salesChannels: salesChannels,
|
||||
shippingOptions: shippingOptions,
|
||||
shippingProfiles: shippingProfiles,
|
||||
productTags: tags,
|
||||
users: users,
|
||||
invites: invites,
|
||||
reservations: reservations,
|
||||
fulfillments: fulfillments,
|
||||
fulfillmentProviders: fulfillmentProviders,
|
||||
productTypes: productTypes,
|
||||
priceLists: priceLists,
|
||||
stockLocations: stockLocations,
|
||||
workflowExecutions: workflowExecutions,
|
||||
}
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
import { CreateFulfillmentDTO } from "@medusajs/types"
|
||||
|
||||
import { FulfillmentRes } from "../../types/api-responses"
|
||||
import { postRequest } from "./common"
|
||||
|
||||
/**
|
||||
* Create a fulfillment.
|
||||
* NOTE: to create a fulfillment on an order use orders/:id/fulfillments endpoint
|
||||
*/
|
||||
async function createFulfillment(payload: CreateFulfillmentDTO) {
|
||||
return postRequest<FulfillmentRes>(`/admin/fulfillments`, payload)
|
||||
}
|
||||
|
||||
/**
|
||||
* Cancel a fulfillment.
|
||||
* NOTE: to cancel a fulfillment on an order use orders/:id/fulfillments/:id/cancel endpoint
|
||||
*/
|
||||
async function cancelFulfillment(id: string) {
|
||||
return postRequest<FulfillmentRes>(`/admin/fulfillments/${id}/cancel`)
|
||||
}
|
||||
|
||||
export const fulfillments = {
|
||||
create: createFulfillment,
|
||||
cancel: cancelFulfillment,
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
import { CreateInviteReq } from "../../types/api-payloads"
|
||||
import {
|
||||
InviteDeleteRes,
|
||||
InviteListRes,
|
||||
InviteRes,
|
||||
} from "../../types/api-responses"
|
||||
import { deleteRequest, getRequest, postRequest } from "./common"
|
||||
|
||||
async function retrieveInvite(id: string, query?: Record<string, any>) {
|
||||
return getRequest<InviteRes, Record<string, any>>(
|
||||
`/admin/invites/${id}`,
|
||||
query
|
||||
)
|
||||
}
|
||||
|
||||
async function listInvites(query?: Record<string, any>) {
|
||||
return getRequest<InviteListRes, Record<string, any>>(`/admin/invites`, query)
|
||||
}
|
||||
|
||||
async function createInvite(payload: CreateInviteReq) {
|
||||
return postRequest<InviteRes>(`/admin/invites`, payload)
|
||||
}
|
||||
|
||||
async function resendInvite(id: string) {
|
||||
return postRequest<InviteRes>(`/admin/invites/${id}/resend`)
|
||||
}
|
||||
|
||||
async function deleteInvite(id: string) {
|
||||
return deleteRequest<InviteDeleteRes>(`/admin/invites/${id}`)
|
||||
}
|
||||
|
||||
export const invites = {
|
||||
retrieve: retrieveInvite,
|
||||
list: listInvites,
|
||||
create: createInvite,
|
||||
resend: resendInvite,
|
||||
delete: deleteInvite,
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
import { PaymentProvidersListRes } from "../../types/api-responses"
|
||||
import { getRequest } from "./common"
|
||||
|
||||
async function listPaymentProviders(query?: Record<string, any>) {
|
||||
return getRequest<PaymentProvidersListRes, Record<string, any>>(
|
||||
`/admin/payments/payment-providers`,
|
||||
query
|
||||
)
|
||||
}
|
||||
|
||||
export const payments = {
|
||||
listPaymentProviders,
|
||||
}
|
||||
@@ -1,57 +0,0 @@
|
||||
import {
|
||||
AddPriceListPricesReq,
|
||||
CreatePriceListReq,
|
||||
DeletePriceListPricesReq,
|
||||
UpdatePriceListReq,
|
||||
} from "../../types/api-payloads"
|
||||
import {
|
||||
PriceListDeleteRes,
|
||||
PriceListListRes,
|
||||
PriceListRes,
|
||||
} from "../../types/api-responses"
|
||||
import { getRequest, postRequest } from "./common"
|
||||
|
||||
async function retrievePriceLists(id: string, query?: Record<string, any>) {
|
||||
return getRequest<PriceListRes>(`/admin/price-lists/${id}`, query)
|
||||
}
|
||||
|
||||
async function listPriceLists(query?: Record<string, any>) {
|
||||
return getRequest<PriceListListRes>(`/admin/price-lists`, query)
|
||||
}
|
||||
|
||||
async function createPriceList(payload: CreatePriceListReq) {
|
||||
return postRequest<PriceListRes>(`/admin/price-lists`, payload)
|
||||
}
|
||||
|
||||
async function updatePriceList(id: string, payload: UpdatePriceListReq) {
|
||||
return postRequest<PriceListRes>(`/admin/price-lists/${id}`, payload)
|
||||
}
|
||||
|
||||
async function deletePriceList(id: string) {
|
||||
return postRequest<PriceListDeleteRes>(`/admin/price-lists/${id}/delete`)
|
||||
}
|
||||
|
||||
async function addPriceListPrices(id: string, payload: AddPriceListPricesReq) {
|
||||
return postRequest<PriceListRes>(`/admin/price-lists/${id}/prices/batch`, {
|
||||
create: payload.prices,
|
||||
})
|
||||
}
|
||||
|
||||
async function removePriceListPrices(
|
||||
id: string,
|
||||
payload: DeletePriceListPricesReq
|
||||
) {
|
||||
return postRequest<PriceListRes>(`/admin/price-lists/${id}/prices/batch`, {
|
||||
delete: payload.ids,
|
||||
})
|
||||
}
|
||||
|
||||
export const priceLists = {
|
||||
retrieve: retrievePriceLists,
|
||||
list: listPriceLists,
|
||||
create: createPriceList,
|
||||
update: updatePriceList,
|
||||
delete: deletePriceList,
|
||||
addPrices: addPriceListPrices,
|
||||
removePrices: removePriceListPrices,
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
import { HttpTypes } from "@medusajs/types"
|
||||
import { getRequest } from "./common"
|
||||
|
||||
async function listProductTypes(query?: Record<string, any>) {
|
||||
return getRequest<{ product_types: HttpTypes.AdminProductType[] }>(
|
||||
`/admin/product-types`,
|
||||
query
|
||||
)
|
||||
}
|
||||
|
||||
async function retrieveProductType(id: string, query?: Record<string, any>) {
|
||||
return getRequest<{ product_type: HttpTypes.AdminProductType }>(
|
||||
`/admin/product-types/${id}`,
|
||||
query
|
||||
)
|
||||
}
|
||||
|
||||
export const productTypes = {
|
||||
list: listProductTypes,
|
||||
retrieve: retrieveProductType,
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
import { getRequest } from "./common"
|
||||
|
||||
async function listProductTags(query?: Record<string, any>) {
|
||||
return getRequest<any>(`/admin/product-tags`, query)
|
||||
}
|
||||
|
||||
async function retrieveProductTag(id: string, query?: Record<string, any>) {
|
||||
return getRequest<any>(`/admin/product-tags/${id}`, query)
|
||||
}
|
||||
|
||||
export const tags = {
|
||||
list: listProductTags,
|
||||
retrieve: retrieveProductTag,
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
import { UpdateUserReq } from "../../types/api-payloads"
|
||||
import { UserDeleteRes, UserListRes, UserRes } from "../../types/api-responses"
|
||||
import { deleteRequest, getRequest, postRequest } from "./common"
|
||||
|
||||
async function me() {
|
||||
return getRequest<UserRes>("/admin/users/me")
|
||||
}
|
||||
|
||||
async function retrieveUser(id: string, query?: Record<string, any>) {
|
||||
return getRequest<UserRes>(`/admin/users/${id}`, query)
|
||||
}
|
||||
|
||||
async function listUsers(query?: Record<string, any>) {
|
||||
return getRequest<UserListRes>(`/admin/users`, query)
|
||||
}
|
||||
|
||||
async function updateUser(id: string, payload: UpdateUserReq) {
|
||||
return postRequest<UserRes>(`/admin/users/${id}`, payload)
|
||||
}
|
||||
|
||||
async function deleteUser(id: string) {
|
||||
return deleteRequest<UserDeleteRes>(`/admin/users/${id}`)
|
||||
}
|
||||
|
||||
export const users = {
|
||||
me,
|
||||
retrieve: retrieveUser,
|
||||
list: listUsers,
|
||||
update: updateUser,
|
||||
delete: deleteUser,
|
||||
}
|
||||
+3
-3
@@ -7,7 +7,7 @@ import { Form } from "../../../../../../../components/common/form"
|
||||
import { SwitchBox } from "../../../../../../../components/common/switch-box"
|
||||
import { Combobox } from "../../../../../../../components/inputs/combobox"
|
||||
import { useComboboxData } from "../../../../../../../hooks/use-combobox-data"
|
||||
import { client, sdk } from "../../../../../../../lib/client"
|
||||
import { sdk } from "../../../../../../../lib/client"
|
||||
import { CategoryCombobox } from "../../../../../common/components/category-combobox"
|
||||
import { ProductCreateSchemaType } from "../../../../types"
|
||||
import { useProductCreateDetailsContext } from "../product-create-organize-context"
|
||||
@@ -34,7 +34,7 @@ export const ProductCreateOrganizationSection = ({
|
||||
|
||||
const types = useComboboxData({
|
||||
queryKey: ["product_types"],
|
||||
queryFn: client.productTypes.list,
|
||||
queryFn: sdk.admin.productType.list,
|
||||
getOptions: (data) =>
|
||||
data.product_types.map((type) => ({
|
||||
label: type.value,
|
||||
@@ -44,7 +44,7 @@ export const ProductCreateOrganizationSection = ({
|
||||
|
||||
const tags = useComboboxData({
|
||||
queryKey: ["product_tags"],
|
||||
queryFn: client.productTags.list,
|
||||
queryFn: sdk.admin.productTag.list,
|
||||
getOptions: (data) =>
|
||||
data.product_tags.map((tag) => ({
|
||||
label: tag.value,
|
||||
|
||||
+2
-2
@@ -41,7 +41,7 @@ export const ProductOrganizationForm = ({
|
||||
|
||||
const types = useComboboxData({
|
||||
queryKey: ["product_types"],
|
||||
queryFn: client.productTypes.list,
|
||||
queryFn: sdk.admin.productType.list,
|
||||
getOptions: (data) =>
|
||||
data.product_types.map((type) => ({
|
||||
label: type.value,
|
||||
@@ -51,7 +51,7 @@ export const ProductOrganizationForm = ({
|
||||
|
||||
const tags = useComboboxData({
|
||||
queryKey: ["product_tags"],
|
||||
queryFn: client.productTags.list,
|
||||
queryFn: sdk.admin.productTag.list,
|
||||
getOptions: (data) =>
|
||||
data.product_tags.map((tag) => ({
|
||||
label: tag.value,
|
||||
|
||||
+6
-11
@@ -104,18 +104,13 @@ export const AddProductsToSalesChannelForm = ({
|
||||
})
|
||||
|
||||
const handleSubmit = form.handleSubmit(async (values) => {
|
||||
await mutateAsync(
|
||||
{
|
||||
product_ids: values.product_ids,
|
||||
await mutateAsync(values.product_ids, {
|
||||
onSuccess: () => {
|
||||
toast.success(t("salesChannels.toast.update"))
|
||||
handleSuccess()
|
||||
},
|
||||
{
|
||||
onSuccess: () => {
|
||||
toast.success(t("salesChannels.toast.update"))
|
||||
handleSuccess()
|
||||
},
|
||||
onError: (error) => toast.error(error.message),
|
||||
}
|
||||
)
|
||||
onError: (error) => toast.error(error.message),
|
||||
})
|
||||
})
|
||||
|
||||
if (isError) {
|
||||
|
||||
+15
-25
@@ -93,20 +93,15 @@ export const SalesChannelProductSection = ({
|
||||
return
|
||||
}
|
||||
|
||||
await mutateAsync(
|
||||
{
|
||||
product_ids: ids,
|
||||
await mutateAsync(ids, {
|
||||
onSuccess: () => {
|
||||
toast.success(t("salesChannels.toast.update"))
|
||||
setRowSelection({})
|
||||
},
|
||||
{
|
||||
onSuccess: () => {
|
||||
toast.success(t("salesChannels.toast.update"))
|
||||
setRowSelection({})
|
||||
},
|
||||
onError: (error) => {
|
||||
toast.error(error.message)
|
||||
},
|
||||
}
|
||||
)
|
||||
onError: (error) => {
|
||||
toast.error(error.message)
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
if (isError) {
|
||||
@@ -218,19 +213,14 @@ const ProductListCellActions = ({
|
||||
const { mutateAsync } = useSalesChannelRemoveProducts(salesChannelId)
|
||||
|
||||
const onRemove = async () => {
|
||||
await mutateAsync(
|
||||
{
|
||||
product_ids: [productId],
|
||||
await mutateAsync([productId], {
|
||||
onSuccess: () => {
|
||||
toast.success(t("salesChannels.toast.update"))
|
||||
},
|
||||
{
|
||||
onSuccess: () => {
|
||||
toast.success(t("salesChannels.toast.update"))
|
||||
},
|
||||
onError: (e) => {
|
||||
toast.error(e.message)
|
||||
},
|
||||
}
|
||||
)
|
||||
onError: (e) => {
|
||||
toast.error(e.message)
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
return (
|
||||
|
||||
+2
-2
@@ -2,12 +2,12 @@ import { LoaderFunctionArgs } from "react-router-dom"
|
||||
|
||||
import { AdminSalesChannelResponse } from "@medusajs/types"
|
||||
import { productsQueryKeys } from "../../../hooks/api/products"
|
||||
import { client } from "../../../lib/client"
|
||||
import { sdk } from "../../../lib/client"
|
||||
import { queryClient } from "../../../lib/query-client"
|
||||
|
||||
const salesChannelDetailQuery = (id: string) => ({
|
||||
queryKey: productsQueryKeys.detail(id),
|
||||
queryFn: async () => client.salesChannels.retrieve(id),
|
||||
queryFn: async () => sdk.admin.salesChannel.retrieve(id),
|
||||
})
|
||||
|
||||
export const salesChannelLoader = async ({ params }: LoaderFunctionArgs) => {
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
import { LoaderFunctionArgs } from "react-router-dom"
|
||||
|
||||
import { productsQueryKeys } from "../../../hooks/api/products"
|
||||
import { client } from "../../../lib/client"
|
||||
import { sdk } from "../../../lib/client"
|
||||
import { queryClient } from "../../../lib/query-client"
|
||||
import { UserRes } from "../../../types/api-responses"
|
||||
|
||||
const userDetailQuery = (id: string) => ({
|
||||
queryKey: productsQueryKeys.detail(id),
|
||||
queryFn: async () => client.users.retrieve(id),
|
||||
queryFn: async () => sdk.admin.user.retrieve(id),
|
||||
})
|
||||
|
||||
export const userLoader = async ({ params }: LoaderFunctionArgs) => {
|
||||
|
||||
@@ -18,6 +18,19 @@ export class Payment {
|
||||
)
|
||||
}
|
||||
|
||||
async listPaymentProviders(
|
||||
query?: HttpTypes.AdminGetPaymentProvidersParams,
|
||||
headers?: ClientHeaders
|
||||
) {
|
||||
return await this.client.fetch<HttpTypes.AdminPaymentProviderListResponse>(
|
||||
`/admin/payments/payment-providers`,
|
||||
{
|
||||
query,
|
||||
headers,
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
async retrieve(
|
||||
id: string,
|
||||
query?: HttpTypes.AdminPaymentFilters,
|
||||
|
||||
@@ -94,4 +94,19 @@ export class SalesChannel {
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
async batchProducts(
|
||||
id: string,
|
||||
body: HttpTypes.AdminBatchLink,
|
||||
headers?: ClientHeaders
|
||||
) {
|
||||
return await this.client.fetch<HttpTypes.AdminSalesChannelResponse>(
|
||||
`/admin/sales-channels/${id}/products`,
|
||||
{
|
||||
method: "POST",
|
||||
headers,
|
||||
body,
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { BaseFilterable } from "../../../dal"
|
||||
import { FindParams } from "../../common"
|
||||
import {
|
||||
BasePaymentCollectionFilters,
|
||||
BasePaymentFilters,
|
||||
@@ -22,4 +23,13 @@ export interface RefundFilters extends BaseFilterable<AdminRefund> {
|
||||
}
|
||||
export interface RefundReasonFilters extends BaseFilterable<AdminRefundReason> {
|
||||
id?: string | string[]
|
||||
}
|
||||
}
|
||||
|
||||
export interface AdminGetPaymentProvidersParams
|
||||
extends FindParams,
|
||||
BaseFilterable<AdminGetPaymentProvidersParams> {
|
||||
id?: string | string[]
|
||||
is_enabled?: boolean
|
||||
$and?: AdminGetPaymentProvidersParams[]
|
||||
$or?: AdminGetPaymentProvidersParams[]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user