Fix part hover preview and localStorage quota on cart creation
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
import { useState } from 'react'
|
import { useEffect, useState } from 'react'
|
||||||
import type { Product, Drone, CompleteDrone, KitBuild } from '../types'
|
import type { Product, Drone, CompleteDrone, KitBuild } from '../types'
|
||||||
import { useResolvedImage, resolveImageSync } from '../utils/imageCache'
|
import { useResolvedImage, resolveImageSync, resolveImage } from '../utils/imageCache'
|
||||||
|
|
||||||
function fmt(amount: number, currency: string) {
|
function fmt(amount: number, currency: string) {
|
||||||
return new Intl.NumberFormat('en', { style: 'currency', currency }).format(amount)
|
return new Intl.NumberFormat('en', { style: 'currency', currency }).format(amount)
|
||||||
@@ -26,6 +26,14 @@ export function ItemCard({ item, onEdit, onRemove }: Props) {
|
|||||||
const [hoverImg, setHoverImg] = useState<string | null>(null)
|
const [hoverImg, setHoverImg] = useState<string | null>(null)
|
||||||
const [mousePos, setMousePos] = useState({ x: 0, y: 0 })
|
const [mousePos, setMousePos] = useState({ x: 0, y: 0 })
|
||||||
|
|
||||||
|
// Preload part images into memCache so resolveImageSync works on hover
|
||||||
|
useEffect(() => {
|
||||||
|
if (!isKit) return
|
||||||
|
for (const p of (item as KitBuild).parts) {
|
||||||
|
if (p.image) resolveImage(p.image)
|
||||||
|
}
|
||||||
|
}, [item])
|
||||||
|
|
||||||
const priceLabel = isKit
|
const priceLabel = isKit
|
||||||
? kitTotal(item as KitBuild)
|
? kitTotal(item as KitBuild)
|
||||||
: isDrone
|
: isDrone
|
||||||
|
|||||||
Reference in New Issue
Block a user