import React from 'react'; import type { DealItem } from '../types'; import { TagIcon } from './icons/TagIcon'; import { LoadingSpinner } from './LoadingSpinner'; import { formatUnitPrice } from '../utils/unitConverter'; import { Session } from '@supabase/supabase-js'; import { UserIcon } from './icons/UserIcon'; interface PriceChartProps { deals: DealItem[]; isLoading: boolean; unitSystem: 'metric' | 'imperial'; session: Session | null; } export const PriceChart: React.FC = ({ deals, isLoading, unitSystem, session }) => { const renderContent = () => { if (!session) { return (

Personalized Deals

Log in to see active deals for items on your watchlist.

); } if (isLoading) { return (
Finding active deals...
); } if (deals.length === 0) { return

No deals for your watched items found in any currently valid flyers.

; } return (
{deals.map((deal, index) => { const formattedUnitPrice = formatUnitPrice(deal.unit_price, unitSystem); return ( ) })}
Item Store Price Unit Price
{deal.item} {deal.master_item_name && deal.master_item_name.toLowerCase() !== deal.item.toLowerCase() && ( ({deal.master_item_name}) )}
{deal.quantity}
{deal.storeName} {deal.price_display}
{formattedUnitPrice.price} {formattedUnitPrice.unit && ( {formattedUnitPrice.unit} )}
); }; return (

Active Deals on Watched Items

{renderContent()}
); };