'use client';

import { useTranslations } from 'next-intl';
import { Sparkles } from 'lucide-react';

/**
 * Feature 054 — US13 (C6). Approximate loyalty points a customer earns on this
 * item, shown above the booking CTA. Per-vendor earn rates are not exposed on
 * the service detail payload, so this uses the platform baseline of 1 point per
 * major currency unit and labels the figure as approximate ("~").
 */
export function EarnPointsLine({ priceFromMinor, locale }: { priceFromMinor: number; locale: string }) {
  const t = useTranslations('loyalty.preview');
  const points = Math.floor((priceFromMinor ?? 0) / 100);
  if (points <= 0) return null;

  return (
    <p
      data-testid="earn-points-line"
      className="mb-3 inline-flex items-center gap-1.5 rounded-md bg-accent-50 px-2.5 py-1 text-xs font-medium text-accent-800"
    >
      <Sparkles aria-hidden="true" className="h-3.5 w-3.5" />
      {t('earn_on_item', { points: points.toLocaleString(locale === 'ar' ? 'ar-EG' : 'en-GB') })}
    </p>
  );
}
