diff --git a/packages/admin-next/dashboard/src/hooks/api/fulfillment.tsx b/packages/admin-next/dashboard/src/hooks/api/fulfillment.tsx index 77ff34bbac..eb393c8a9d 100644 --- a/packages/admin-next/dashboard/src/hooks/api/fulfillment.tsx +++ b/packages/admin-next/dashboard/src/hooks/api/fulfillment.tsx @@ -14,7 +14,7 @@ export const useCreateFulfillment = ( options?: UseMutationOptions ) => { 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 ) => { 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({ diff --git a/packages/admin-next/dashboard/src/hooks/api/payments.tsx b/packages/admin-next/dashboard/src/hooks/api/payments.tsx index 7f42733fb3..b06d48369f 100644 --- a/packages/admin-next/dashboard/src/hooks/api/payments.tsx +++ b/packages/admin-next/dashboard/src/hooks/api/payments.tsx @@ -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, + 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, }) diff --git a/packages/admin-next/dashboard/src/hooks/api/sales-channels.tsx b/packages/admin-next/dashboard/src/hooks/api/sales-channels.tsx index 11d6ed1886..6fe9b6d666 100644 --- a/packages/admin-next/dashboard/src/hooks/api/sales-channels.tsx +++ b/packages/admin-next/dashboard/src/hooks/api/sales-channels.tsx @@ -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 + 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), }) diff --git a/packages/admin-next/dashboard/src/lib/client/client.ts b/packages/admin-next/dashboard/src/lib/client/client.ts index 4fce5e6232..ed91fe7a7f 100644 --- a/packages/admin-next/dashboard/src/lib/client/client.ts +++ b/packages/admin-next/dashboard/src/lib/client/client.ts @@ -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, } diff --git a/packages/admin-next/dashboard/src/lib/client/fulfillments.ts b/packages/admin-next/dashboard/src/lib/client/fulfillments.ts deleted file mode 100644 index 9bbaa8c4b4..0000000000 --- a/packages/admin-next/dashboard/src/lib/client/fulfillments.ts +++ /dev/null @@ -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(`/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(`/admin/fulfillments/${id}/cancel`) -} - -export const fulfillments = { - create: createFulfillment, - cancel: cancelFulfillment, -} diff --git a/packages/admin-next/dashboard/src/lib/client/invites.ts b/packages/admin-next/dashboard/src/lib/client/invites.ts deleted file mode 100644 index 80f3553180..0000000000 --- a/packages/admin-next/dashboard/src/lib/client/invites.ts +++ /dev/null @@ -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) { - return getRequest>( - `/admin/invites/${id}`, - query - ) -} - -async function listInvites(query?: Record) { - return getRequest>(`/admin/invites`, query) -} - -async function createInvite(payload: CreateInviteReq) { - return postRequest(`/admin/invites`, payload) -} - -async function resendInvite(id: string) { - return postRequest(`/admin/invites/${id}/resend`) -} - -async function deleteInvite(id: string) { - return deleteRequest(`/admin/invites/${id}`) -} - -export const invites = { - retrieve: retrieveInvite, - list: listInvites, - create: createInvite, - resend: resendInvite, - delete: deleteInvite, -} diff --git a/packages/admin-next/dashboard/src/lib/client/payments.ts b/packages/admin-next/dashboard/src/lib/client/payments.ts deleted file mode 100644 index fe3668ae31..0000000000 --- a/packages/admin-next/dashboard/src/lib/client/payments.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { PaymentProvidersListRes } from "../../types/api-responses" -import { getRequest } from "./common" - -async function listPaymentProviders(query?: Record) { - return getRequest>( - `/admin/payments/payment-providers`, - query - ) -} - -export const payments = { - listPaymentProviders, -} diff --git a/packages/admin-next/dashboard/src/lib/client/price-lists.ts b/packages/admin-next/dashboard/src/lib/client/price-lists.ts deleted file mode 100644 index b26226094e..0000000000 --- a/packages/admin-next/dashboard/src/lib/client/price-lists.ts +++ /dev/null @@ -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) { - return getRequest(`/admin/price-lists/${id}`, query) -} - -async function listPriceLists(query?: Record) { - return getRequest(`/admin/price-lists`, query) -} - -async function createPriceList(payload: CreatePriceListReq) { - return postRequest(`/admin/price-lists`, payload) -} - -async function updatePriceList(id: string, payload: UpdatePriceListReq) { - return postRequest(`/admin/price-lists/${id}`, payload) -} - -async function deletePriceList(id: string) { - return postRequest(`/admin/price-lists/${id}/delete`) -} - -async function addPriceListPrices(id: string, payload: AddPriceListPricesReq) { - return postRequest(`/admin/price-lists/${id}/prices/batch`, { - create: payload.prices, - }) -} - -async function removePriceListPrices( - id: string, - payload: DeletePriceListPricesReq -) { - return postRequest(`/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, -} diff --git a/packages/admin-next/dashboard/src/lib/client/product-types.ts b/packages/admin-next/dashboard/src/lib/client/product-types.ts deleted file mode 100644 index 87f542cbc2..0000000000 --- a/packages/admin-next/dashboard/src/lib/client/product-types.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { HttpTypes } from "@medusajs/types" -import { getRequest } from "./common" - -async function listProductTypes(query?: Record) { - return getRequest<{ product_types: HttpTypes.AdminProductType[] }>( - `/admin/product-types`, - query - ) -} - -async function retrieveProductType(id: string, query?: Record) { - return getRequest<{ product_type: HttpTypes.AdminProductType }>( - `/admin/product-types/${id}`, - query - ) -} - -export const productTypes = { - list: listProductTypes, - retrieve: retrieveProductType, -} diff --git a/packages/admin-next/dashboard/src/lib/client/tags.ts b/packages/admin-next/dashboard/src/lib/client/tags.ts deleted file mode 100644 index 58ddc5b61c..0000000000 --- a/packages/admin-next/dashboard/src/lib/client/tags.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { getRequest } from "./common" - -async function listProductTags(query?: Record) { - return getRequest(`/admin/product-tags`, query) -} - -async function retrieveProductTag(id: string, query?: Record) { - return getRequest(`/admin/product-tags/${id}`, query) -} - -export const tags = { - list: listProductTags, - retrieve: retrieveProductTag, -} diff --git a/packages/admin-next/dashboard/src/lib/client/users.ts b/packages/admin-next/dashboard/src/lib/client/users.ts deleted file mode 100644 index 5826a60959..0000000000 --- a/packages/admin-next/dashboard/src/lib/client/users.ts +++ /dev/null @@ -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("/admin/users/me") -} - -async function retrieveUser(id: string, query?: Record) { - return getRequest(`/admin/users/${id}`, query) -} - -async function listUsers(query?: Record) { - return getRequest(`/admin/users`, query) -} - -async function updateUser(id: string, payload: UpdateUserReq) { - return postRequest(`/admin/users/${id}`, payload) -} - -async function deleteUser(id: string) { - return deleteRequest(`/admin/users/${id}`) -} - -export const users = { - me, - retrieve: retrieveUser, - list: listUsers, - update: updateUser, - delete: deleteUser, -} diff --git a/packages/admin-next/dashboard/src/routes/products/product-create/components/product-create-organize-form/components/product-create-organize-section/product-create-details-organize-section.tsx b/packages/admin-next/dashboard/src/routes/products/product-create/components/product-create-organize-form/components/product-create-organize-section/product-create-details-organize-section.tsx index 3c7f2da605..e4d5c32cdf 100644 --- a/packages/admin-next/dashboard/src/routes/products/product-create/components/product-create-organize-form/components/product-create-organize-section/product-create-details-organize-section.tsx +++ b/packages/admin-next/dashboard/src/routes/products/product-create/components/product-create-organize-form/components/product-create-organize-section/product-create-details-organize-section.tsx @@ -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, diff --git a/packages/admin-next/dashboard/src/routes/products/product-organization/components/product-organization-form/product-organization-form.tsx b/packages/admin-next/dashboard/src/routes/products/product-organization/components/product-organization-form/product-organization-form.tsx index 83fee51fce..5745dab440 100644 --- a/packages/admin-next/dashboard/src/routes/products/product-organization/components/product-organization-form/product-organization-form.tsx +++ b/packages/admin-next/dashboard/src/routes/products/product-organization/components/product-organization-form/product-organization-form.tsx @@ -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, diff --git a/packages/admin-next/dashboard/src/routes/sales-channels/sales-channel-add-products/components/add-products-to-sales-channel-form.tsx b/packages/admin-next/dashboard/src/routes/sales-channels/sales-channel-add-products/components/add-products-to-sales-channel-form.tsx index 335dba1150..9089b05be0 100644 --- a/packages/admin-next/dashboard/src/routes/sales-channels/sales-channel-add-products/components/add-products-to-sales-channel-form.tsx +++ b/packages/admin-next/dashboard/src/routes/sales-channels/sales-channel-add-products/components/add-products-to-sales-channel-form.tsx @@ -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) { diff --git a/packages/admin-next/dashboard/src/routes/sales-channels/sales-channel-detail/components/sales-channel-product-section/sales-channel-product-section.tsx b/packages/admin-next/dashboard/src/routes/sales-channels/sales-channel-detail/components/sales-channel-product-section/sales-channel-product-section.tsx index 9ddff7edf5..95c7a73250 100644 --- a/packages/admin-next/dashboard/src/routes/sales-channels/sales-channel-detail/components/sales-channel-product-section/sales-channel-product-section.tsx +++ b/packages/admin-next/dashboard/src/routes/sales-channels/sales-channel-detail/components/sales-channel-product-section/sales-channel-product-section.tsx @@ -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 ( diff --git a/packages/admin-next/dashboard/src/routes/sales-channels/sales-channel-detail/loader.ts b/packages/admin-next/dashboard/src/routes/sales-channels/sales-channel-detail/loader.ts index cc4f686929..5c58f64764 100644 --- a/packages/admin-next/dashboard/src/routes/sales-channels/sales-channel-detail/loader.ts +++ b/packages/admin-next/dashboard/src/routes/sales-channels/sales-channel-detail/loader.ts @@ -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) => { diff --git a/packages/admin-next/dashboard/src/routes/users/user-detail/loader.ts b/packages/admin-next/dashboard/src/routes/users/user-detail/loader.ts index cbdda0f484..b0c44cd827 100644 --- a/packages/admin-next/dashboard/src/routes/users/user-detail/loader.ts +++ b/packages/admin-next/dashboard/src/routes/users/user-detail/loader.ts @@ -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) => { diff --git a/packages/core/js-sdk/src/admin/payment.ts b/packages/core/js-sdk/src/admin/payment.ts index 230cdf5107..3d5331d14b 100644 --- a/packages/core/js-sdk/src/admin/payment.ts +++ b/packages/core/js-sdk/src/admin/payment.ts @@ -18,6 +18,19 @@ export class Payment { ) } + async listPaymentProviders( + query?: HttpTypes.AdminGetPaymentProvidersParams, + headers?: ClientHeaders + ) { + return await this.client.fetch( + `/admin/payments/payment-providers`, + { + query, + headers, + } + ) + } + async retrieve( id: string, query?: HttpTypes.AdminPaymentFilters, diff --git a/packages/core/js-sdk/src/admin/sales-channel.ts b/packages/core/js-sdk/src/admin/sales-channel.ts index 022a483e77..53ee7cf1b8 100644 --- a/packages/core/js-sdk/src/admin/sales-channel.ts +++ b/packages/core/js-sdk/src/admin/sales-channel.ts @@ -94,4 +94,19 @@ export class SalesChannel { } ) } + + async batchProducts( + id: string, + body: HttpTypes.AdminBatchLink, + headers?: ClientHeaders + ) { + return await this.client.fetch( + `/admin/sales-channels/${id}/products`, + { + method: "POST", + headers, + body, + } + ) + } } diff --git a/packages/core/types/src/http/payment/admin/queries.ts b/packages/core/types/src/http/payment/admin/queries.ts index 38f2e52520..4d1ff5ab80 100644 --- a/packages/core/types/src/http/payment/admin/queries.ts +++ b/packages/core/types/src/http/payment/admin/queries.ts @@ -1,4 +1,5 @@ import { BaseFilterable } from "../../../dal" +import { FindParams } from "../../common" import { BasePaymentCollectionFilters, BasePaymentFilters, @@ -22,4 +23,13 @@ export interface RefundFilters extends BaseFilterable { } export interface RefundReasonFilters extends BaseFilterable { id?: string | string[] -} \ No newline at end of file +} + +export interface AdminGetPaymentProvidersParams + extends FindParams, + BaseFilterable { + id?: string | string[] + is_enabled?: boolean + $and?: AdminGetPaymentProvidersParams[] + $or?: AdminGetPaymentProvidersParams[] +}