feat(dashboard,types,js-sdk,ui): Tax Regions UI (#7935)
This commit is contained in:
@@ -47,7 +47,7 @@ export class Customer {
|
||||
}
|
||||
|
||||
async list(
|
||||
queryParams?: FindParams & HttpTypes.AdminCollectionFilters,
|
||||
queryParams?: FindParams & HttpTypes.AdminCustomerFilters,
|
||||
headers?: ClientHeaders
|
||||
) {
|
||||
return this.client.fetch<
|
||||
|
||||
@@ -11,6 +11,7 @@ import { PricePreference } from "./price-preference"
|
||||
import { Product } from "./product"
|
||||
import { ProductCategory } from "./product-category"
|
||||
import { ProductCollection } from "./product-collection"
|
||||
import { ProductTag } from "./product-tag"
|
||||
import { ProductType } from "./product-type"
|
||||
import { Region } from "./region"
|
||||
import { SalesChannel } from "./sales-channel"
|
||||
@@ -45,6 +46,7 @@ export class Admin {
|
||||
public taxRate: TaxRate
|
||||
public taxRegion: TaxRegion
|
||||
public store: Store
|
||||
public productTag: ProductTag
|
||||
|
||||
constructor(client: Client) {
|
||||
this.invite = new Invite(client)
|
||||
@@ -69,5 +71,6 @@ export class Admin {
|
||||
this.taxRate = new TaxRate(client)
|
||||
this.taxRegion = new TaxRegion(client)
|
||||
this.store = new Store(client)
|
||||
this.productTag = new ProductTag(client)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,4 @@
|
||||
import {
|
||||
DeleteResponse,
|
||||
FindParams,
|
||||
HttpTypes,
|
||||
PaginatedResponse,
|
||||
SelectParams,
|
||||
} from "@medusajs/types"
|
||||
import { HttpTypes } from "@medusajs/types"
|
||||
import { Client } from "../client"
|
||||
import { ClientHeaders } from "../types"
|
||||
|
||||
@@ -16,10 +10,10 @@ export class ProductCollection {
|
||||
|
||||
async create(
|
||||
body: HttpTypes.AdminCreateCollection,
|
||||
query?: SelectParams,
|
||||
query?: HttpTypes.AdminCollectionParams,
|
||||
headers?: ClientHeaders
|
||||
) {
|
||||
return this.client.fetch<{ collection: HttpTypes.AdminCollection }>(
|
||||
return this.client.fetch<HttpTypes.AdminCollectionResponse>(
|
||||
`/admin/collections`,
|
||||
{
|
||||
method: "POST",
|
||||
@@ -32,10 +26,10 @@ export class ProductCollection {
|
||||
async update(
|
||||
id: string,
|
||||
body: HttpTypes.AdminUpdateCollection,
|
||||
query?: SelectParams,
|
||||
query?: HttpTypes.AdminCollectionParams,
|
||||
headers?: ClientHeaders
|
||||
) {
|
||||
return this.client.fetch<{ collection: HttpTypes.AdminCollection }>(
|
||||
return this.client.fetch<HttpTypes.AdminCollectionResponse>(
|
||||
`/admin/collections/${id}`,
|
||||
{
|
||||
method: "POST",
|
||||
@@ -46,17 +40,25 @@ export class ProductCollection {
|
||||
)
|
||||
}
|
||||
|
||||
async list(queryParams?: FindParams, headers?: ClientHeaders) {
|
||||
return this.client.fetch<
|
||||
PaginatedResponse<{ collections: HttpTypes.AdminCollection[] }>
|
||||
>(`/admin/collections`, {
|
||||
headers,
|
||||
query: queryParams,
|
||||
})
|
||||
async list(
|
||||
queryParams?: HttpTypes.AdminCollectionListParams,
|
||||
headers?: ClientHeaders
|
||||
) {
|
||||
return this.client.fetch<HttpTypes.AdminCollectionListResponse>(
|
||||
`/admin/collections`,
|
||||
{
|
||||
headers,
|
||||
query: queryParams,
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
async retrieve(id: string, query?: SelectParams, headers?: ClientHeaders) {
|
||||
return this.client.fetch<{ collection: HttpTypes.AdminCollection }>(
|
||||
async retrieve(
|
||||
id: string,
|
||||
query?: HttpTypes.AdminCollectionParams,
|
||||
headers?: ClientHeaders
|
||||
) {
|
||||
return this.client.fetch<HttpTypes.AdminCollectionResponse>(
|
||||
`/admin/collections/${id}`,
|
||||
{
|
||||
query,
|
||||
@@ -66,7 +68,7 @@ export class ProductCollection {
|
||||
}
|
||||
|
||||
async delete(id: string, headers?: ClientHeaders) {
|
||||
return this.client.fetch<DeleteResponse<"collection">>(
|
||||
return this.client.fetch<HttpTypes.AdminCollectionDeleteResponse>(
|
||||
`/admin/collections/${id}`,
|
||||
{
|
||||
method: "DELETE",
|
||||
@@ -80,7 +82,7 @@ export class ProductCollection {
|
||||
body: HttpTypes.AdminUpdateCollectionProducts,
|
||||
headers?: ClientHeaders
|
||||
) {
|
||||
return this.client.fetch<{ collection: HttpTypes.AdminCollection }>(
|
||||
return this.client.fetch<HttpTypes.AdminCollectionResponse>(
|
||||
`/admin/collections/${id}/products`,
|
||||
{
|
||||
method: "POST",
|
||||
|
||||
@@ -0,0 +1,80 @@
|
||||
import { HttpTypes } from "@medusajs/types"
|
||||
import { Client } from "../client"
|
||||
import { ClientHeaders } from "../types"
|
||||
|
||||
export class ProductTag {
|
||||
private client: Client
|
||||
constructor(client: Client) {
|
||||
this.client = client
|
||||
}
|
||||
|
||||
async create(
|
||||
body: HttpTypes.AdminCreateProductTag,
|
||||
query?: HttpTypes.AdminProductTagParams,
|
||||
headers?: ClientHeaders
|
||||
) {
|
||||
return this.client.fetch<HttpTypes.AdminProductTagResponse>(
|
||||
`/admin/product-tags`,
|
||||
{
|
||||
method: "POST",
|
||||
headers,
|
||||
body,
|
||||
query,
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
async update(
|
||||
id: string,
|
||||
body: HttpTypes.AdminUpdateProductTag,
|
||||
query?: HttpTypes.AdminProductTagParams,
|
||||
headers?: ClientHeaders
|
||||
) {
|
||||
return this.client.fetch<HttpTypes.AdminProductTagResponse>(
|
||||
`/admin/product-tags/${id}`,
|
||||
{
|
||||
method: "POST",
|
||||
headers,
|
||||
body,
|
||||
query,
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
async list(
|
||||
query?: HttpTypes.AdminProductTagListParams,
|
||||
headers?: ClientHeaders
|
||||
) {
|
||||
return this.client.fetch<HttpTypes.AdminProductTagListResponse>(
|
||||
`/admin/product-tags`,
|
||||
{
|
||||
headers,
|
||||
query: query,
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
async retrieve(
|
||||
id: string,
|
||||
query?: HttpTypes.AdminProductTagParams,
|
||||
headers?: ClientHeaders
|
||||
) {
|
||||
return this.client.fetch<HttpTypes.AdminProductTagResponse>(
|
||||
`/admin/product-tags/${id}`,
|
||||
{
|
||||
query,
|
||||
headers,
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
async delete(id: string, headers?: ClientHeaders) {
|
||||
return this.client.fetch<HttpTypes.AdminProductTagDeleteResponse>(
|
||||
`/admin/product-tags/${id}`,
|
||||
{
|
||||
method: "DELETE",
|
||||
headers,
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
import { BaseCollection, BaseCollectionFilters } from "./common"
|
||||
|
||||
export interface AdminCollection extends BaseCollection {}
|
||||
export interface AdminCollectionFilters extends BaseCollectionFilters {}
|
||||
|
||||
export interface AdminCreateCollection {
|
||||
title: string
|
||||
handle?: string
|
||||
metadata?: Record<string, any>
|
||||
}
|
||||
export interface AdminUpdateCollection extends Partial<AdminCreateCollection> {}
|
||||
|
||||
export interface AdminUpdateCollectionProducts {
|
||||
add?: string[]
|
||||
remove?: string[]
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
import { BaseCollection } from "../common"
|
||||
|
||||
export interface AdminCollection extends BaseCollection {}
|
||||
@@ -0,0 +1,4 @@
|
||||
export * from "./entities"
|
||||
export * from "./payloads"
|
||||
export * from "./queries"
|
||||
export * from "./responses"
|
||||
@@ -0,0 +1,16 @@
|
||||
export interface AdminCreateCollection {
|
||||
title: string
|
||||
handle?: string
|
||||
metadata?: Record<string, any>
|
||||
}
|
||||
|
||||
export interface AdminUpdateCollection {
|
||||
title?: string
|
||||
handle?: string
|
||||
metadata?: Record<string, any>
|
||||
}
|
||||
|
||||
export interface AdminUpdateCollectionProducts {
|
||||
add?: string[]
|
||||
remove?: string[]
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
import { OperatorMap } from "../../../dal"
|
||||
import { BaseCollectionListParams, BaseCollectionParams } from "../common"
|
||||
|
||||
export interface AdminCollectionListParams extends BaseCollectionListParams {
|
||||
deleted_at?: OperatorMap<string>
|
||||
}
|
||||
export interface AdminCollectionParams extends BaseCollectionParams {}
|
||||
@@ -0,0 +1,14 @@
|
||||
import { DeleteResponse, PaginatedResponse } from "../../common"
|
||||
import { AdminCollection } from "./entities"
|
||||
|
||||
export interface AdminCollectionResponse {
|
||||
collection: AdminCollection
|
||||
}
|
||||
|
||||
export interface AdminCollectionListResponse
|
||||
extends PaginatedResponse<{
|
||||
collections: AdminCollection[]
|
||||
}> {}
|
||||
|
||||
export interface AdminCollectionDeleteResponse
|
||||
extends DeleteResponse<"collection"> {}
|
||||
@@ -1,24 +1,27 @@
|
||||
import { BaseFilterable, OperatorMap } from "../../dal"
|
||||
import { FindParams, SelectParams } from "../common"
|
||||
import { AdminProduct } from "../product"
|
||||
|
||||
export interface BaseCollection {
|
||||
id?: string
|
||||
title?: string
|
||||
handle?: string
|
||||
created_at?: string
|
||||
updated_at?: string
|
||||
deleted_at?: string | null
|
||||
id: string
|
||||
title: string
|
||||
handle: string
|
||||
created_at: string
|
||||
updated_at: string
|
||||
deleted_at: string | null
|
||||
products?: AdminProduct[]
|
||||
metadata?: Record<string, unknown> | null
|
||||
metadata: Record<string, unknown> | null
|
||||
}
|
||||
|
||||
export interface BaseCollectionFilters
|
||||
extends BaseFilterable<BaseCollectionFilters> {
|
||||
export interface BaseCollectionParams extends SelectParams {}
|
||||
|
||||
export interface BaseCollectionListParams
|
||||
extends FindParams,
|
||||
BaseFilterable<BaseCollectionListParams> {
|
||||
q?: string
|
||||
id?: string | string[]
|
||||
handle?: string | string[]
|
||||
title?: string | string[]
|
||||
created_at?: OperatorMap<string>
|
||||
updated_at?: OperatorMap<string>
|
||||
deleted_at?: OperatorMap<string>
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { BaseCollection, BaseCollectionFilters } from "./common"
|
||||
import { BaseCollection, BaseCollectionListParams } from "./common"
|
||||
|
||||
export interface StoreCollection extends BaseCollection {}
|
||||
export interface StoreCollectionFilters extends BaseCollectionFilters {}
|
||||
export interface StoreCollectionFilters extends BaseCollectionListParams {}
|
||||
|
||||
@@ -18,6 +18,7 @@ export * from "./price-list"
|
||||
export * from "./pricing"
|
||||
export * from "./product"
|
||||
export * from "./product-category"
|
||||
export * from "./product-tag"
|
||||
export * from "./product-type"
|
||||
export * from "./promotion"
|
||||
export * from "./region"
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
import { BaseProductTag } from "../common"
|
||||
|
||||
export interface AdminProductTag extends BaseProductTag {}
|
||||
@@ -0,0 +1,4 @@
|
||||
export * from "./entities"
|
||||
export * from "./payloads"
|
||||
export * from "./queries"
|
||||
export * from "./responses"
|
||||
@@ -0,0 +1,9 @@
|
||||
export interface AdminCreateProductTag {
|
||||
value: string
|
||||
metadata?: Record<string, unknown> | null
|
||||
}
|
||||
|
||||
export interface AdminUpdateProductTag {
|
||||
value?: string
|
||||
metadata?: Record<string, unknown> | null
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
import { BaseFilterable, OperatorMap } from "../../../dal"
|
||||
import { SelectParams } from "../../common"
|
||||
import { BaseProductTagListParams } from "../common"
|
||||
|
||||
export interface AdminProductTagListParams
|
||||
extends BaseProductTagListParams,
|
||||
BaseFilterable<AdminProductTagListParams> {
|
||||
deleted_at?: OperatorMap<string>
|
||||
}
|
||||
|
||||
export interface AdminProductTagParams extends SelectParams {}
|
||||
@@ -0,0 +1,14 @@
|
||||
import { DeleteResponse, PaginatedResponse } from "../../common"
|
||||
import { AdminProductTag } from "./entities"
|
||||
|
||||
export interface AdminProductTagResponse {
|
||||
product_tag: AdminProductTag
|
||||
}
|
||||
|
||||
export interface AdminProductTagListResponse
|
||||
extends PaginatedResponse<{
|
||||
product_tags: AdminProductTag[]
|
||||
}> {}
|
||||
|
||||
export interface AdminProductTagDeleteResponse
|
||||
extends DeleteResponse<"product_tag"> {}
|
||||
@@ -0,0 +1,19 @@
|
||||
import { OperatorMap } from "../../dal"
|
||||
import { FindParams } from "../common"
|
||||
|
||||
export interface BaseProductTag {
|
||||
id: string
|
||||
value: string
|
||||
created_at: string
|
||||
updated_at: string
|
||||
deleted_at?: string | null
|
||||
metadata?: Record<string, unknown> | null
|
||||
}
|
||||
|
||||
export interface BaseProductTagListParams extends FindParams {
|
||||
q?: string
|
||||
id?: string | string[]
|
||||
value?: string | string[]
|
||||
created_at?: OperatorMap<string>
|
||||
updated_at?: OperatorMap<string>
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
export * from "./admin"
|
||||
export * from "./store"
|
||||
@@ -0,0 +1,3 @@
|
||||
import { BaseProductTag } from "../common"
|
||||
|
||||
export interface StoreProductTag extends BaseProductTag {}
|
||||
@@ -0,0 +1,2 @@
|
||||
export * from "./entities"
|
||||
export * from "./queries"
|
||||
@@ -0,0 +1,9 @@
|
||||
import { BaseFilterable } from "../../../dal"
|
||||
import { SelectParams } from "../../common"
|
||||
import { BaseProductTagListParams } from "../common"
|
||||
|
||||
export interface StoreProductTagListParams
|
||||
extends BaseProductTagListParams,
|
||||
BaseFilterable<StoreProductTagListParams> {}
|
||||
|
||||
export interface StoreProductTagParams extends SelectParams {}
|
||||
@@ -1,8 +1,8 @@
|
||||
export interface BaseProductType {
|
||||
id: string
|
||||
value: string
|
||||
created_at?: string
|
||||
updated_at?: string
|
||||
created_at: string
|
||||
updated_at: string
|
||||
deleted_at?: string | null
|
||||
metadata?: Record<string, unknown> | null
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { AdminCollection } from "../../collection"
|
||||
import { AdminPrice } from "../../pricing"
|
||||
import { AdminProductCategory } from "../../product-category"
|
||||
import { AdminProductTag } from "../../product-tag"
|
||||
import { AdminProductType } from "../../product-type"
|
||||
import { AdminSalesChannel } from "../../sales-channel"
|
||||
import {
|
||||
@@ -8,7 +9,6 @@ import {
|
||||
BaseProductImage,
|
||||
BaseProductOption,
|
||||
BaseProductOptionValue,
|
||||
BaseProductTag,
|
||||
BaseProductVariant,
|
||||
ProductStatus,
|
||||
} from "../common"
|
||||
@@ -16,7 +16,6 @@ import {
|
||||
export interface AdminProductVariant extends BaseProductVariant {
|
||||
prices: AdminPrice[] | null
|
||||
}
|
||||
export interface AdminProductTag extends BaseProductTag {}
|
||||
export interface AdminProductOption extends BaseProductOption {}
|
||||
export interface AdminProductImage extends BaseProductImage {}
|
||||
export interface AdminProductOptionValue extends BaseProductOptionValue {}
|
||||
@@ -27,5 +26,6 @@ export interface AdminProduct
|
||||
sales_channels?: AdminSalesChannel[] | null
|
||||
variants?: AdminProductVariant[] | null
|
||||
type: AdminProductType | null
|
||||
tags?: AdminProductTag[] | null
|
||||
}
|
||||
export type AdminProductStatus = ProductStatus
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
import {
|
||||
BaseProductListParams,
|
||||
BaseProductOptionParams,
|
||||
BaseProductTagParams,
|
||||
BaseProductVariantParams,
|
||||
} from "../common"
|
||||
|
||||
export interface AdminProductTagParams extends BaseProductTagParams {}
|
||||
export interface AdminProductOptionParams extends BaseProductOptionParams {}
|
||||
export interface AdminProductVariantParams extends BaseProductVariantParams {}
|
||||
export interface AdminProductListParams extends BaseProductListParams {
|
||||
|
||||
@@ -3,6 +3,7 @@ import { BaseCollection } from "../collection/common"
|
||||
import { FindParams } from "../common"
|
||||
import { BaseCalculatedPriceSet } from "../pricing/common"
|
||||
import { BaseProductCategory } from "../product-category/common"
|
||||
import { BaseProductTag } from "../product-tag/common"
|
||||
import { BaseProductType } from "../product-type/common"
|
||||
|
||||
export type ProductStatus = "draft" | "proposed" | "published" | "rejected"
|
||||
@@ -28,7 +29,7 @@ export interface BaseProduct {
|
||||
categories?: BaseProductCategory[] | null
|
||||
type?: BaseProductType | null
|
||||
type_id: string | null
|
||||
tags: BaseProductTag[] | null
|
||||
tags?: BaseProductTag[] | null
|
||||
variants: BaseProductVariant[] | null
|
||||
options: BaseProductOption[] | null
|
||||
images: BaseProductImage[] | null
|
||||
@@ -68,13 +69,6 @@ export interface BaseProductVariant {
|
||||
metadata?: Record<string, unknown> | null
|
||||
}
|
||||
|
||||
export interface BaseProductTag {
|
||||
id: string
|
||||
value: string
|
||||
products?: BaseProduct[]
|
||||
metadata?: Record<string, unknown> | null
|
||||
}
|
||||
|
||||
export interface BaseProductOption {
|
||||
id: string
|
||||
title: string
|
||||
@@ -129,14 +123,6 @@ export interface BaseProductListParams
|
||||
deleted_at?: OperatorMap<string>
|
||||
}
|
||||
|
||||
export interface BaseProductTagParams
|
||||
extends FindParams,
|
||||
BaseFilterable<BaseProductTagParams> {
|
||||
q?: string
|
||||
id?: string | string[]
|
||||
value?: string | string[]
|
||||
}
|
||||
|
||||
export interface BaseProductOptionParams
|
||||
extends FindParams,
|
||||
BaseFilterable<BaseProductOptionParams> {
|
||||
|
||||
@@ -5,7 +5,6 @@ import {
|
||||
BaseProductImage,
|
||||
BaseProductOption,
|
||||
BaseProductOptionValue,
|
||||
BaseProductTag,
|
||||
BaseProductVariant,
|
||||
ProductStatus,
|
||||
} from "../common"
|
||||
@@ -15,7 +14,6 @@ export interface StoreProduct extends Omit<BaseProduct, "categories"> {
|
||||
type?: StoreProductType | null
|
||||
}
|
||||
export interface StoreProductVariant extends BaseProductVariant {}
|
||||
export interface StoreProductTag extends BaseProductTag {}
|
||||
export interface StoreProductOption extends BaseProductOption {}
|
||||
export interface StoreProductImage extends BaseProductImage {}
|
||||
export interface StoreProductOptionValue extends BaseProductOptionValue {}
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
import {
|
||||
BaseProductListParams,
|
||||
BaseProductOptionParams,
|
||||
BaseProductTagParams,
|
||||
BaseProductVariantParams,
|
||||
} from "../common"
|
||||
|
||||
export interface StoreProductTagParams extends BaseProductTagParams {}
|
||||
export interface StoreProductOptionParams extends BaseProductOptionParams {}
|
||||
export interface StoreProductVariantParams extends BaseProductVariantParams {}
|
||||
export interface StoreProductParams extends BaseProductListParams {
|
||||
|
||||
@@ -17,7 +17,7 @@ export interface AdminCreateTaxRate {
|
||||
export interface AdminUpdateTaxRate {
|
||||
name?: string
|
||||
rate?: number
|
||||
code?: string
|
||||
code?: string | null
|
||||
rules?: AdminCreateTaxRateRule[]
|
||||
is_default?: boolean
|
||||
is_combinable?: boolean
|
||||
|
||||
@@ -17,5 +17,6 @@ export interface AdminTaxRegion {
|
||||
deleted_at: string | null
|
||||
created_by: string | null
|
||||
tax_rates: AdminTaxRate[]
|
||||
parent: AdminTaxRegion
|
||||
parent: AdminTaxRegion | null
|
||||
children: AdminTaxRegion[]
|
||||
}
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
import { OperatorMap } from "../../../dal"
|
||||
import { FindParams } from "../../common"
|
||||
import { BaseFilterable, OperatorMap } from "../../../dal"
|
||||
import { FindParams, SelectParams } from "../../common"
|
||||
|
||||
export interface AdminTaxRegionListParams extends FindParams {
|
||||
export interface AdminTaxRegionListParams
|
||||
extends FindParams,
|
||||
BaseFilterable<AdminTaxRegionListParams> {
|
||||
id?: string | string[]
|
||||
q?: string
|
||||
parent_id?: string | string[] | OperatorMap<string | string[]>
|
||||
@@ -12,3 +14,5 @@ export interface AdminTaxRegionListParams extends FindParams {
|
||||
deleted_at?: string | OperatorMap<string>
|
||||
created_by?: string | OperatorMap<string>
|
||||
}
|
||||
|
||||
export interface AdminTaxRegionParams extends SelectParams {}
|
||||
|
||||
Reference in New Issue
Block a user