feat(admin-next, inventory-next, medusa, types): Add admin reservations flow (#7080)
* add reservation endpoints * add changeset * initial * add reservations table * add edit-item modal * udpate inventory item attributes * manage locations skeleton * add combi batch endpoint * cleanup * fix manage locations * add adjust inventory * prep for pr * minor fixes to region domain and api (#7042) * initial reservation * init * update reservation * create reservation * polishing * minor fix * prep for pr * prep for pr * polishing * inventory items reservations * Update packages/admin-next/dashboard/src/v2-routes/reservations/reservation-list/components/reservation-list-table/reservation-list-table.tsx Co-authored-by: Frane Polić <16856471+fPolic@users.noreply.github.com> * fix feedback * rename to ispending --------- Co-authored-by: Kasper Fabricius Kristensen <45367945+kasperkristensen@users.noreply.github.com> Co-authored-by: Frane Polić <16856471+fPolic@users.noreply.github.com>
This commit is contained in:
@@ -14,6 +14,7 @@ import { productTypes } from "./product-types"
|
||||
import { products } from "./products"
|
||||
import { promotions } from "./promotions"
|
||||
import { regions } from "./regions"
|
||||
import { reservations } from "./reservations"
|
||||
import { salesChannels } from "./sales-channels"
|
||||
import { shippingOptions } from "./shipping-options"
|
||||
import { stockLocations } from "./stock-locations"
|
||||
@@ -45,6 +46,7 @@ export const client = {
|
||||
taxes: taxes,
|
||||
invites: invites,
|
||||
inventoryItems: inventoryItems,
|
||||
reservations: reservations,
|
||||
products: products,
|
||||
productTypes: productTypes,
|
||||
priceLists: priceLists,
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import {
|
||||
AdminInventoryItemListResponse,
|
||||
AdminInventoryItemResponse,
|
||||
AdminInventoryLevelListResponse,
|
||||
AdminInventoryLevelResponse,
|
||||
} from "@medusajs/types"
|
||||
import {
|
||||
@@ -12,9 +11,7 @@ import {
|
||||
} from "../../types/api-payloads"
|
||||
import {
|
||||
InventoryItemLevelDeleteRes,
|
||||
ReservationItemDeleteRes,
|
||||
ReservationItemListRes,
|
||||
ReservationItemRes,
|
||||
InventoryItemLocationLevelsRes,
|
||||
} from "../../types/api-responses"
|
||||
import { deleteRequest, getRequest, postRequest } from "./common"
|
||||
|
||||
@@ -59,7 +56,7 @@ async function listInventoryItemLevels(
|
||||
id: string,
|
||||
query?: Record<string, any>
|
||||
) {
|
||||
return getRequest<AdminInventoryLevelListResponse>(
|
||||
return getRequest<InventoryItemLocationLevelsRes>(
|
||||
`/admin/inventory-items/${id}/location-levels`,
|
||||
query
|
||||
)
|
||||
@@ -79,32 +76,12 @@ async function updateInventoryLevel(
|
||||
locationId: string,
|
||||
payload: UpdateInventoryLevelReq
|
||||
) {
|
||||
return postRequest<AdminInventoryLevelResponse>(
|
||||
return postRequest<AdminInventoryItemResponse>(
|
||||
`/admin/inventory-items/${inventoryItemId}/location-levels/${locationId}`,
|
||||
payload
|
||||
)
|
||||
}
|
||||
|
||||
async function listReservationItems(query?: Record<string, any>) {
|
||||
return getRequest<ReservationItemListRes>(`/admin/reservations`, query)
|
||||
}
|
||||
|
||||
async function deleteReservationItem(reservationId: string) {
|
||||
return deleteRequest<ReservationItemDeleteRes>(
|
||||
`/admin/reservations/${reservationId}`
|
||||
)
|
||||
}
|
||||
|
||||
async function updateReservationItem(
|
||||
reservationId: string,
|
||||
payload: UpdateInventoryItemReq
|
||||
) {
|
||||
return postRequest<ReservationItemRes>(
|
||||
`/admin/reservatinos/${reservationId}`,
|
||||
payload
|
||||
)
|
||||
}
|
||||
|
||||
async function batchPostLocationLevels(
|
||||
inventoryItemId: string,
|
||||
payload: InventoryItemLocationBatch
|
||||
@@ -127,8 +104,5 @@ export const inventoryItems = {
|
||||
listLocationLevels: listInventoryItemLevels,
|
||||
updateInventoryLevel,
|
||||
deleteInventoryItemLevel,
|
||||
listReservationItems,
|
||||
deleteReservationItem,
|
||||
updateReservationItem,
|
||||
batchPostLocationLevels,
|
||||
}
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
import {
|
||||
ReservationDeleteRes,
|
||||
ReservationListRes,
|
||||
ReservationRes,
|
||||
} from "../../types/api-responses"
|
||||
import { deleteRequest, getRequest, postRequest } from "./common"
|
||||
|
||||
import { InventoryNext } 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: InventoryNext.CreateReservationItemInput
|
||||
) {
|
||||
return postRequest<ReservationRes>(`/admin/reservations`, payload)
|
||||
}
|
||||
|
||||
async function updateReservation(
|
||||
id: string,
|
||||
payload: InventoryNext.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,
|
||||
}
|
||||
Reference in New Issue
Block a user