feat(dashboard,types,js-sdk,ui): Add missing Price List features (#7856)

**What**
- Adds missing features to Price List domain
- Adds `StackedFocusModal` and `StackedDrawer` components that should replace SplitView across the project.
- Add Footer to FocusModal
- Adds missing js-sdk functions and types

**Note**
The DatePickers in the PriceLists forms do not work as intended atm. The component is broken, and needs to be fixed. I am working on a fix, but choose to move that work into a separate branch, to prevent this PR from getting bigger then it already is. Will update once the fixes have been merged.
This commit is contained in:
Kasper Fabricius Kristensen authored and GitHub committed 2024-06-28 14:08:23 +00:00
1 parent 9f3998393b
commit c1740218e9
295 files changed
+4488 -2350

No files matched your search

+3
View File
@@ -16,6 +16,7 @@ import { SalesChannel } from "./sales-channel"
import { ShippingOption } from "./shipping-option"
import { ShippingProfile } from "./shipping-profile"
import { StockLocation } from "./stock-location"
import { Store } from "./store"
import { TaxRate } from "./tax-rate"
import { TaxRegion } from "./tax-region"
import { Upload } from "./upload"
@@ -41,6 +42,7 @@ export class Admin {
public order: Order
public taxRate: TaxRate
public taxRegion: TaxRegion
public store: Store
constructor(client: Client) {
this.invite = new Invite(client)
@@ -63,5 +65,6 @@ export class Admin {
this.order = new Order(client)
this.taxRate = new TaxRate(client)
this.taxRegion = new TaxRegion(client)
this.store = new Store(client)
}
}
@@ -9,6 +9,95 @@ export class PriceList {
this.client = client
}
async retrieve(
id: string,
query?: HttpTypes.AdminPriceListParams,
headers?: ClientHeaders
) {
return this.client.fetch<HttpTypes.AdminPriceListResponse>(
`/admin/price-lists/${id}`,
{
method: "GET",
headers,
query,
}
)
}
async list(
query?: HttpTypes.AdminPriceListListParams,
headers?: ClientHeaders
) {
return this.client.fetch<HttpTypes.AdminPriceListListResponse>(
`/admin/price-lists`,
{
method: "GET",
headers,
query,
}
)
}
async create(
body: HttpTypes.AdminCreatePriceList,
query?: HttpTypes.AdminPriceListParams,
headers?: ClientHeaders
) {
return this.client.fetch<HttpTypes.AdminPriceListResponse>(
`/admin/price-lists`,
{
method: "POST",
headers,
body,
query,
}
)
}
async update(
id: string,
body: HttpTypes.AdminUpdatePriceList,
query?: HttpTypes.AdminPriceListParams,
headers?: ClientHeaders
) {
return this.client.fetch<HttpTypes.AdminPriceListResponse>(
`/admin/price-lists/${id}`,
{
method: "POST",
headers,
body,
query,
}
)
}
async delete(id: string, headers?: ClientHeaders) {
return this.client.fetch<HttpTypes.AdminPriceListDeleteResponse>(
`/admin/price-lists/${id}`,
{
method: "DELETE",
headers,
}
)
}
async batchPrices(
id: string,
body: HttpTypes.AdminBatchPriceListPrice,
query?: HttpTypes.AdminPriceListParams,
headers?: ClientHeaders
) {
return this.client.fetch<HttpTypes.AdminPriceListResponse>(
`/admin/price-lists/${id}/prices/batch`,
{
method: "POST",
headers,
body,
query,
}
)
}
async linkProducts(
id: string,
body: HttpTypes.AdminLinkPriceListProducts,
+53
View File
@@ -0,0 +1,53 @@
import { HttpTypes, SelectParams } from "@medusajs/types"
import { Client } from "../client"
import { ClientHeaders } from "../types"
export class Store {
private client: Client
constructor(client: Client) {
this.client = client
}
async retrieve(
id: string,
query?: HttpTypes.AdminStoreParams,
headers?: ClientHeaders
) {
return await this.client.fetch<HttpTypes.AdminStoreResponse>(
`/admin/stores/${id}`,
{
method: "GET",
headers,
query,
}
)
}
async list(query?: HttpTypes.AdminStoreListParams, headers?: ClientHeaders) {
return await this.client.fetch<HttpTypes.AdminStoreListResponse>(
`/admin/stores`,
{
method: "GET",
headers,
query,
}
)
}
async update(
id: string,
body: HttpTypes.AdminUpdateStore,
query?: SelectParams,
headers?: ClientHeaders
) {
return await this.client.fetch<HttpTypes.AdminStoreResponse>(
`/admin/stores/${id}`,
{
method: "POST",
headers,
body,
query,
}
)
}
}
+5
View File
@@ -363,3 +363,8 @@ export type KebabCase<S extends string> =
: S
export type MetadataType = Record<string, unknown> | null
export type RawRounding = {
value: string
precision: number
}
@@ -0,0 +1,14 @@
import { RawRounding } from "../../../common"
export interface AdminCurrency {
code: string
symbol: string
symbol_native: string
name: string
decimal_digits: number
raw_rounding: RawRounding
rounding: number
created_at: string
updated_at: string
deleted_at: string | null
}
@@ -0,0 +1 @@
export * from "./entities"
@@ -0,0 +1 @@
export * from "./admin"
+3
View File
@@ -3,6 +3,7 @@ export * from "./campaign"
export * from "./cart"
export * from "./collection"
export * from "./common"
export * from "./currency"
export * from "./customer"
export * from "./file"
export * from "./fulfillment"
@@ -13,6 +14,7 @@ export * from "./inventory-level"
export * from "./invite"
export * from "./order"
export * from "./payment"
export * from "./price-list"
export * from "./pricing"
export * from "./product"
export * from "./product-category"
@@ -24,6 +26,7 @@ export * from "./sales-channel"
export * from "./shipping-option"
export * from "./shipping-profile"
export * from "./stock-locations"
export * from "./store"
export * from "./tax-rate"
export * from "./tax-region"
export * from "./user"
@@ -0,0 +1,22 @@
import { PriceListStatus, PriceListType } from "../../../pricing"
import { AdminPrice } from "../../pricing"
export interface AdminPriceListPrice extends AdminPrice {
variant_id: string
rules: Record<string, unknown>
}
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: AdminPriceListPrice[]
created_at: string
updated_at: string
deleted_at: string | null
}
@@ -0,0 +1,4 @@
export * from "./entities"
export * from "./payloads"
export * from "./queries"
export * from "./responses"
@@ -0,0 +1,51 @@
import { PriceListStatus, PriceListType } from "../../../pricing"
export interface AdminCreatePriceListPrice {
currency_code: string
amount: number
variant_id: string
min_quantity?: number | null
max_quantity?: number | null
rules?: Record<string, string>
}
export interface AdminCreatePriceList {
title: string
description?: string | null
starts_at?: string | null
ends_at?: string | null
status: PriceListStatus
type: PriceListType
rules?: Record<string, string[]>
prices?: AdminCreatePriceListPrice[]
}
export interface AdminUpdatePriceListPrice {
id: string
currency_code?: string
amount?: number
variant_id: string
min_quantity?: number | null
max_quantity?: number | null
rules?: Record<string, string>
}
export interface AdminUpdatePriceList {
title?: string
description?: string
starts_at?: string | null
ends_at?: string | null
status?: PriceListStatus
type?: PriceListType
rules?: Record<string, string[]>
}
export interface AdminBatchPriceListPrice {
create?: AdminCreatePriceListPrice[]
update?: AdminUpdatePriceListPrice[]
delete?: string[]
}
export interface AdminLinkPriceListProducts {
remove?: string[]
}
@@ -0,0 +1,16 @@
import { BaseFilterable, OperatorMap } from "../../../dal"
import { PriceListStatus } from "../../../pricing"
import { FindParams, SelectParams } from "../../common"
export interface AdminPriceListListParams
extends FindParams,
BaseFilterable<AdminPriceListListParams> {
q?: string
id?: string | string[]
starts_at?: OperatorMap<string>
ends_at?: OperatorMap<string>
status?: PriceListStatus[]
rules_count?: number[]
}
export interface AdminPriceListParams extends SelectParams {}
@@ -0,0 +1,14 @@
import { DeleteResponse, PaginatedResponse } from "../../common"
import { AdminPriceList } from "./entities"
export interface AdminPriceListResponse {
price_list: AdminPriceList
}
export interface AdminPriceListListResponse
extends PaginatedResponse<{
price_lists: AdminPriceList[]
}> {}
export interface AdminPriceListDeleteResponse
extends DeleteResponse<"price_list"> {}
@@ -0,0 +1 @@
export * from "./admin"
@@ -1,5 +1,3 @@
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.
@@ -31,17 +29,3 @@ 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,4 +1 @@
export * from "./entities"
export * from "./payloads"
export * from "./queries"
export * from "./responses"
@@ -1,3 +0,0 @@
export interface AdminLinkPriceListProducts {
remove?: string[]
}
@@ -1,3 +0,0 @@
import { SelectParams } from "../../common"
export interface AdminPriceListParams extends SelectParams {}
@@ -1,5 +0,0 @@
import { AdminPriceList } from "./entities"
export interface AdminPriceListResponse {
price_list: AdminPriceList
}
@@ -0,0 +1,24 @@
import { AdminCurrency } from "../../currency"
export interface AdminStoreCurrency {
id: string
currency_code: string
store_id: string
is_default: boolean
currency: AdminCurrency
created_at: string
updated_at: string
deleted_at: string | null
}
export interface AdminStore {
id: string
name: string
supported_currencies: AdminStoreCurrency[]
default_sales_channel_id: string | null
default_region_id: string | null
default_location_id: string | null
metadata: Record<string, any> | null
created_at: string
updated_at: string
}
@@ -0,0 +1,4 @@
export * from "./entities"
export * from "./payloads"
export * from "./queries"
export * from "./responses"
@@ -0,0 +1,13 @@
interface AdminUpdateStoreSupportedCurrency {
is_default?: boolean
code: string
}
export interface AdminUpdateStore {
name?: string | null
supported_currencies?: AdminUpdateStoreSupportedCurrency[]
default_sales_channel_id?: string | null
default_region_id?: string | null
default_location_id?: string | null
metadata?: Record<string, any> | null
}
@@ -0,0 +1,12 @@
import { BaseFilterable } from "../../../dal"
import { FindParams, SelectParams } from "../../common"
export interface AdminStoreListParams
extends BaseFilterable<AdminStoreListParams>,
FindParams {
q?: string
id?: string | string[]
name?: string | string[]
}
export interface AdminStoreParams extends SelectParams {}
@@ -0,0 +1,11 @@
import { PaginatedResponse } from "../../common"
import { AdminStore } from "./entities"
export interface AdminStoreResponse {
store: AdminStore
}
export interface AdminStoreListResponse
extends PaginatedResponse<{
stores: AdminStore[]
}> {}
@@ -0,0 +1 @@
export * from "./admin"