Add product AI fill, Enter-to-filter, and URL-persisted product filters.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
co-authored by
Cursor
parent
ad83fc1099
commit
4d480799b0
@@ -4,12 +4,22 @@ import type { ProductApi } from './productService'
|
||||
|
||||
export type ProductAiLanguage = 'en' | 'fa'
|
||||
|
||||
export type ProductAiFillField = 'summary' | 'description'
|
||||
|
||||
export interface CreateProductByAiPayload {
|
||||
categoryId: string
|
||||
name: string
|
||||
language: ProductAiLanguage
|
||||
}
|
||||
|
||||
export interface FillProductFieldByAiPayload {
|
||||
field: ProductAiFillField
|
||||
prompt: string
|
||||
title?: string
|
||||
nameFa?: string
|
||||
categoryId?: string
|
||||
}
|
||||
|
||||
export async function createProductByAi(payload: CreateProductByAiPayload) {
|
||||
const businessId = getActiveBusinessId()
|
||||
if (!businessId) {
|
||||
@@ -25,3 +35,19 @@ export async function createProductByAi(payload: CreateProductByAiPayload) {
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
export async function fillProductFieldByAi(payload: FillProductFieldByAiPayload) {
|
||||
const businessId = getActiveBusinessId()
|
||||
if (!businessId) {
|
||||
throw new Error('No active business selected. Please sign in again.')
|
||||
}
|
||||
|
||||
return apiRequest<
|
||||
| { field: 'summary'; text: string }
|
||||
| { field: 'description'; html: string }
|
||||
>(`/businesses/${businessId}/products/ai-fill`, {
|
||||
method: 'POST',
|
||||
auth: true,
|
||||
body: payload,
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user