Insert image for product

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-05-17 13:45:52 +03:30
co-authored by Cursor
parent f994a61567
commit 1c2647d093
11 changed files with 457 additions and 97 deletions
+27
View File
@@ -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
}
}
+1
View File
@@ -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}`)
}