change prices &...

This commit is contained in:
2026-06-03 11:57:40 +03:30
parent f4b98576f5
commit b055cd4a5d
16 changed files with 305 additions and 25 deletions
+12
View File
@@ -1,13 +1,16 @@
import { baseURL } from '@/themeConfig'
import type { User } from '@/models/login'
export interface ProductFile {
id?: number
url?: string | null
src?: string
full_src?: string
}
export function getFileUrl(file?: ProductFile | null): string | null {
if (!file) return null
if (file.full_src) return file.full_src
if (file.url) return file.url
if (!file.src) return null
if (/^https?:\/\//i.test(file.src)) return file.src
@@ -15,3 +18,12 @@ export function getFileUrl(file?: ProductFile | null): string | null {
const path = file.src.replace(/^\//, '')
return `${base}/${path}`
}
/** Resolve profile avatar URL from GET /customer/me payload */
export function getUserAvatarUrl(user?: User | null): string | null {
if (!user) return null
if (typeof user.avatar_url === 'string' && user.avatar_url) return user.avatar_url
if (typeof user.full_src === 'string' && user.full_src) return user.full_src
const nested = user.avatar || user.file
return getFileUrl(nested as ProductFile | undefined)
}