import React, { useState } from 'react'; import type { FC, KeyboardEvent } from 'react'; import { FiArrowLeft, FiHeart, FiMic, FiShoppingCart, FiX, } from 'react-icons/fi'; import { PiDotsSixThin } from 'react-icons/pi'; import DismissIcon from '../icons/DismissIcon'; import { DEFAULT_BLUE_RGB, DEFAULT_PINK_RGB, hexToRgb, } from '../../utils/colors'; import TripleStarsIcon from '../icons/TripleStarsIcon'; type SessionProduct = { id: string; name: string; imageUrl: string | File | null; price: number; oldPrice?: number; currency?: string; liked?: boolean; }; type LatestArrivalsSessionCardProps = { title?: string; introTitle?: string; introBody?: React.ReactNode; matchTitle?: string; suggestionText?: string[]; products: SessionProduct[]; favoritesCount?: number; textColor: string; buttonColor: string; cartIconColor: string; popupBorderColorLeft: string; popupBorderColorRight: string; showPrices?: boolean; showAddToCartButton?: boolean; onBack?: () => void; onToggleLikeProduct?: (id: string, liked: boolean) => void; onDislikeProduct?: (id: string) => void; onAddToCart?: (id: string) => void; onSuggestionClick?: () => void; onAsk?: (question: string) => void; }; type ProductCardProps = { product: SessionProduct; textColor: string; buttonColor: string; popupBorderColorLeft: string; cartIconColor?: string; showPrices: boolean; showAddToCartButton: boolean; onToggleLike?: (id: string, liked: boolean) => void; onDislike?: (id: string) => void; onAddToCart?: (id: string) => void; }; const ProductCard: FC = ({ product, onToggleLike, onDislike, onAddToCart, buttonColor, textColor, cartIconColor, popupBorderColorLeft, showPrices, showAddToCartButton, }) => { const { id, name, imageUrl, price, oldPrice, currency = '$', liked, } = product; const formattedPrice = `${currency} ${price.toLocaleString(undefined, { minimumFractionDigits: 2, maximumFractionDigits: 2, })}`; const formattedOldPrice = oldPrice != null ? `${currency} ${oldPrice.toLocaleString(undefined, { minimumFractionDigits: 2, maximumFractionDigits: 2, })}` : undefined; const handleLike = () => { onToggleLike?.(id, !liked); }; const handleDislike = () => { onDislike?.(id); }; const handleAddToCart = () => { onAddToCart?.(id); }; const customStyles = { '--accent-pink-rgb': hexToRgb(popupBorderColorLeft || '') || '0, 0, 0', } as React.CSSProperties; return (
{/* Image */}
{name} {/* Like */} {/* Dislike (X) */}
{/* Title */}

{name}

{/* Prices */} {showPrices && (

{formattedPrice}

{formattedOldPrice && (

{formattedOldPrice}

)}
)} {/* Add to cart */} {showAddToCartButton && ( )}
); }; type SessionInputBarProps = { placeholder: string; onSubmit?: (val: string) => void; popupBorderColorLeft?: string; popupBorderColorRight?: string; }; const SessionInputBar: FC = ({ // placeholder, onSubmit, popupBorderColorLeft, popupBorderColorRight, }) => { const [value, setValue] = useState(''); const customStyles = { '--accent-pink-rgb': hexToRgb(popupBorderColorLeft || '') || DEFAULT_PINK_RGB, '--accent-blue-rgb': hexToRgb(popupBorderColorRight || '') || DEFAULT_BLUE_RGB, } as React.CSSProperties; const handleSubmit = () => { const trimmed = value.trim(); if (!trimmed) return; onSubmit?.(trimmed); setValue(''); }; const handleKeyDown = (e: KeyboardEvent) => { if (e.key === 'Enter') { e.preventDefault(); handleSubmit(); } }; return (
setValue(e.target.value)} onKeyDown={handleKeyDown} />
); }; export const LatestArrivalsSessionCard: FC = ({ title = 'Latest arrivals', // introTitle = "Latest arrivals", introBody, matchTitle = 'New arrivals match your broad interests.', suggestionText, products, favoritesCount = 3, buttonColor, textColor, popupBorderColorLeft, popupBorderColorRight, cartIconColor, showPrices = true, showAddToCartButton = true, onBack, onToggleLikeProduct, onDislikeProduct, onAddToCart, onSuggestionClick, onAsk, }) => { const customStyles = { '--accent-pink-rgb': hexToRgb(popupBorderColorLeft || '') || '0, 0, 0', } as React.CSSProperties; const leftRgb = hexToRgb(popupBorderColorLeft || ''); const rightRgb = hexToRgb(popupBorderColorRight || ''); const cardStyle: React.CSSProperties = { background: `linear-gradient( to bottom, rgba(${leftRgb}, 0.12) 0%, rgba(${leftRgb}, 0.12) 40%, rgba(${rightRgb}, 0.18) 100% )`, backdropFilter: 'blur(12px)', boxShadow: `0 25px 50px -12px rgba(${rightRgb}, 0.35)`, }; return (
{/* Top bar */}
{/* Back */} {/* Handle */}
{/* Favorites + minimize */}
{favoritesCount}
{/* Scrollable content */}
{/* Title */}

{title}

{/* Message bubble */}
{introBody ? ( introBody ) : ( <>

We have some wonderful new arrivals that just came in! Are you looking for something in tech, fashion, or perhaps a home accessory?

For example, we recently added the{' '} Google Pixel 9 Pro, which offers cutting-edge AI and camera features. If you're looking for fashion, the elegant Verona Linen Wrap Skirt is a beautiful new piece designed for graceful movement. We also have the stylish Leather Wallet Organizer for keeping your essentials secure and accessible.

)}
{/* Match title */}

{matchTitle}

{/* Product carousel */}
{products.map(p => ( ))}
{/* Suggestion chip */}
{suggestionText && suggestionText.map((suggestion, key) => { return ( ); })}
{/* Sticky bottom input */}
); };