feat(dashboard): manage inventory items for variants (#7800)
* feat: manage inventory items for variants * fix: show action only when manage inventory * fix: translation key * fix: labels depending on number of items * fix: address feedback --------- Co-authored-by: Sebastian Rindom <skrindom@gmail.com>
This commit is contained in:
1 parent
4945c79818
commit
8703f453be
13 files changed
+467
-18
No files matched your search
@@ -1,4 +1,9 @@
|
||||
import { HttpTypes, SelectParams } from "@medusajs/types"
|
||||
import {
|
||||
AdminBatchProductVariantInventoryItemRequest,
|
||||
AdminBatchProductVariantInventoryItemResponse,
|
||||
HttpTypes,
|
||||
SelectParams,
|
||||
} from "@medusajs/types"
|
||||
import { Client } from "../client"
|
||||
import { ClientHeaders } from "../types"
|
||||
|
||||
@@ -101,6 +106,7 @@ export class Product {
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
async createVariant(
|
||||
productId: string,
|
||||
body: HttpTypes.AdminCreateProductVariant,
|
||||
@@ -117,6 +123,7 @@ export class Product {
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
async updateVariant(
|
||||
productId: string,
|
||||
id: string,
|
||||
@@ -134,6 +141,7 @@ export class Product {
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
async listVariants(
|
||||
productId: string,
|
||||
queryParams?: HttpTypes.AdminProductVariantParams,
|
||||
@@ -147,6 +155,7 @@ export class Product {
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
async retrieveVariant(
|
||||
productId: string,
|
||||
id: string,
|
||||
@@ -161,6 +170,7 @@ export class Product {
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
async deleteVariant(productId: string, id: string, headers?: ClientHeaders) {
|
||||
return await this.client.fetch<HttpTypes.AdminProductVariantDeleteResponse>(
|
||||
`/admin/products/${productId}/variants/${id}`,
|
||||
@@ -170,6 +180,24 @@ export class Product {
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
async batchVariantInventoryItems(
|
||||
productId: string,
|
||||
body: HttpTypes.AdminBatchProductVariantInventoryItemRequest,
|
||||
query?: SelectParams,
|
||||
headers?: ClientHeaders
|
||||
) {
|
||||
return await this.client.fetch<HttpTypes.AdminBatchProductVariantInventoryItemResponse>(
|
||||
`/admin/products/${productId}/variants/inventory-items/batch`,
|
||||
{
|
||||
method: "POST",
|
||||
headers,
|
||||
body,
|
||||
query,
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
async createOption(
|
||||
productId: string,
|
||||
body: HttpTypes.AdminCreateProductOption,
|
||||
@@ -186,6 +214,7 @@ export class Product {
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
async updateOption(
|
||||
productId: string,
|
||||
id: string,
|
||||
@@ -203,6 +232,7 @@ export class Product {
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
async listOptions(
|
||||
productId: string,
|
||||
queryParams?: HttpTypes.AdminProductOptionParams,
|
||||
@@ -216,6 +246,7 @@ export class Product {
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
async retrieveOption(
|
||||
productId: string,
|
||||
id: string,
|
||||
@@ -230,6 +261,7 @@ export class Product {
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
async deleteOption(productId: string, id: string, headers?: ClientHeaders) {
|
||||
return await this.client.fetch<HttpTypes.AdminProductOptionDeleteResponse>(
|
||||
`/admin/products/${productId}/options/${id}`,
|
||||
|
||||
@@ -3,12 +3,20 @@ import { ProductStatus } from "../common"
|
||||
|
||||
export interface AdminBatchProductRequest
|
||||
extends BatchMethodRequest<AdminCreateProduct, AdminUpdateProduct> {}
|
||||
|
||||
export interface AdminBatchProductVariantRequest
|
||||
extends BatchMethodRequest<
|
||||
AdminCreateProductVariant,
|
||||
AdminUpdateProductVariant
|
||||
> {}
|
||||
|
||||
export interface AdminBatchProductVariantInventoryItemRequest
|
||||
extends BatchMethodRequest<
|
||||
AdminCreateProductVariantInventoryItem,
|
||||
AdminUpdateProductVariantInventoryItem,
|
||||
AdminDeleteProductVariantInventoryItem
|
||||
> {}
|
||||
|
||||
export interface AdminCreateProductVariantPrice {
|
||||
currency_code: string
|
||||
amount: number
|
||||
@@ -125,3 +133,20 @@ export interface AdminUpdateProductOption {
|
||||
title?: string
|
||||
values?: string[]
|
||||
}
|
||||
|
||||
interface AdminCreateProductVariantInventoryItem {
|
||||
required_quantity: number
|
||||
inventory_item_id: string
|
||||
variant_id: string
|
||||
}
|
||||
|
||||
interface AdminUpdateProductVariantInventoryItem {
|
||||
required_quantity: number
|
||||
inventory_item_id: string
|
||||
variant_id: string
|
||||
}
|
||||
|
||||
interface AdminDeleteProductVariantInventoryItem {
|
||||
inventory_item_id: string
|
||||
variant_id: string
|
||||
}
|
||||
@@ -5,6 +5,7 @@ import {
|
||||
AdminProductOption,
|
||||
AdminProductVariant,
|
||||
} from "./entitites"
|
||||
import { AdminInventoryItem } from "../../inventory"
|
||||
|
||||
export interface AdminProductResponse {
|
||||
product: AdminProduct
|
||||
@@ -33,6 +34,9 @@ export interface AdminProductVariantDeleteResponse
|
||||
export interface AdminBatchProductVariantResponse
|
||||
extends BatchMethodResponse<AdminProductVariant> {}
|
||||
|
||||
export interface AdminBatchProductVariantInventoryItemResponse
|
||||
extends BatchMethodResponse<AdminInventoryItem> {}
|
||||
|
||||
export interface AdminProductOptionResponse {
|
||||
product_option: AdminProductOption
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user