change prices &...
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user