feat: Revamp product details page and several product fixes and cleanups (#6988)
This commit is contained in:
@@ -1,16 +1,12 @@
|
||||
import {
|
||||
ProductDeleteRes,
|
||||
ProductListRes,
|
||||
ProductRes,
|
||||
} from "../../types/api-responses"
|
||||
import { ProductDeleteRes, ProductListRes } from "../../types/api-responses"
|
||||
import { deleteRequest, getRequest, postRequest } from "./common"
|
||||
|
||||
async function retrieveProduct(id: string, query?: Record<string, any>) {
|
||||
return getRequest<ProductRes>(`/admin/products/${id}`, query)
|
||||
return getRequest<any>(`/admin/products/${id}`, query)
|
||||
}
|
||||
|
||||
async function createProduct(payload: any) {
|
||||
return postRequest<ProductRes>(`/admin/products`, payload)
|
||||
return postRequest<any>(`/admin/products`, payload)
|
||||
}
|
||||
|
||||
async function listProducts(query?: Record<string, any>) {
|
||||
@@ -18,7 +14,7 @@ async function listProducts(query?: Record<string, any>) {
|
||||
}
|
||||
|
||||
async function updateProduct(id: string, payload: any) {
|
||||
return postRequest<ProductRes>(`/admin/products/${id}`, payload)
|
||||
return postRequest<any>(`/admin/products/${id}`, payload)
|
||||
}
|
||||
|
||||
async function deleteProduct(id: string) {
|
||||
@@ -40,12 +36,38 @@ async function listVariants(productId: string, query?: Record<string, any>) {
|
||||
return getRequest<any>(`/admin/products/${productId}/variants`, query)
|
||||
}
|
||||
|
||||
async function updateVariant(
|
||||
productId: string,
|
||||
variantId: string,
|
||||
payload: any
|
||||
) {
|
||||
return postRequest<any>(
|
||||
`/admin/products/${productId}/variants/${variantId}`,
|
||||
payload
|
||||
)
|
||||
}
|
||||
|
||||
async function deleteVariant(productId: string, variantId: string) {
|
||||
return deleteRequest<any>(
|
||||
`/admin/products/${productId}/variants/${variantId}`
|
||||
)
|
||||
}
|
||||
|
||||
async function createOption(productId: string, payload: any) {
|
||||
return postRequest<any>(`/admin/products/${productId}/options`, payload)
|
||||
}
|
||||
|
||||
async function updateOption(productId: string, optionId: string, payload: any) {
|
||||
return postRequest<any>(
|
||||
`/admin/products/${productId}/options/${optionId}`,
|
||||
payload
|
||||
)
|
||||
}
|
||||
|
||||
async function deleteOption(productId: string, optionId: string) {
|
||||
return deleteRequest<any>(`/admin/products/${productId}/options/${optionId}`)
|
||||
}
|
||||
|
||||
export const products = {
|
||||
retrieve: retrieveProduct,
|
||||
list: listProducts,
|
||||
@@ -54,5 +76,9 @@ export const products = {
|
||||
delete: deleteProduct,
|
||||
retrieveVariant,
|
||||
listVariants,
|
||||
updateVariant,
|
||||
deleteVariant,
|
||||
createOption,
|
||||
updateOption,
|
||||
deleteOption,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user