feat(dashboard,types,js-sdk): Cleanup collection domain (#7502)
**What** - Adds missing collection HttpTypes - Adds missing sdk functions - Adds usage of sdk to collection domain.
This commit is contained in:
@@ -203,7 +203,10 @@ export class Admin {
|
||||
}
|
||||
)
|
||||
},
|
||||
list: async (queryParams?: FindParams, headers?: ClientHeaders) => {
|
||||
list: async (
|
||||
queryParams?: FindParams & HttpTypes.AdminCollectionFilters,
|
||||
headers?: ClientHeaders
|
||||
) => {
|
||||
return this.client.fetch<
|
||||
PaginatedResponse<{ customers: HttpTypes.AdminCustomer[] }>
|
||||
>(`/admin/customers`, {
|
||||
@@ -234,4 +237,82 @@ export class Admin {
|
||||
)
|
||||
},
|
||||
}
|
||||
|
||||
public collection = {
|
||||
create: async (
|
||||
body: HttpTypes.AdminCreateCollection,
|
||||
query?: SelectParams,
|
||||
headers?: ClientHeaders
|
||||
) => {
|
||||
return this.client.fetch<{ collection: HttpTypes.AdminCollection }>(
|
||||
`/admin/collections`,
|
||||
{
|
||||
method: "POST",
|
||||
headers,
|
||||
body,
|
||||
query,
|
||||
}
|
||||
)
|
||||
},
|
||||
update: async (
|
||||
id: string,
|
||||
body: HttpTypes.AdminUpdateCollection,
|
||||
query?: SelectParams,
|
||||
headers?: ClientHeaders
|
||||
) => {
|
||||
return this.client.fetch<{ collection: HttpTypes.AdminCollection }>(
|
||||
`/admin/collections/${id}`,
|
||||
{
|
||||
method: "POST",
|
||||
headers,
|
||||
body,
|
||||
query,
|
||||
}
|
||||
)
|
||||
},
|
||||
list: async (queryParams?: FindParams, headers?: ClientHeaders) => {
|
||||
return this.client.fetch<
|
||||
PaginatedResponse<{ collections: HttpTypes.AdminCollection[] }>
|
||||
>(`/admin/collections`, {
|
||||
headers,
|
||||
query: queryParams,
|
||||
})
|
||||
},
|
||||
retrieve: async (
|
||||
id: string,
|
||||
query?: SelectParams,
|
||||
headers?: ClientHeaders
|
||||
) => {
|
||||
return this.client.fetch<{ collection: HttpTypes.AdminCollection }>(
|
||||
`/admin/collections/${id}`,
|
||||
{
|
||||
query,
|
||||
headers,
|
||||
}
|
||||
)
|
||||
},
|
||||
delete: async (id: string, headers?: ClientHeaders) => {
|
||||
return this.client.fetch<DeleteResponse<"collection">>(
|
||||
`/admin/collections/${id}`,
|
||||
{
|
||||
method: "DELETE",
|
||||
headers,
|
||||
}
|
||||
)
|
||||
},
|
||||
updateProducts: async (
|
||||
id: string,
|
||||
body: HttpTypes.AdminUpdateCollectionProducts,
|
||||
headers?: ClientHeaders
|
||||
) => {
|
||||
return this.client.fetch<{ collection: HttpTypes.AdminCollection }>(
|
||||
`/admin/collections/${id}/products`,
|
||||
{
|
||||
method: "POST",
|
||||
headers,
|
||||
body,
|
||||
}
|
||||
)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,16 @@
|
||||
import { BaseProductCollection, BaseProductCollectionFilters } from "./common"
|
||||
import { BaseCollection, BaseCollectionFilters } from "./common"
|
||||
|
||||
export interface AdminCollection extends BaseProductCollection {}
|
||||
export interface AdminCollectionFilters extends BaseProductCollectionFilters {}
|
||||
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[]
|
||||
}
|
||||
|
||||
@@ -1,21 +1,24 @@
|
||||
import { BaseFilterable } from "../../dal"
|
||||
import { BaseProduct } from "../product/common"
|
||||
import { BaseFilterable, OperatorMap } from "../../dal"
|
||||
import { AdminProduct } from "../product"
|
||||
|
||||
export interface BaseProductCollection {
|
||||
export interface BaseCollection {
|
||||
id?: string
|
||||
title?: string
|
||||
handle?: string
|
||||
created_at?: string
|
||||
updated_at?: string
|
||||
deleted_at?: string | null
|
||||
products?: BaseProduct[]
|
||||
products?: AdminProduct[]
|
||||
metadata?: Record<string, unknown> | null
|
||||
}
|
||||
|
||||
export interface BaseProductCollectionFilters
|
||||
extends BaseFilterable<BaseProductCollectionFilters> {
|
||||
export interface BaseCollectionFilters
|
||||
extends BaseFilterable<BaseCollectionFilters> {
|
||||
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 { BaseProductCollection, BaseProductCollectionFilters } from "./common"
|
||||
import { BaseCollection, BaseCollectionFilters } from "./common"
|
||||
|
||||
export interface StoreCollection extends BaseProductCollection {}
|
||||
export interface StoreCollectionFilters extends BaseProductCollectionFilters {}
|
||||
export interface StoreCollection extends BaseCollection {}
|
||||
export interface StoreCollectionFilters extends BaseCollectionFilters {}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { BaseFilterable, OperatorMap } from "../../dal"
|
||||
import { BaseProductCollection } from "../collection/common"
|
||||
import { BaseCollection } from "../collection/common"
|
||||
|
||||
export type ProductStatus = "draft" | "proposed" | "published" | "rejected"
|
||||
|
||||
@@ -20,7 +20,7 @@ export interface BaseProduct {
|
||||
hs_code?: string
|
||||
mid_code?: string
|
||||
material?: string
|
||||
collection?: BaseProductCollection
|
||||
collection?: BaseCollection
|
||||
collection_id?: string | null
|
||||
categories?: BaseProductCategory[]
|
||||
type?: BaseProductType | null
|
||||
|
||||
Reference in New Issue
Block a user