chore: Replace reservation customer group client with JS-SDK + clean up (#8857)
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { FetchError } from "@medusajs/js-sdk"
|
||||
import { HttpTypes, PaginatedResponse } from "@medusajs/types"
|
||||
import { HttpTypes } from "@medusajs/types"
|
||||
import {
|
||||
QueryKey,
|
||||
UseMutationOptions,
|
||||
@@ -7,12 +7,9 @@ import {
|
||||
useMutation,
|
||||
useQuery,
|
||||
} from "@tanstack/react-query"
|
||||
import { z } from "zod"
|
||||
import { client } from "../../lib/client"
|
||||
import { sdk } from "../../lib/client"
|
||||
import { queryClient } from "../../lib/query-client"
|
||||
import { queryKeysFactory } from "../../lib/query-key-factory"
|
||||
import { CreateCustomerGroupSchema } from "../../routes/customer-groups/customer-group-create/components/create-customer-group-form"
|
||||
import { EditCustomerGroupSchema } from "../../routes/customer-groups/customer-group-edit/components/edit-customer-group-form"
|
||||
import { customersQueryKeys } from "./customers"
|
||||
|
||||
const CUSTOMER_GROUPS_QUERY_KEY = "customer_groups" as const
|
||||
@@ -22,12 +19,11 @@ export const customerGroupsQueryKeys = queryKeysFactory(
|
||||
|
||||
export const useCustomerGroup = (
|
||||
id: string,
|
||||
query?: Record<string, any>,
|
||||
options?: Omit<
|
||||
UseQueryOptions<
|
||||
{ customer_group: HttpTypes.AdminCustomerGroup },
|
||||
HttpTypes.AdminCustomerGroupResponse,
|
||||
FetchError,
|
||||
{ customer_group: HttpTypes.AdminCustomerGroup },
|
||||
HttpTypes.AdminCustomerGroupResponse,
|
||||
QueryKey
|
||||
>,
|
||||
"queryFn" | "queryKey"
|
||||
@@ -35,7 +31,7 @@ export const useCustomerGroup = (
|
||||
) => {
|
||||
const { data, ...rest } = useQuery({
|
||||
queryKey: customerGroupsQueryKeys.detail(id),
|
||||
queryFn: async () => client.customerGroups.retrieve(id, query),
|
||||
queryFn: async () => sdk.admin.customerGroup.retrieve(id),
|
||||
...options,
|
||||
})
|
||||
|
||||
@@ -46,16 +42,16 @@ export const useCustomerGroups = (
|
||||
query?: Record<string, any>,
|
||||
options?: Omit<
|
||||
UseQueryOptions<
|
||||
PaginatedResponse<{ customer_groups: HttpTypes.AdminCustomerGroup[] }>,
|
||||
HttpTypes.AdminGetCustomerGroupsParams,
|
||||
FetchError,
|
||||
PaginatedResponse<{ customer_groups: HttpTypes.AdminCustomerGroup[] }>,
|
||||
HttpTypes.AdminCustomerGroupListResponse,
|
||||
QueryKey
|
||||
>,
|
||||
"queryFn" | "queryKey"
|
||||
>
|
||||
) => {
|
||||
const { data, ...rest } = useQuery({
|
||||
queryFn: () => client.customerGroups.list(query),
|
||||
queryFn: () => sdk.admin.customerGroup.list(query),
|
||||
queryKey: customerGroupsQueryKeys.list(query),
|
||||
...options,
|
||||
})
|
||||
@@ -65,13 +61,13 @@ export const useCustomerGroups = (
|
||||
|
||||
export const useCreateCustomerGroup = (
|
||||
options?: UseMutationOptions<
|
||||
{ customer_group: HttpTypes.AdminCustomerGroup },
|
||||
HttpTypes.AdminCustomerGroupResponse,
|
||||
FetchError,
|
||||
z.infer<typeof CreateCustomerGroupSchema>
|
||||
HttpTypes.AdminCreateCustomerGroup
|
||||
>
|
||||
) => {
|
||||
return useMutation({
|
||||
mutationFn: (payload) => client.customerGroups.create(payload),
|
||||
mutationFn: (payload) => sdk.admin.customerGroup.create(payload),
|
||||
onSuccess: (data, variables, context) => {
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: customerGroupsQueryKeys.lists(),
|
||||
@@ -85,13 +81,13 @@ export const useCreateCustomerGroup = (
|
||||
export const useUpdateCustomerGroup = (
|
||||
id: string,
|
||||
options?: UseMutationOptions<
|
||||
{ customer_group: HttpTypes.AdminCustomerGroup },
|
||||
HttpTypes.AdminCustomerGroupResponse,
|
||||
FetchError,
|
||||
z.infer<typeof EditCustomerGroupSchema>
|
||||
HttpTypes.AdminUpdateCustomerGroup
|
||||
>
|
||||
) => {
|
||||
return useMutation({
|
||||
mutationFn: (payload) => client.customerGroups.update(id, payload),
|
||||
mutationFn: (payload) => sdk.admin.customerGroup.update(id, payload),
|
||||
onSuccess: (data, variables, context) => {
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: customerGroupsQueryKeys.lists(),
|
||||
@@ -109,13 +105,13 @@ export const useUpdateCustomerGroup = (
|
||||
export const useDeleteCustomerGroup = (
|
||||
id: string,
|
||||
options?: UseMutationOptions<
|
||||
{ id: string; object: "customer-group"; deleted: boolean },
|
||||
HttpTypes.DeleteResponse<"customer_group">,
|
||||
FetchError,
|
||||
void
|
||||
>
|
||||
) => {
|
||||
return useMutation({
|
||||
mutationFn: () => client.customerGroups.delete(id),
|
||||
mutationFn: () => sdk.admin.customerGroup.delete(id),
|
||||
onSuccess: (data, variables, context) => {
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: customerGroupsQueryKeys.lists(),
|
||||
@@ -133,13 +129,14 @@ export const useDeleteCustomerGroup = (
|
||||
export const useAddCustomersToGroup = (
|
||||
id: string,
|
||||
options?: UseMutationOptions<
|
||||
{ customer_group: HttpTypes.AdminCustomerGroup },
|
||||
HttpTypes.AdminCustomerGroupResponse,
|
||||
FetchError,
|
||||
{ customer_ids: string[] }
|
||||
HttpTypes.AdminBatchLink["add"]
|
||||
>
|
||||
) => {
|
||||
return useMutation({
|
||||
mutationFn: (payload) => client.customerGroups.addCustomers(id, payload),
|
||||
mutationFn: (payload) =>
|
||||
sdk.admin.customerGroup.batchCustomers(id, { add: payload }),
|
||||
onSuccess: (data, variables, context) => {
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: customerGroupsQueryKeys.lists(),
|
||||
@@ -160,13 +157,14 @@ export const useAddCustomersToGroup = (
|
||||
export const useRemoveCustomersFromGroup = (
|
||||
id: string,
|
||||
options?: UseMutationOptions<
|
||||
{ customer_group: HttpTypes.AdminCustomerGroup },
|
||||
HttpTypes.AdminCustomerGroupResponse,
|
||||
FetchError,
|
||||
{ customer_ids: string[] }
|
||||
HttpTypes.AdminBatchLink["remove"]
|
||||
>
|
||||
) => {
|
||||
return useMutation({
|
||||
mutationFn: (payload) => client.customerGroups.removeCustomers(id, payload),
|
||||
mutationFn: (payload) =>
|
||||
sdk.admin.customerGroup.batchCustomers(id, { remove: payload }),
|
||||
onSuccess: (data, variables, context) => {
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: customerGroupsQueryKeys.lists(),
|
||||
|
||||
@@ -5,24 +5,15 @@ import {
|
||||
useMutation,
|
||||
useQuery,
|
||||
} from "@tanstack/react-query"
|
||||
import {
|
||||
CreateReservationReq,
|
||||
UpdateReservationReq,
|
||||
} from "../../types/api-payloads"
|
||||
import {
|
||||
ReservationItemDeleteRes,
|
||||
ReservationItemListRes,
|
||||
ReservationItemRes,
|
||||
} from "../../types/api-responses"
|
||||
|
||||
import { InventoryTypes } from "@medusajs/types"
|
||||
import { client } from "../../lib/client"
|
||||
import { HttpTypes } from "@medusajs/types"
|
||||
import { sdk } from "../../lib/client"
|
||||
import { queryClient } from "../../lib/query-client"
|
||||
import { queryKeysFactory } from "../../lib/query-key-factory"
|
||||
import {
|
||||
inventoryItemLevelsQueryKeys,
|
||||
inventoryItemsQueryKeys,
|
||||
} from "./inventory.tsx"
|
||||
import { FetchError } from "@medusajs/js-sdk"
|
||||
|
||||
const RESERVATION_ITEMS_QUERY_KEY = "reservation_items" as const
|
||||
export const reservationItemsQueryKeys = queryKeysFactory(
|
||||
@@ -31,15 +22,20 @@ export const reservationItemsQueryKeys = queryKeysFactory(
|
||||
|
||||
export const useReservationItem = (
|
||||
id: string,
|
||||
query?: Record<string, any>,
|
||||
query?: HttpTypes.AdminReservationParams,
|
||||
options?: Omit<
|
||||
UseQueryOptions<ReservationItemRes, Error, ReservationItemRes, QueryKey>,
|
||||
UseQueryOptions<
|
||||
HttpTypes.AdminReservationResponse,
|
||||
FetchError,
|
||||
HttpTypes.AdminReservationResponse,
|
||||
QueryKey
|
||||
>,
|
||||
"queryFn" | "queryKey"
|
||||
>
|
||||
) => {
|
||||
const { data, ...rest } = useQuery({
|
||||
queryKey: reservationItemsQueryKeys.detail(id),
|
||||
queryFn: async () => client.reservations.retrieve(id, query),
|
||||
queryFn: async () => sdk.admin.reservation.retrieve(id, query),
|
||||
...options,
|
||||
})
|
||||
|
||||
@@ -47,19 +43,19 @@ export const useReservationItem = (
|
||||
}
|
||||
|
||||
export const useReservationItems = (
|
||||
query?: Record<string, any>,
|
||||
query?: HttpTypes.AdminGetReservationsParams,
|
||||
options?: Omit<
|
||||
UseQueryOptions<
|
||||
ReservationItemListRes,
|
||||
Error,
|
||||
ReservationItemListRes,
|
||||
HttpTypes.AdminGetReservationsParams,
|
||||
FetchError,
|
||||
HttpTypes.AdminReservationListResponse,
|
||||
QueryKey
|
||||
>,
|
||||
"queryKey" | "queryFn"
|
||||
>
|
||||
) => {
|
||||
const { data, ...rest } = useQuery({
|
||||
queryFn: () => client.reservations.list(query),
|
||||
queryFn: () => sdk.admin.reservation.list(query),
|
||||
queryKey: reservationItemsQueryKeys.list(query),
|
||||
...options,
|
||||
})
|
||||
@@ -69,11 +65,15 @@ export const useReservationItems = (
|
||||
|
||||
export const useUpdateReservationItem = (
|
||||
id: string,
|
||||
options?: UseMutationOptions<ReservationItemRes, Error, UpdateReservationReq>
|
||||
options?: UseMutationOptions<
|
||||
HttpTypes.AdminReservationResponse,
|
||||
FetchError,
|
||||
HttpTypes.AdminUpdateReservation
|
||||
>
|
||||
) => {
|
||||
return useMutation({
|
||||
mutationFn: (payload: InventoryTypes.UpdateReservationItemInput) =>
|
||||
client.reservations.update(id, payload),
|
||||
mutationFn: (payload: HttpTypes.AdminUpdateReservation) =>
|
||||
sdk.admin.reservation.update(id, payload),
|
||||
onSuccess: (data, variables, context) => {
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: reservationItemsQueryKeys.detail(id),
|
||||
@@ -94,11 +94,15 @@ export const useUpdateReservationItem = (
|
||||
}
|
||||
|
||||
export const useCreateReservationItem = (
|
||||
options?: UseMutationOptions<ReservationItemRes, Error, CreateReservationReq>
|
||||
options?: UseMutationOptions<
|
||||
HttpTypes.AdminReservationResponse,
|
||||
FetchError,
|
||||
HttpTypes.AdminCreateReservation
|
||||
>
|
||||
) => {
|
||||
return useMutation({
|
||||
mutationFn: (payload: CreateReservationReq) =>
|
||||
client.reservations.create(payload),
|
||||
mutationFn: (payload: HttpTypes.AdminCreateReservation) =>
|
||||
sdk.admin.reservation.create(payload),
|
||||
onSuccess: (data, variables, context) => {
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: reservationItemsQueryKeys.lists(),
|
||||
@@ -117,10 +121,14 @@ export const useCreateReservationItem = (
|
||||
|
||||
export const useDeleteReservationItem = (
|
||||
id: string,
|
||||
options?: UseMutationOptions<ReservationItemDeleteRes, Error, void>
|
||||
options?: UseMutationOptions<
|
||||
HttpTypes.DeleteResponse<"reservation">,
|
||||
FetchError,
|
||||
void
|
||||
>
|
||||
) => {
|
||||
return useMutation({
|
||||
mutationFn: () => client.reservations.delete(id),
|
||||
mutationFn: () => sdk.admin.reservation.delete(id),
|
||||
onSuccess: (data, variables, context) => {
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: reservationItemsQueryKeys.lists(),
|
||||
|
||||
@@ -1,11 +1,7 @@
|
||||
import Medusa from "@medusajs/js-sdk"
|
||||
import { campaigns } from "./campaigns"
|
||||
import { categories } from "./categories"
|
||||
import { customerGroups } from "./customer-groups"
|
||||
import { fulfillmentProviders } from "./fulfillment-providers"
|
||||
import { promotions } from "./promotions"
|
||||
import { reservations } from "./reservations"
|
||||
import { stockLocations } from "./stock-locations"
|
||||
import { workflowExecutions } from "./workflow-executions"
|
||||
|
||||
export const backendUrl = __BACKEND_URL__ ?? "http://localhost:9000"
|
||||
@@ -13,11 +9,7 @@ export const backendUrl = __BACKEND_URL__ ?? "http://localhost:9000"
|
||||
export const client = {
|
||||
campaigns: campaigns,
|
||||
categories: categories,
|
||||
customerGroups: customerGroups,
|
||||
promotions: promotions,
|
||||
reservations: reservations,
|
||||
fulfillmentProviders: fulfillmentProviders,
|
||||
stockLocations: stockLocations,
|
||||
workflowExecutions: workflowExecutions,
|
||||
}
|
||||
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
import { CurrencyListRes, CurrencyRes } from "../../types/api-responses"
|
||||
import { getRequest } from "./common"
|
||||
|
||||
async function retrieveCurrency(id: string, query?: Record<string, any>) {
|
||||
return getRequest<CurrencyRes>(`/admin/currencies/${id}`, query)
|
||||
}
|
||||
|
||||
async function listCurrencies(query?: Record<string, any>) {
|
||||
return getRequest<CurrencyListRes>("/admin/currencies", query)
|
||||
}
|
||||
|
||||
export const currencies = {
|
||||
retrieve: retrieveCurrency,
|
||||
list: listCurrencies,
|
||||
}
|
||||
@@ -1,79 +0,0 @@
|
||||
import { z } from "zod"
|
||||
import { CreateCustomerGroupSchema } from "../../routes/customer-groups/customer-group-create/components/create-customer-group-form"
|
||||
import { EditCustomerGroupSchema } from "../../routes/customer-groups/customer-group-edit/components/edit-customer-group-form"
|
||||
import { deleteRequest, getRequest, postRequest } from "./common"
|
||||
import { HttpTypes, PaginatedResponse } from "@medusajs/types"
|
||||
|
||||
async function retrieveCustomerGroup(id: string, query?: Record<string, any>) {
|
||||
return getRequest<{ customer_group: HttpTypes.AdminCustomerGroup }>(
|
||||
`/admin/customer-groups/${id}`,
|
||||
query
|
||||
)
|
||||
}
|
||||
|
||||
async function listCustomerGroups(query?: Record<string, any>) {
|
||||
return getRequest<
|
||||
PaginatedResponse<{ customer_groups: HttpTypes.AdminCustomerGroup[] }>
|
||||
>(`/admin/customer-groups`, query)
|
||||
}
|
||||
|
||||
async function createCustomerGroup(
|
||||
payload: z.infer<typeof CreateCustomerGroupSchema>
|
||||
) {
|
||||
return postRequest<{ customer_group: HttpTypes.AdminCustomerGroup }>(
|
||||
`/admin/customer-groups`,
|
||||
payload
|
||||
)
|
||||
}
|
||||
|
||||
async function updateCustomerGroup(
|
||||
id: string,
|
||||
payload: z.infer<typeof EditCustomerGroupSchema>
|
||||
) {
|
||||
return postRequest<{ customer_group: HttpTypes.AdminCustomerGroup }>(
|
||||
`/admin/customer-groups/${id}`,
|
||||
payload
|
||||
)
|
||||
}
|
||||
|
||||
async function deleteCustomerGroup(id: string) {
|
||||
return deleteRequest<{
|
||||
id: string
|
||||
deleted: boolean
|
||||
object: "customer-group"
|
||||
}>(`/admin/customer-groups/${id}`)
|
||||
}
|
||||
|
||||
async function batchAddCustomers(
|
||||
id: string,
|
||||
payload: { customer_ids: string[] }
|
||||
) {
|
||||
return postRequest<{ customer_group: HttpTypes.AdminCustomerGroup }>(
|
||||
`/admin/customer-groups/${id}/customers`,
|
||||
{
|
||||
add: payload.customer_ids,
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
async function batchRemoveCustomers(
|
||||
id: string,
|
||||
payload: { customer_ids: string[] }
|
||||
) {
|
||||
return postRequest<{ customer_group: HttpTypes.AdminCustomerGroup }>(
|
||||
`/admin/customer-groups/${id}/customers`,
|
||||
{
|
||||
remove: payload.customer_ids,
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
export const customerGroups = {
|
||||
retrieve: retrieveCustomerGroup,
|
||||
list: listCustomerGroups,
|
||||
create: createCustomerGroup,
|
||||
update: updateCustomerGroup,
|
||||
delete: deleteCustomerGroup,
|
||||
addCustomers: batchAddCustomers,
|
||||
removeCustomers: batchRemoveCustomers,
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
import { getRequest } from "./common"
|
||||
import { FulfillmentProvidersListRes } from "../../types/api-responses"
|
||||
|
||||
async function listFulfillmentProviders(query?: Record<string, any>) {
|
||||
return getRequest<FulfillmentProvidersListRes>(
|
||||
`/admin/fulfillment-providers`,
|
||||
query
|
||||
)
|
||||
}
|
||||
|
||||
export const fulfillmentProviders = {
|
||||
list: listFulfillmentProviders,
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
import {
|
||||
ReservationDeleteRes,
|
||||
ReservationListRes,
|
||||
ReservationRes,
|
||||
} from "../../types/api-responses"
|
||||
import { deleteRequest, getRequest, postRequest } from "./common"
|
||||
|
||||
import { InventoryTypes } from "@medusajs/types"
|
||||
|
||||
async function retrieveReservation(id: string, query?: Record<string, any>) {
|
||||
return getRequest<ReservationRes>(`/admin/reservations/${id}`, query)
|
||||
}
|
||||
|
||||
async function listReservations(query?: Record<string, any>) {
|
||||
return getRequest<ReservationListRes>(`/admin/reservations`, query)
|
||||
}
|
||||
|
||||
async function createReservation(
|
||||
payload: InventoryTypes.CreateReservationItemInput
|
||||
) {
|
||||
return postRequest<ReservationRes>(`/admin/reservations`, payload)
|
||||
}
|
||||
|
||||
async function updateReservation(
|
||||
id: string,
|
||||
payload: InventoryTypes.UpdateReservationItemInput
|
||||
) {
|
||||
return postRequest<ReservationRes>(`/admin/reservations/${id}`, payload)
|
||||
}
|
||||
|
||||
async function deleteReservation(id: string) {
|
||||
return deleteRequest<ReservationDeleteRes>(`/admin/reservations/${id}`)
|
||||
}
|
||||
|
||||
export const reservations = {
|
||||
retrieve: retrieveReservation,
|
||||
list: listReservations,
|
||||
create: createReservation,
|
||||
update: updateReservation,
|
||||
delete: deleteReservation,
|
||||
}
|
||||
@@ -1,78 +0,0 @@
|
||||
import {
|
||||
AdminSalesChannelListResponse,
|
||||
AdminSalesChannelResponse,
|
||||
} from "@medusajs/types"
|
||||
import {
|
||||
AddProductsSalesChannelReq,
|
||||
CreateSalesChannelReq,
|
||||
RemoveProductsSalesChannelReq,
|
||||
UpdateSalesChannelReq,
|
||||
} from "../../types/api-payloads"
|
||||
import { SalesChannelDeleteRes } from "../../types/api-responses"
|
||||
import { deleteRequest, getRequest, postRequest } from "./common"
|
||||
|
||||
async function retrieveSalesChannel(id: string, query?: Record<string, any>) {
|
||||
return getRequest<AdminSalesChannelResponse, Record<string, any>>(
|
||||
`/admin/sales-channels/${id}`,
|
||||
query
|
||||
)
|
||||
}
|
||||
|
||||
async function listSalesChannels(query?: Record<string, any>) {
|
||||
return getRequest<AdminSalesChannelListResponse, Record<string, any>>(
|
||||
`/admin/sales-channels`,
|
||||
query
|
||||
)
|
||||
}
|
||||
|
||||
async function createSalesChannel(payload: CreateSalesChannelReq) {
|
||||
return postRequest<AdminSalesChannelResponse>(
|
||||
`/admin/sales-channels`,
|
||||
payload
|
||||
)
|
||||
}
|
||||
|
||||
async function updateSalesChannel(id: string, payload: UpdateSalesChannelReq) {
|
||||
return postRequest<AdminSalesChannelResponse>(
|
||||
`/admin/sales-channels/${id}`,
|
||||
payload
|
||||
)
|
||||
}
|
||||
|
||||
async function deleteSalesChannel(id: string) {
|
||||
return deleteRequest<SalesChannelDeleteRes>(`/admin/sales-channels/${id}`)
|
||||
}
|
||||
|
||||
async function batchRemoveProducts(
|
||||
id: string,
|
||||
payload: RemoveProductsSalesChannelReq
|
||||
) {
|
||||
return postRequest<AdminSalesChannelResponse>(
|
||||
`/admin/sales-channels/${id}/products`,
|
||||
{
|
||||
remove: payload.product_ids,
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
async function batchAddProducts(
|
||||
id: string,
|
||||
payload: AddProductsSalesChannelReq
|
||||
) {
|
||||
return postRequest<AdminSalesChannelResponse>(
|
||||
`/admin/sales-channels/${id}/products`,
|
||||
{
|
||||
add: payload.product_ids,
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
export const salesChannels = {
|
||||
retrieve: retrieveSalesChannel,
|
||||
list: listSalesChannels,
|
||||
create: createSalesChannel,
|
||||
update: updateSalesChannel,
|
||||
delete: deleteSalesChannel,
|
||||
removeProducts: batchRemoveProducts,
|
||||
addProducts: batchAddProducts,
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
import { deleteRequest, getRequest, postRequest } from "./common"
|
||||
import {
|
||||
ShippingOptionDeleteRes,
|
||||
ShippingOptionListRes,
|
||||
ShippingOptionRes,
|
||||
} from "../../types/api-responses"
|
||||
import {
|
||||
CreateShippingOptionReq,
|
||||
UpdateShippingOptionReq,
|
||||
} from "../../types/api-payloads"
|
||||
|
||||
async function createShippingOptions(payload: CreateShippingOptionReq) {
|
||||
return postRequest<ShippingOptionRes>(`/admin/shipping-options`, payload)
|
||||
}
|
||||
|
||||
async function updateShippingOptions(
|
||||
id: string,
|
||||
payload: UpdateShippingOptionReq
|
||||
) {
|
||||
return postRequest<ShippingOptionRes>(
|
||||
`/admin/shipping-options/${id}`,
|
||||
payload
|
||||
)
|
||||
}
|
||||
|
||||
async function listShippingOptions(query?: Record<string, any>) {
|
||||
return getRequest<ShippingOptionListRes>(`/admin/shipping-options`, query)
|
||||
}
|
||||
|
||||
async function deleteShippingOption(optionId: string) {
|
||||
return deleteRequest<ShippingOptionDeleteRes>(
|
||||
`/admin/shipping-options/${optionId}`
|
||||
)
|
||||
}
|
||||
|
||||
export const shippingOptions = {
|
||||
create: createShippingOptions,
|
||||
update: updateShippingOptions,
|
||||
delete: deleteShippingOption,
|
||||
list: listShippingOptions,
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
import { CreateShippingProfileReq } from "../../types/api-payloads"
|
||||
import {
|
||||
ShippingProfileDeleteRes,
|
||||
ShippingProfileListRes,
|
||||
ShippingProfileRes,
|
||||
} from "../../types/api-responses"
|
||||
import { deleteRequest, getRequest, postRequest } from "./common"
|
||||
|
||||
async function createShippingProfile(payload: CreateShippingProfileReq) {
|
||||
return postRequest<ShippingProfileRes>(`/admin/shipping-profiles`, payload)
|
||||
}
|
||||
|
||||
async function retrieveShippingProfile(
|
||||
id: string,
|
||||
query?: Record<string, any>
|
||||
) {
|
||||
return getRequest<ShippingProfileRes>(`/admin/shipping-profiles/${id}`, query)
|
||||
}
|
||||
|
||||
async function listShippingProfiles(query?: Record<string, any>) {
|
||||
return getRequest<ShippingProfileListRes>(`/admin/shipping-profiles`, query)
|
||||
}
|
||||
|
||||
async function deleteShippingProfile(id: string) {
|
||||
return deleteRequest<ShippingProfileDeleteRes>(
|
||||
`/admin/shipping-profiles/${id}`
|
||||
)
|
||||
}
|
||||
|
||||
export const shippingProfiles = {
|
||||
retrieve: retrieveShippingProfile,
|
||||
list: listShippingProfiles,
|
||||
create: createShippingProfile,
|
||||
delete: deleteShippingProfile,
|
||||
}
|
||||
@@ -1,106 +0,0 @@
|
||||
import {
|
||||
CreateFulfillmentSetReq,
|
||||
CreateServiceZoneReq,
|
||||
CreateStockLocationReq,
|
||||
UpdateServiceZoneReq,
|
||||
UpdateStockLocationReq,
|
||||
UpdateStockLocationSalesChannelsReq,
|
||||
} from "../../types/api-payloads"
|
||||
import {
|
||||
FulfillmentSetDeleteRes,
|
||||
ServiceZoneDeleteRes,
|
||||
StockLocationDeleteRes,
|
||||
StockLocationListRes,
|
||||
StockLocationRes,
|
||||
} from "../../types/api-responses"
|
||||
import { deleteRequest, getRequest, postRequest } from "./common"
|
||||
|
||||
async function listStockLocations(query?: Record<string, any>) {
|
||||
return getRequest<StockLocationListRes>(`/admin/stock-locations`, query)
|
||||
}
|
||||
|
||||
async function retrieveStockLocation(id: string, query?: Record<string, any>) {
|
||||
return getRequest<StockLocationRes>(`/admin/stock-locations/${id}`, query)
|
||||
}
|
||||
|
||||
async function createStockLocation(payload: CreateStockLocationReq) {
|
||||
return postRequest<StockLocationRes>(`/admin/stock-locations`, payload)
|
||||
}
|
||||
|
||||
async function createFulfillmentSet(
|
||||
locationId: string,
|
||||
payload: CreateFulfillmentSetReq
|
||||
) {
|
||||
return postRequest<StockLocationRes>(
|
||||
`/admin/stock-locations/${locationId}/fulfillment-sets`,
|
||||
payload
|
||||
)
|
||||
}
|
||||
|
||||
async function createServiceZone(
|
||||
fulfillmentSetId: string,
|
||||
payload: CreateServiceZoneReq
|
||||
) {
|
||||
return postRequest<StockLocationRes>(
|
||||
`/admin/fulfillment-sets/${fulfillmentSetId}/service-zones`,
|
||||
payload
|
||||
)
|
||||
}
|
||||
|
||||
async function updateServiceZone(
|
||||
fulfillmentSetId: string,
|
||||
serviceZoneId: string,
|
||||
payload: UpdateServiceZoneReq
|
||||
) {
|
||||
return postRequest<StockLocationRes>(
|
||||
`/admin/fulfillment-sets/${fulfillmentSetId}/service-zones/${serviceZoneId}`,
|
||||
payload
|
||||
)
|
||||
}
|
||||
|
||||
async function updateStockLocation(
|
||||
id: string,
|
||||
payload: UpdateStockLocationReq
|
||||
) {
|
||||
return postRequest<StockLocationRes>(`/admin/stock-locations/${id}`, payload)
|
||||
}
|
||||
|
||||
async function updateStockLocationSalesChannels(
|
||||
id: string,
|
||||
payload: UpdateStockLocationSalesChannelsReq
|
||||
) {
|
||||
return postRequest<StockLocationRes>(
|
||||
`/admin/stock-locations/${id}/sales-channels`,
|
||||
payload
|
||||
)
|
||||
}
|
||||
|
||||
async function deleteStockLocation(id: string) {
|
||||
return deleteRequest<StockLocationDeleteRes>(`/admin/stock-locations/${id}`)
|
||||
}
|
||||
|
||||
async function deleteFulfillmentSet(setId: string) {
|
||||
return deleteRequest<FulfillmentSetDeleteRes>(
|
||||
`/admin/fulfillment-sets/${setId}`
|
||||
)
|
||||
}
|
||||
|
||||
async function deleteServiceZone(setId: string, zoneId: string) {
|
||||
return deleteRequest<ServiceZoneDeleteRes>(
|
||||
`/admin/fulfillment-sets/${setId}/service-zones/${zoneId}`
|
||||
)
|
||||
}
|
||||
|
||||
export const stockLocations = {
|
||||
list: listStockLocations,
|
||||
retrieve: retrieveStockLocation,
|
||||
create: createStockLocation,
|
||||
update: updateStockLocation,
|
||||
delete: deleteStockLocation,
|
||||
updateSalesChannels: updateStockLocationSalesChannels,
|
||||
createFulfillmentSet,
|
||||
deleteFulfillmentSet,
|
||||
createServiceZone,
|
||||
deleteServiceZone,
|
||||
updateServiceZone,
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
import { UpdateStoreReq } from "../../types/api-payloads"
|
||||
import { StoreListRes, StoreRes } from "../../types/api-responses"
|
||||
import { getRequest, postRequest } from "./common"
|
||||
|
||||
async function retrieveStore(query?: Record<string, any>): Promise<StoreRes> {
|
||||
const response = await getRequest<StoreListRes>("/admin/stores", query)
|
||||
|
||||
const activeStore = response.stores?.[0]
|
||||
|
||||
if (!activeStore) {
|
||||
// Temp: Add proper error handling
|
||||
throw new Error("No active store found")
|
||||
}
|
||||
|
||||
return { store: activeStore }
|
||||
}
|
||||
|
||||
async function updateStore(id: string, payload: UpdateStoreReq) {
|
||||
return postRequest<StoreRes>(`/admin/stores/${id}`, payload)
|
||||
}
|
||||
|
||||
export const stores = {
|
||||
retrieve: retrieveStore,
|
||||
update: updateStore,
|
||||
}
|
||||
+13
-18
@@ -103,25 +103,20 @@ export const AddCustomersForm = ({
|
||||
const { mutateAsync, isPending } = useAddCustomersToGroup(customerGroupId)
|
||||
|
||||
const handleSubmit = form.handleSubmit(async (data) => {
|
||||
await mutateAsync(
|
||||
{
|
||||
customer_ids: data.customer_ids,
|
||||
},
|
||||
{
|
||||
onSuccess: () => {
|
||||
toast.success(
|
||||
t("customerGroups.customers.add.successToast", {
|
||||
count: data.customer_ids.length,
|
||||
})
|
||||
)
|
||||
await mutateAsync(data.customer_ids, {
|
||||
onSuccess: () => {
|
||||
toast.success(
|
||||
t("customerGroups.customers.add.successToast", {
|
||||
count: data.customer_ids.length,
|
||||
})
|
||||
)
|
||||
|
||||
handleSuccess(`/customer-groups/${customerGroupId}`)
|
||||
},
|
||||
onError: (error) => {
|
||||
toast.error(error.message)
|
||||
},
|
||||
}
|
||||
)
|
||||
handleSuccess(`/customer-groups/${customerGroupId}`)
|
||||
},
|
||||
onError: (error) => {
|
||||
toast.error(error.message)
|
||||
},
|
||||
})
|
||||
})
|
||||
|
||||
if (isError) {
|
||||
|
||||
+5
-12
@@ -78,16 +78,11 @@ export const CustomerGroupCustomerSection = ({
|
||||
return
|
||||
}
|
||||
|
||||
await mutateAsync(
|
||||
{
|
||||
customer_ids: keys.map((k) => ({ id: k })),
|
||||
await mutateAsync(keys, {
|
||||
onSuccess: () => {
|
||||
setRowSelection({})
|
||||
},
|
||||
{
|
||||
onSuccess: () => {
|
||||
setRowSelection({})
|
||||
},
|
||||
}
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
return (
|
||||
@@ -162,9 +157,7 @@ const CustomerActions = ({
|
||||
return
|
||||
}
|
||||
|
||||
await mutateAsync({
|
||||
customer_ids: [{ id: customer.id }],
|
||||
})
|
||||
await mutateAsync([customer.id])
|
||||
}
|
||||
|
||||
return (
|
||||
|
||||
+3
-3
@@ -1,13 +1,13 @@
|
||||
import { HttpTypes } from "@medusajs/types"
|
||||
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 { HttpTypes } from "@medusajs/types"
|
||||
|
||||
const customerGroupDetailQuery = (id: string) => ({
|
||||
queryKey: productsQueryKeys.detail(id),
|
||||
queryFn: async () =>
|
||||
client.customerGroups.retrieve(id, {
|
||||
sdk.admin.customerGroup.retrieve(id, {
|
||||
fields: "+customers.id",
|
||||
}),
|
||||
})
|
||||
|
||||
+8
-11
@@ -26,7 +26,7 @@ import { useCustomerGroupTableColumns } from "../../../../../hooks/table/columns
|
||||
import { useCustomerGroupTableFilters } from "../../../../../hooks/table/filters/use-customer-group-table-filters.tsx"
|
||||
import { useCustomerGroupTableQuery } from "../../../../../hooks/table/query/use-customer-group-table-query.tsx"
|
||||
import { useDataTable } from "../../../../../hooks/use-data-table.tsx"
|
||||
import { client } from "../../../../../lib/client/index.ts"
|
||||
import { client, sdk } from "../../../../../lib/client/index.ts"
|
||||
import { queryClient } from "../../../../../lib/query-client.ts"
|
||||
|
||||
type CustomerGroupSectionProps = {
|
||||
@@ -98,8 +98,8 @@ export const CustomerGroupSection = ({
|
||||
* TODO: use this for now until add customer groups to customers batch is implemented
|
||||
*/
|
||||
const promises = customerGroupIds.map((id) =>
|
||||
client.customerGroups.removeCustomers(id, {
|
||||
customer_ids: [customer.id],
|
||||
sdk.admin.customerGroup.batchCustomers(id, {
|
||||
remove: [customer.id],
|
||||
})
|
||||
)
|
||||
|
||||
@@ -180,14 +180,11 @@ const CustomerGroupRowActions = ({
|
||||
return
|
||||
}
|
||||
|
||||
await mutateAsync(
|
||||
{ customer_ids: [customerId] },
|
||||
{
|
||||
onError: (error) => {
|
||||
toast.error(error.message)
|
||||
},
|
||||
}
|
||||
)
|
||||
await mutateAsync([customerId], {
|
||||
onError: (error) => {
|
||||
toast.error(error.message)
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
return (
|
||||
|
||||
+4
-2
@@ -23,7 +23,7 @@ import { useCustomerGroupTableColumns } from "../../../../../hooks/table/columns
|
||||
import { useCustomerGroupTableFilters } from "../../../../../hooks/table/filters/use-customer-group-table-filters"
|
||||
import { useCustomerGroupTableQuery } from "../../../../../hooks/table/query/use-customer-group-table-query"
|
||||
import { useDataTable } from "../../../../../hooks/use-data-table"
|
||||
import { client } from "../../../../../lib/client"
|
||||
import { client, sdk } from "../../../../../lib/client"
|
||||
import { queryClient } from "../../../../../lib/query-client"
|
||||
|
||||
type AddCustomerGroupsFormProps = {
|
||||
@@ -119,7 +119,9 @@ export const AddCustomerGroupsForm = ({
|
||||
* TODO: use this for now until add customer groups to customers batch is implemented
|
||||
*/
|
||||
const promises = data.customer_group_ids.map((id) =>
|
||||
client.customerGroups.addCustomers(id, { customer_ids: [customerId] })
|
||||
sdk.admin.customerGroup.batchCustomers(id, {
|
||||
add: [customerId],
|
||||
})
|
||||
)
|
||||
|
||||
await Promise.all(promises)
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
import { Container, Heading } from "@medusajs/ui"
|
||||
import { AdminInventoryItemResponse } from "@medusajs/types"
|
||||
import { HttpTypes } from "@medusajs/types"
|
||||
|
||||
import { ActionMenu } from "../../../../components/common/action-menu"
|
||||
import { PencilSquare } from "@medusajs/icons"
|
||||
@@ -7,7 +7,7 @@ import { SectionRow } from "../../../../components/common/section"
|
||||
import { useTranslation } from "react-i18next"
|
||||
|
||||
type InventoryItemGeneralSectionProps = {
|
||||
inventoryItem: AdminInventoryItemResponse["inventory_item"]
|
||||
inventoryItem: HttpTypes.AdminInventoryItemResponse["inventory_item"]
|
||||
}
|
||||
export const InventoryItemGeneralSection = ({
|
||||
inventoryItem,
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import { HttpTypes } from "@medusajs/types"
|
||||
import { LoaderFunctionArgs } from "react-router-dom"
|
||||
import { reservationItemsQueryKeys } from "../../../hooks/api/reservations"
|
||||
import { client } from "../../../lib/client"
|
||||
import { sdk } from "../../../lib/client"
|
||||
import { queryClient } from "../../../lib/query-client"
|
||||
import { ReservationItemRes } from "../../../types/api-responses"
|
||||
|
||||
const reservationDetailQuery = (id: string) => ({
|
||||
queryKey: reservationItemsQueryKeys.detail(id),
|
||||
queryFn: async () => client.reservations.retrieve(id),
|
||||
queryFn: async () => sdk.admin.reservation.retrieve(id),
|
||||
})
|
||||
|
||||
export const reservationItemLoader = async ({ params }: LoaderFunctionArgs) => {
|
||||
@@ -14,7 +14,8 @@ export const reservationItemLoader = async ({ params }: LoaderFunctionArgs) => {
|
||||
const query = reservationDetailQuery(id!)
|
||||
|
||||
return (
|
||||
queryClient.getQueryData<ReservationItemRes>(query.queryKey) ??
|
||||
(await queryClient.fetchQuery(query))
|
||||
queryClient.getQueryData<HttpTypes.AdminReservationResponse>(
|
||||
query.queryKey
|
||||
) ?? (await queryClient.fetchQuery(query))
|
||||
)
|
||||
}
|
||||
|
||||
+2
-3
@@ -1,4 +1,4 @@
|
||||
import { AdminGetReservationsParams } from "@medusajs/medusa"
|
||||
import { HttpTypes } from "@medusajs/types"
|
||||
import { useQueryParams } from "../../../../../hooks/use-query-params"
|
||||
|
||||
export const useReservationTableQuery = ({
|
||||
@@ -15,13 +15,12 @@ export const useReservationTableQuery = ({
|
||||
|
||||
const { location_id, created_at, updated_at, quantity, offset, ...rest } = raw
|
||||
|
||||
const searchParams: AdminGetReservationsParams = {
|
||||
const searchParams: HttpTypes.AdminGetReservationsParams = {
|
||||
limit: pageSize,
|
||||
offset: offset ? parseInt(offset) : undefined,
|
||||
location_id: location_id,
|
||||
created_at: created_at ? JSON.parse(created_at) : undefined,
|
||||
updated_at: updated_at ? JSON.parse(updated_at) : undefined,
|
||||
quantity: quantity ? JSON.parse(quantity) : undefined,
|
||||
...rest,
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,97 @@
|
||||
import { HttpTypes } from "@medusajs/types"
|
||||
import { Client } from "../client"
|
||||
import { ClientHeaders } from "../types"
|
||||
|
||||
export class CustomerGroup {
|
||||
private client: Client
|
||||
constructor(client: Client) {
|
||||
this.client = client
|
||||
}
|
||||
|
||||
async retrieve(
|
||||
id: string,
|
||||
query?: HttpTypes.AdminGetCustomerGroupParams,
|
||||
headers?: ClientHeaders
|
||||
) {
|
||||
return await this.client.fetch<HttpTypes.AdminCustomerGroupResponse>(
|
||||
`/admin/customer-groups/${id}`,
|
||||
{
|
||||
method: "GET",
|
||||
query,
|
||||
headers,
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
async list(
|
||||
query?: HttpTypes.AdminGetCustomerGroupsParams,
|
||||
headers?: ClientHeaders
|
||||
) {
|
||||
return await this.client.fetch<HttpTypes.AdminCustomerGroupListResponse>(
|
||||
`/admin/customer-groups`,
|
||||
{
|
||||
method: "GET",
|
||||
headers,
|
||||
query,
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
async create(
|
||||
body: HttpTypes.AdminCreateCustomerGroup,
|
||||
query?: HttpTypes.AdminGetCustomerGroupsParams,
|
||||
headers?: ClientHeaders
|
||||
) {
|
||||
return await this.client.fetch<HttpTypes.AdminCustomerGroupResponse>(
|
||||
`/admin/customer-groups`,
|
||||
{
|
||||
method: "POST",
|
||||
headers,
|
||||
body,
|
||||
query,
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
async update(
|
||||
id: string,
|
||||
body: HttpTypes.AdminUpdateCustomerGroup,
|
||||
query?: HttpTypes.AdminGetCustomerGroupsParams,
|
||||
headers?: ClientHeaders
|
||||
) {
|
||||
return await this.client.fetch<HttpTypes.AdminCustomerGroupResponse>(
|
||||
`/admin/customer-groups/${id}`,
|
||||
{
|
||||
method: "POST",
|
||||
headers,
|
||||
body,
|
||||
query,
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
async delete(id: string, headers?: ClientHeaders) {
|
||||
return await this.client.fetch<HttpTypes.DeleteResponse<"customer_group">>(
|
||||
`/admin/customer-groups/${id}`,
|
||||
{
|
||||
method: "DELETE",
|
||||
headers,
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
async batchCustomers(
|
||||
id: string,
|
||||
body: HttpTypes.AdminBatchLink,
|
||||
headers?: ClientHeaders
|
||||
) {
|
||||
return await this.client.fetch<HttpTypes.AdminCustomerGroupResponse>(
|
||||
`/admin/customer-groups/${id}/customers`,
|
||||
{
|
||||
method: "POST",
|
||||
headers,
|
||||
body,
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@ import { ApiKey } from "./api-key"
|
||||
import { Claim } from "./claim"
|
||||
import { Currency } from "./currency"
|
||||
import { Customer } from "./customer"
|
||||
import { CustomerGroup } from "./customer-group"
|
||||
import { Exchange } from "./exchange"
|
||||
import { Fulfillment } from "./fulfillment"
|
||||
import { FulfillmentProvider } from "./fulfillment-provider"
|
||||
@@ -24,6 +25,7 @@ import { ProductType } from "./product-type"
|
||||
import { ProductVariant } from "./product-variant"
|
||||
import { RefundReason } from "./refund-reasons"
|
||||
import { Region } from "./region"
|
||||
import Reservation from "./reservation"
|
||||
import { Return } from "./return"
|
||||
import { ReturnReason } from "./return-reason"
|
||||
import { SalesChannel } from "./sales-channel"
|
||||
@@ -73,6 +75,8 @@ export class Admin {
|
||||
public refundReason: RefundReason
|
||||
public paymentCollection: PaymentCollection
|
||||
public apiKey: ApiKey
|
||||
public reservation: Reservation
|
||||
public customerGroup: CustomerGroup
|
||||
|
||||
constructor(client: Client) {
|
||||
this.invite = new Invite(client)
|
||||
@@ -111,5 +115,7 @@ export class Admin {
|
||||
this.exchange = new Exchange(client)
|
||||
this.paymentCollection = new PaymentCollection(client)
|
||||
this.apiKey = new ApiKey(client)
|
||||
this.reservation = new Reservation(client)
|
||||
this.customerGroup = new CustomerGroup(client)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
import { HttpTypes } from "@medusajs/types"
|
||||
import { Client } from "../client"
|
||||
import { ClientHeaders } from "../types"
|
||||
|
||||
class Reservation {
|
||||
private client: Client
|
||||
constructor(client: Client) {
|
||||
this.client = client
|
||||
}
|
||||
|
||||
async retrieve(
|
||||
id: string,
|
||||
query?: HttpTypes.AdminReservationParams,
|
||||
headers?: ClientHeaders
|
||||
) {
|
||||
return await this.client.fetch<HttpTypes.AdminReservationResponse>(
|
||||
`/admin/reservations/${id}`,
|
||||
{
|
||||
method: "GET",
|
||||
headers,
|
||||
query,
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
async list(
|
||||
query?: HttpTypes.AdminGetReservationsParams,
|
||||
headers?: ClientHeaders
|
||||
) {
|
||||
return await this.client.fetch<HttpTypes.AdminReservationListResponse>(
|
||||
"/admin/reservations",
|
||||
{
|
||||
method: "GET",
|
||||
query,
|
||||
headers,
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
async create(
|
||||
body: HttpTypes.AdminCreateReservation,
|
||||
query?: HttpTypes.AdminGetReservationsParams,
|
||||
headers?: ClientHeaders
|
||||
) {
|
||||
return await this.client.fetch<HttpTypes.AdminReservationResponse>(
|
||||
"/admin/reservations",
|
||||
{
|
||||
method: "POST",
|
||||
body,
|
||||
query,
|
||||
headers,
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
async update(
|
||||
id: string,
|
||||
body: HttpTypes.AdminUpdateReservation,
|
||||
query?: HttpTypes.AdminGetReservationsParams,
|
||||
headers?: ClientHeaders
|
||||
) {
|
||||
return await this.client.fetch<HttpTypes.AdminReservationResponse>(
|
||||
`/admin/reservations/${id}`,
|
||||
{
|
||||
method: "POST",
|
||||
body,
|
||||
query,
|
||||
headers,
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
async delete(id: string, headers?: ClientHeaders) {
|
||||
return await this.client.fetch<HttpTypes.DeleteResponse<"reservation">>(
|
||||
`/admin/reservations/${id}`,
|
||||
{
|
||||
method: "DELETE",
|
||||
headers,
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
export default Reservation
|
||||
@@ -0,0 +1,3 @@
|
||||
import { BaseCustomerGroup } from "../common"
|
||||
|
||||
export interface AdminCustomerGroup extends BaseCustomerGroup {}
|
||||
@@ -0,0 +1,4 @@
|
||||
export * from "./entities"
|
||||
export * from "./payloads"
|
||||
export * from "./queries"
|
||||
export * from "./responses"
|
||||
@@ -0,0 +1,9 @@
|
||||
export interface AdminCreateCustomerGroup {
|
||||
name: string
|
||||
metadata?: Record<string, unknown> | null
|
||||
}
|
||||
|
||||
export interface AdminUpdateCustomerGroup {
|
||||
name?: string
|
||||
metadata?: Record<string, unknown> | null
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
import { OperatorMap } from "../../../dal"
|
||||
import { SelectParams } from "../../common"
|
||||
|
||||
export interface AdminCustomerInGroupFilters {
|
||||
id?: string | string[]
|
||||
email?: string | string[] | OperatorMap<string>
|
||||
default_billing_address_id?: string | string[]
|
||||
default_shipping_address_id?: string | string[]
|
||||
company_name?: string | string[]
|
||||
first_name?: string | string[]
|
||||
last_name?: string | string[]
|
||||
created_by?: string | string[]
|
||||
created_at?: OperatorMap<string>
|
||||
updated_at?: OperatorMap<string>
|
||||
deleted_at?: OperatorMap<string>
|
||||
}
|
||||
|
||||
export interface AdminGetCustomerGroupsParams {
|
||||
limit?: number
|
||||
offset?: number
|
||||
q?: string
|
||||
id?: string | string[]
|
||||
name?: string | string[]
|
||||
customers?: string | string[] | AdminCustomerInGroupFilters
|
||||
created_by?: string | string[]
|
||||
created_at?: OperatorMap<string>
|
||||
updated_at?: OperatorMap<string>
|
||||
deleted_at?: OperatorMap<string>
|
||||
$and?: AdminGetCustomerGroupsParams[]
|
||||
$or?: AdminGetCustomerGroupsParams[]
|
||||
}
|
||||
|
||||
export interface AdminGetCustomerGroupParams extends SelectParams {}
|
||||
@@ -0,0 +1,10 @@
|
||||
import { PaginatedResponse } from "../../common"
|
||||
import { AdminCustomerGroup } from "./entities"
|
||||
|
||||
export interface AdminCustomerGroupResponse {
|
||||
customer_group: AdminCustomerGroup
|
||||
}
|
||||
|
||||
export type AdminCustomerGroupListResponse = PaginatedResponse<{
|
||||
customer_groups: AdminCustomerGroup[]
|
||||
}>
|
||||
@@ -0,0 +1,10 @@
|
||||
import { BaseCustomer } from "../customer/common"
|
||||
|
||||
export interface BaseCustomerGroup {
|
||||
id: string
|
||||
name: string | null
|
||||
customers: BaseCustomer[]
|
||||
metadata: Record<string, unknown> | null
|
||||
created_at: string
|
||||
updated_at: string
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
export * from "./admin";
|
||||
|
||||
@@ -1,12 +1,8 @@
|
||||
import {
|
||||
BaseCustomer,
|
||||
BaseCustomerAddress,
|
||||
BaseCustomerGroup,
|
||||
} from "../common"
|
||||
import { AdminCustomerGroup } from "../../customer-group"
|
||||
import { BaseCustomer, BaseCustomerAddress } from "../common"
|
||||
|
||||
export interface AdminCustomerGroup extends BaseCustomerGroup {}
|
||||
export interface AdminCustomer extends BaseCustomer {
|
||||
has_account: boolean
|
||||
groups?: AdminCustomerGroup[]
|
||||
}
|
||||
export interface AdminCustomerAddress extends BaseCustomerAddress {}
|
||||
export interface AdminCustomerAddress extends BaseCustomerAddress {}
|
||||
|
||||
@@ -1,18 +1,12 @@
|
||||
import { PaginatedResponse } from "../../common";
|
||||
import { AdminCustomer, AdminCustomerAddress, AdminCustomerGroup } from "./entities";
|
||||
import { PaginatedResponse } from "../../common"
|
||||
import { AdminCustomer, AdminCustomerAddress } from "./entities"
|
||||
|
||||
export interface AdminCustomerResponse {
|
||||
customer: AdminCustomer
|
||||
}
|
||||
|
||||
export type AdminCustomerListResponse = PaginatedResponse<{ customers: AdminCustomer }>
|
||||
|
||||
export interface AdminCustomerGroupResponse {
|
||||
customer_group: AdminCustomerGroup
|
||||
}
|
||||
|
||||
export type AdminCustomerGroupListResponse = PaginatedResponse<{
|
||||
customer_groups: AdminCustomerGroup[]
|
||||
export type AdminCustomerListResponse = PaginatedResponse<{
|
||||
customers: AdminCustomer
|
||||
}>
|
||||
|
||||
export interface AdminCustomerAddressResponse {
|
||||
@@ -21,4 +15,4 @@ export interface AdminCustomerAddressResponse {
|
||||
|
||||
export type AdminCustomerAddressListResponse = PaginatedResponse<{
|
||||
addresses: AdminCustomerAddress[]
|
||||
}>
|
||||
}>
|
||||
|
||||
@@ -6,6 +6,7 @@ export * from "./collection"
|
||||
export * from "./common"
|
||||
export * from "./currency"
|
||||
export * from "./customer"
|
||||
export * from "./customer-group"
|
||||
export * from "./exchange"
|
||||
export * from "./file"
|
||||
export * from "./fulfillment"
|
||||
|
||||
@@ -1,2 +1,4 @@
|
||||
export * from "./entities"
|
||||
export * from "./payloads"
|
||||
export * from "./queries"
|
||||
export * from "./responses"
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
export interface AdminCreateReservation {
|
||||
line_item_id?: string | null
|
||||
location_id: string
|
||||
inventory_item_id: string
|
||||
quantity: number
|
||||
description?: string | null
|
||||
metadata?: Record<string, unknown> | null
|
||||
}
|
||||
|
||||
export interface AdminUpdateReservation {
|
||||
location_id?: string
|
||||
quantity?: number
|
||||
description?: string | null
|
||||
metadata?: Record<string, unknown> | null
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
import { OperatorMap } from "../../../dal"
|
||||
import { SelectParams } from "../../common"
|
||||
|
||||
export interface AdminGetReservationsParams {
|
||||
limit?: number
|
||||
offset?: number
|
||||
location_id?: string | string[]
|
||||
inventory_item_id?: string | string[]
|
||||
line_item_id?: string | string[]
|
||||
created_by?: string | string[]
|
||||
description?: string | OperatorMap<string>
|
||||
created_at?: OperatorMap<string>
|
||||
updated_at?: OperatorMap<string>
|
||||
deleted_at?: OperatorMap<string>
|
||||
}
|
||||
|
||||
export interface AdminReservationParams extends SelectParams {}
|
||||
Reference in New Issue
Block a user