chore: price list prices of a product can be deleted (#7700)

This commit is contained in:
Riqwan Thamir authored and GitHub committed 2024-06-13 12:19:09 +02:00
1 parent c1db40b564
commit c57223a3a2
11 files changed
+132 -20

No files matched your search

+4 -1
View File
@@ -2,8 +2,10 @@ import { Client } from "../client"
import { Customer } from "./customer"
import { Fulfillment } from "./fulfillment"
import { FulfillmentSet } from "./fulfillment-set"
import { InventoryItem } from "./inventory-item"
import { Invite } from "./invite"
import { Order } from "./order"
import { PriceList } from "./price-list"
import { Product } from "./product"
import { ProductCategory } from "./product-category"
import { ProductCollection } from "./product-collection"
@@ -15,13 +17,13 @@ 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
public customer: Customer
public productCollection: ProductCollection
public productCategory: ProductCategory
public priceList: PriceList
public product: Product
public upload: Upload
public region: Region
@@ -41,6 +43,7 @@ export class Admin {
this.customer = new Customer(client)
this.productCollection = new ProductCollection(client)
this.productCategory = new ProductCategory(client)
this.priceList = new PriceList(client)
this.product = new Product(client)
this.upload = new Upload(client)
this.region = new Region(client)
@@ -0,0 +1,28 @@
import { HttpTypes } from "@medusajs/types"
import { Client } from "../client"
import { ClientHeaders } from "../types"
export class PriceList {
private client: Client
constructor(client: Client) {
this.client = client
}
async linkProducts(
id: string,
body: HttpTypes.AdminLinkPriceListProducts,
query?: HttpTypes.AdminPriceListParams,
headers?: ClientHeaders
) {
return this.client.fetch<HttpTypes.AdminPriceListResponse>(
`/admin/price-lists/${id}/products`,
{
method: "POST",
headers,
body,
query,
}
)
}
}
-1
View File
@@ -26,4 +26,3 @@ export * from "./stock-locations"
export * from "./tax-rate"
export * from "./tax-region"
export * from "./user"
@@ -1,3 +1,5 @@
import { PriceListStatus, PriceListType } from "../../../pricing"
/**
* TODO: Not sure how to type this properly, as it's unclear to me what is returned
* by our API. As an example we return `price_list: null` but `price_list_id` is missing.
@@ -29,3 +31,17 @@ export interface AdminPrice {
updated_at: string
deleted_at: string | null
}
export interface AdminPriceList {
id: string
title: string
description: string
rules: Record<string, any>
starts_at: string | null
ends_at: string | null
status: PriceListStatus
type: PriceListType
prices: AdminPrice[]
created_at: string
updated_at: string
}
@@ -1 +1,4 @@
export * from "./entitites"
export * from "./entities"
export * from "./payloads"
export * from "./queries"
export * from "./responses"
@@ -0,0 +1,3 @@
export interface AdminLinkPriceListProducts {
remove?: string[]
}
@@ -0,0 +1,3 @@
import { SelectParams } from "../../common"
export interface AdminPriceListParams extends SelectParams {}
@@ -0,0 +1,5 @@
import { AdminPriceList } from "./entities"
export interface AdminPriceListResponse {
price_list: AdminPriceList
}