Port modular price, product, and PWA fixes into boursecu
Sync live quote handling, SSE product images, store hours, file URL normalization, PWA icon cache, TV monitor, about software, SuperAdmin menu gates, price alerts, and related UX from modular while preserving boursecu branding and config constraints. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -648,19 +648,31 @@ export function enrichInventoryWithCatalog<T extends { id?: number }>(
|
||||
})
|
||||
}
|
||||
|
||||
function withProductImageCacheBust(
|
||||
url: string,
|
||||
product?: { file_id?: number | string | null; file?: ProductFile | null } | null,
|
||||
): string {
|
||||
if (!url || !/^https?:\/\//i.test(url)) return url
|
||||
const version = product?.file_id ?? product?.file?.id
|
||||
if (version == null || version === '' || Number(version) <= 0) return url
|
||||
if (/[?&]v=/.test(url)) return url
|
||||
return `${url}${url.includes('?') ? '&' : '?'}v=${encodeURIComponent(String(version))}`
|
||||
}
|
||||
|
||||
export function getProductDisplayImage(product?: {
|
||||
group_type?: string | null
|
||||
title?: string | null
|
||||
file?: ProductFile | null
|
||||
file_id?: number | string | null
|
||||
img?: string | null
|
||||
} | null): string {
|
||||
const fileUrl = getFileUrl(product?.file)
|
||||
if (fileUrl) {
|
||||
return fileUrl
|
||||
return withProductImageCacheBust(fileUrl, product)
|
||||
}
|
||||
|
||||
if (product?.img && /^https?:\/\//i.test(product.img)) {
|
||||
return product.img
|
||||
return withProductImageCacheBust(product.img, product)
|
||||
}
|
||||
|
||||
const group = normalizeProductGroupType(product?.group_type)
|
||||
|
||||
Reference in New Issue
Block a user