This commit is contained in:
Your Name committed 2026-10-06 19:55:05 +07:00
1 parent acee55a633
commit b7f337fb79
5 files changed
+11 -12

No files matched your search

@@ -1,6 +1,6 @@
"use client"
import { useState, useMemo } from 'react'
import { useMemo } from 'react'
import Image from 'next/image'
import Link from './LocalizedLink'
import type { Product, Variant } from '@homaroma/types'
@@ -35,10 +35,10 @@ export default function ProductSwatchCard({ product, badgeText }: ProductSwatchC
return swatches
}, [product.variants])
// Active selected variant (for image and price swap when clicking swatch)
const [activeVariant, setActiveVariant] = useState<Variant | null>(() => {
// Active selected variant
const activeVariant = useMemo<Variant | null>(() => {
return colorSwatches[0]?.variant || product.variants?.[0] || null
})
}, [colorSwatches, product.variants])
// Display Image: variant image if available, else first product image
const displayImageUrl = useMemo(() => {