x
This commit is contained in:
1 parent
b415fb2eb4
commit
cfd642dee0
3 files changed
+27
-7
No files matched your search
@@ -4,7 +4,7 @@ import { useEffect, useMemo, useState } from 'react'
|
||||
import Image from 'next/image'
|
||||
import Link from './LocalizedLink'
|
||||
import { Heart, Search, ShoppingBag, Star, User } from 'lucide-react'
|
||||
import { formatPrice, getCategoryImage, type Product } from '@homaroma/types'
|
||||
import { formatPrice, getCategoryImage, type Product, type StoreSettings } from '@homaroma/types'
|
||||
import { useCartStore } from '../store/cartStore'
|
||||
import { resolveCategoryName, resolveLocalized } from '../lib/localization'
|
||||
import { useLang } from '../hooks/useLang'
|
||||
@@ -29,15 +29,18 @@ function resolveOptionValue(val: string, options: Product['options'], lang: stri
|
||||
export default function ProductStickyPurchaseBar({
|
||||
product,
|
||||
triggerId,
|
||||
settings = null,
|
||||
}: {
|
||||
product: Product
|
||||
triggerId: string
|
||||
settings?: StoreSettings | null
|
||||
}) {
|
||||
const lang = useLang()
|
||||
const [isVisible, setIsVisible] = useState(false)
|
||||
const { addToCart, toggleCart } = useCartStore()
|
||||
const productName = resolveLocalized(product.name, lang) || product.brand.name
|
||||
const categoryName = resolveCategoryName(product.category, lang)
|
||||
const brandName = settings?.brandName || 'HomAroma'
|
||||
const variant = product.variants?.[0]
|
||||
const imageUrl = product.images?.[0]?.url || product.category.imageUrl || getCategoryImage(categoryName)
|
||||
|
||||
@@ -91,8 +94,19 @@ export default function ProductStickyPurchaseBar({
|
||||
}`}>
|
||||
<div className="relative mx-auto flex max-w-7xl items-start justify-between gap-6">
|
||||
<div className="absolute left-1/2 top-0 hidden -translate-x-1/2 md:block">
|
||||
<Link href="/" className="text-3xl font-bold uppercase tracking-[0.22em] text-text-main">
|
||||
HomAroma
|
||||
<Link href="/" className="flex h-10 items-center justify-center">
|
||||
{settings?.logoUrl ? (
|
||||
<Image
|
||||
src={settings.logoUrl}
|
||||
alt={brandName}
|
||||
width={180}
|
||||
height={44}
|
||||
unoptimized
|
||||
className="max-h-10 w-auto object-contain"
|
||||
/>
|
||||
) : (
|
||||
<span className="text-3xl font-bold uppercase tracking-[0.22em] text-text-main">{brandName}</span>
|
||||
)}
|
||||
</Link>
|
||||
</div>
|
||||
|
||||
|
||||
Reference in new issue
Block a user