feat(dashboard): inventory create flow (#7650)

This commit is contained in:
Frane Polić
2024-06-10 17:37:36 +02:00
committed by GitHub
parent 69410162f6
commit f08f0d6cc9
37 changed files with 1010 additions and 271 deletions

View File

@@ -14,6 +14,7 @@ import { StockLocation } from "./stock-location"
import { TaxRate } from "./tax-rate"
import { TaxRegion } from "./tax-region"
import { Upload } from "./upload"
import { InventoryItem } from "./inventory-item"
export class Admin {
public invite: Invite
@@ -28,6 +29,7 @@ export class Admin {
public fulfillment: Fulfillment
public shippingOption: ShippingOption
public shippingProfile: ShippingProfile
public inventoryItem: InventoryItem
public order: Order
public taxRate: TaxRate
public taxRegion: TaxRegion
@@ -45,6 +47,7 @@ export class Admin {
this.fulfillment = new Fulfillment(client)
this.shippingOption = new ShippingOption(client)
this.shippingProfile = new ShippingProfile(client)
this.inventoryItem = new InventoryItem(client)
this.order = new Order(client)
this.taxRate = new TaxRate(client)
this.taxRegion = new TaxRegion(client)

View File

@@ -0,0 +1,135 @@
import { HttpTypes, SelectParams } from "@medusajs/types"
import { Client } from "../client"
import { ClientHeaders } from "../types"
export class InventoryItem {
private client: Client
constructor(client: Client) {
this.client = client
}
async create(
body: HttpTypes.AdminCreateInventoryItem,
query?: HttpTypes.SelectParams,
headers?: ClientHeaders
) {
return await this.client.fetch<HttpTypes.AdminInventoryItemResponse>(
`/admin/inventory-items`,
{
method: "POST",
headers,
body,
query,
}
)
}
async update(
id: string,
body: HttpTypes.AdminUpdateInventoryItem,
query?: SelectParams,
headers?: ClientHeaders
) {
return await this.client.fetch<HttpTypes.AdminInventoryItemResponse>(
`/admin/inventory-items/${id}`,
{
method: "POST",
headers,
body,
query,
}
)
}
async list(
query?: HttpTypes.AdminInventoryItemParams,
headers?: ClientHeaders
) {
return await this.client.fetch<HttpTypes.AdminInventoryItemListResponse>(
`/admin/inventory-items`,
{
query,
headers,
}
)
}
async retrieve(id: string, query?: SelectParams, headers?: ClientHeaders) {
return await this.client.fetch<HttpTypes.AdminInventoryItemResponse>(
`/admin/inventory-items/${id}`,
{
query,
headers,
}
)
}
async delete(id: string, headers?: ClientHeaders) {
return await this.client.fetch<HttpTypes.AdminInventoryItemDeleteResponse>(
`/admin/inventory-items/${id}`,
{
method: "DELETE",
headers,
}
)
}
async listLevels(
id: string,
query?: HttpTypes.AdminInventoryLevelFilters,
headers?: ClientHeaders
) {
return await this.client.fetch<HttpTypes.AdminInventoryLevelListResponse>(
`/admin/inventory-items/${id}/location-levels`,
{
query,
headers,
}
)
}
async updateLevel(
id: string,
locationId: string,
body: HttpTypes.AdminUpdateInventoryLevel,
query?: SelectParams,
headers?: ClientHeaders
) {
return await this.client.fetch<HttpTypes.AdminInventoryItemResponse>(
`/admin/inventory-items/${id}/location-levels/${locationId}`,
{
method: "POST",
headers,
body,
query,
}
)
}
async deleteLevel(id: string, locationId: string, headers?: ClientHeaders) {
return await this.client.fetch<HttpTypes.AdminInventoryItemDeleteResponse>(
`/admin/inventory-items/${id}/location-levels/${locationId}`,
{
method: "DELETE",
headers,
}
)
}
async batchUpdateLevels(
id: string,
body: HttpTypes.AdminBatchUpdateInventoryLevelLocation,
query?: SelectParams,
headers?: ClientHeaders
) {
return await this.client.fetch<HttpTypes.AdminInventoryItemResponse>(
`/admin/inventory-items/${id}/location-levels/batch`,
{
method: "POST",
headers,
body,
query,
}
)
}
}