Insert image for product
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
import useAxios from '@core/utils/useAxios'
|
||||
import { pickImageFromRecord, resolveFileImageUrl, unwrapApiRecord } from '@/utils/file'
|
||||
|
||||
export interface FileResource {
|
||||
id?: number
|
||||
src?: string
|
||||
full_src?: string
|
||||
path?: string
|
||||
name?: string
|
||||
title?: string
|
||||
original_name?: string
|
||||
}
|
||||
|
||||
/** Load product image URL from product detail API (file GET endpoint does not exist on backend). */
|
||||
export async function fetchProductImageUrl(productId: number): Promise<string | undefined> {
|
||||
try {
|
||||
const response = await useAxios.get(`/admin/product/${productId}`, {
|
||||
meta: { silent: true }
|
||||
})
|
||||
const record = unwrapApiRecord(response)
|
||||
if (!record) return undefined
|
||||
|
||||
return resolveFileImageUrl(pickImageFromRecord(record))
|
||||
} catch {
|
||||
return undefined
|
||||
}
|
||||
}
|
||||
@@ -40,6 +40,7 @@ export const getSingleArchiveTable = async (params: TableInput) =>
|
||||
export const getCustomerById = async (id: number) => {
|
||||
return await useAxios.get(`/admin/product/${id}`)
|
||||
}
|
||||
|
||||
export const changeBuyActiveProduct = async (id?: number) => {
|
||||
return await useAxios.get(`/admin/product/open_buy/${id}`)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user