Add store-product Excel bulk edit and polish the business dashboard.
Export/import price and stock from Store Products, keep card order after saves, localize variations, and drop unused website nav items. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
co-authored by
Cursor
parent
7b51dda82a
commit
832ac32a09
@@ -6,6 +6,8 @@ export interface BusinessCustomer {
|
||||
cellNumber: string
|
||||
firstName: string | null
|
||||
lastName: string | null
|
||||
firstNameEn?: string | null
|
||||
lastNameEn?: string | null
|
||||
email: string | null
|
||||
label: string
|
||||
}
|
||||
@@ -68,6 +70,8 @@ export interface UpdateCustomerPayload {
|
||||
isEnabled?: boolean
|
||||
firstName?: string
|
||||
lastName?: string
|
||||
firstNameEn?: string
|
||||
lastNameEn?: string
|
||||
email?: string
|
||||
cellNumber?: string
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { apiRequest } from '../lib/api'
|
||||
import { apiRequest, apiRequestBlob, apiRequestForm } from '../lib/api'
|
||||
import { getActiveBusinessId } from '../lib/businessContext'
|
||||
|
||||
/** Product cards per page on My Store Items (grid). */
|
||||
@@ -167,3 +167,47 @@ export async function deleteStoreItemsByProduct(productId: string) {
|
||||
auth: true,
|
||||
})
|
||||
}
|
||||
|
||||
export async function downloadStoreItemsExcel() {
|
||||
const { blob } = await apiRequestBlob(businessPath('/export'), { auth: true })
|
||||
const url = URL.createObjectURL(blob)
|
||||
const link = document.createElement('a')
|
||||
link.href = url
|
||||
link.download = storeItemsExcelFilename()
|
||||
document.body.appendChild(link)
|
||||
link.click()
|
||||
link.remove()
|
||||
URL.revokeObjectURL(url)
|
||||
}
|
||||
|
||||
function storeItemsExcelFilename(now = new Date()) {
|
||||
const parts = new Intl.DateTimeFormat('en-GB', {
|
||||
timeZone: 'Asia/Tehran',
|
||||
year: 'numeric',
|
||||
month: '2-digit',
|
||||
day: '2-digit',
|
||||
hour: '2-digit',
|
||||
minute: '2-digit',
|
||||
hourCycle: 'h23',
|
||||
}).formatToParts(now)
|
||||
|
||||
const pick = (type: Intl.DateTimeFormatPartTypes) =>
|
||||
parts.find((part) => part.type === type)?.value ?? ''
|
||||
|
||||
return `store items - ${pick('year')}-${pick('month')}-${pick('day')} - ${pick('hour')}-${pick('minute')}.xlsx`
|
||||
}
|
||||
|
||||
export interface StoreItemsExcelImportResult {
|
||||
message: string
|
||||
total: number
|
||||
updated: number
|
||||
unchanged: number
|
||||
}
|
||||
|
||||
export async function importStoreItemsExcel(file: File) {
|
||||
const formData = new FormData()
|
||||
formData.append('file', file)
|
||||
return apiRequestForm<StoreItemsExcelImportResult>(businessPath('/import'), formData, {
|
||||
auth: true,
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user