'use client'

import { useCurrencyStore } from '@/store/currencyStore'

// Price in the store currency (client store, seeded server-side by
// CurrencyStoreSync, so server and client render the same text).
export default function PriceTag({
  price,
  oldPrice,
  tone = 'light',
}: {
  price: number
  oldPrice?: number
  tone?: 'light' | 'dark'
}) {
  const formatAmount = useCurrencyStore((s) => s.formatAmount)
  return (
    <span className="flex shrink-0 flex-col items-end leading-tight">
      <span className={`text-lg font-black ${tone === 'dark' ? 'text-white' : 'text-dark'}`}>{formatAmount(price)}</span>
      {oldPrice && (
        <span className={`text-xs line-through ${tone === 'dark' ? 'text-white/45' : 'text-gray-400'}`}>{formatAmount(oldPrice)}</span>
      )}
    </span>
  )
}
