Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(medusa): Reservation routes and VariantInventory type #3328

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/funny-cars-crash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@medusajs/medusa": patch
---

Register reservation endpoints + Fix a type issue for get variant inventory
2 changes: 2 additions & 0 deletions packages/medusa/src/api/routes/admin/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import productTypesRoutes from "./product-types"
import publishableApiKeyRoutes from "./publishable-api-keys"
import productRoutes from "./products"
import regionRoutes from "./regions"
import reservationRoutes from "./reservations"
import returnReasonRoutes from "./return-reasons"
import returnRoutes from "./returns"
import salesChannelRoutes from "./sales-channels"
Expand Down Expand Up @@ -97,6 +98,7 @@ export default (app, container, config) => {
productTypesRoutes(route)
publishableApiKeyRoutes(route)
regionRoutes(route, featureFlagRouter)
reservationRoutes(route)
returnReasonRoutes(route)
returnRoutes(route)
salesChannelRoutes(route)
Expand Down
18 changes: 15 additions & 3 deletions packages/medusa/src/api/routes/admin/variants/get-inventory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export default async (req, res) => {

const variant = await variantService.retrieve(id, { select: ["id"] })

const responseVariant: AdminGetVariantsVariantInventoryRes = {
const responseVariant: VariantInventory = {
id: variant.id,
inventory: [],
sales_channel_availability: [],
Expand Down Expand Up @@ -150,7 +150,7 @@ type ResponseInventoryItem = Partial<InventoryItemDTO> & {
}

/**
* @schema AdminGetVariantsVariantInventoryRes
* @schema VariantInventory
* type: object
* properties:
* id:
Expand All @@ -173,7 +173,7 @@ type ResponseInventoryItem = Partial<InventoryItemDTO> & {
* description: Available quantity in sales channel
* type: number
*/
export type AdminGetVariantsVariantInventoryRes = {
export type VariantInventory = {
id: string
inventory: ResponseInventoryItem[]
sales_channel_availability: {
Expand All @@ -182,3 +182,15 @@ export type AdminGetVariantsVariantInventoryRes = {
available_quantity: number
}[]
}

/**
* @schema AdminGetVariantsVariantInventoryRes
* type: object
* properties:
* variant:
* type: object
* $ref: "#/components/schemas/VariantInventory"
*/
export type AdminGetVariantsVariantInventoryRes = {
variant: VariantInventory
}