import React from 'react'; import Box from '@mui/material/Box'; import Tooltip from '@mui/material/Tooltip'; import type { SxProps, Theme } from '@mui/material/styles'; import LocationOnOutlinedIcon from '@mui/icons-material/LocationOnOutlined'; import StarRoundedIcon from '@mui/icons-material/StarRounded'; import VerifiedOutlinedIcon from '@mui/icons-material/VerifiedOutlined'; import InfoOutlinedIcon from '@mui/icons-material/InfoOutlined'; import { Card } from '../../atoms/Card'; import { Badge } from '../../atoms/Badge'; import type { BadgeColor } from '../../atoms/Badge/Badge'; import { Typography } from '../../atoms/Typography'; // ─── Types ─────────────────────────────────────────────────────────────────── /** Own props for the FA ProviderCard molecule (excludes HTML/Card passthrough) */ export interface ProviderCardOwnProps { /** Provider display name */ name: string; /** Location text (suburb, city) */ location: string; /** Whether this provider is a verified/trusted partner */ verified?: boolean; /** Hero image URL — only rendered when verified */ imageUrl?: string; /** Provider logo URL — rounded rectangle overlay on image, only rendered when verified */ logoUrl?: string; /** Average rating (e.g. 4.8). Omit to hide reviews. */ rating?: number; /** Number of reviews (e.g. 127). Omit to hide review count. */ reviewCount?: number; /** Capability badge label (e.g. "Online Arrangement") */ capabilityLabel?: string; /** Capability badge colour intent — maps to Badge colour */ capabilityColor?: BadgeColor; /** Tooltip description for the capability badge (shown on hover/focus) */ capabilityDescription?: string; /** Starting price in dollars (shown as "From $X") */ startingPrice?: number; /** Whether this card is the currently selected provider */ selected?: boolean; /** Click handler — entire card is clickable */ onClick?: () => void; /** MUI sx prop for style overrides */ sx?: SxProps; } /** Props for the FA ProviderCard molecule — includes HTML/ARIA passthrough to Card */ export type ProviderCardProps = ProviderCardOwnProps & Omit, keyof ProviderCardOwnProps>; // ─── Constants ─────────────────────────────────────────────────────────────── const LOGO_SIZE = 'var(--fa-provider-card-logo-size)'; const LOGO_BORDER_RADIUS = 'var(--fa-provider-card-logo-border-radius)'; const IMAGE_HEIGHT = 'var(--fa-provider-card-image-height)'; const CONTENT_PADDING = 'var(--fa-provider-card-content-padding)'; const CONTENT_GAP = 'var(--fa-provider-card-content-gap)'; // ─── Component ─────────────────────────────────────────────────────────────── /** * Provider listing card for the FA design system. * * Displays a funeral provider in the provider select screen's scrollable * list. Supports verified (paid partner) and unverified (scraped listing) * providers with consistent text alignment for scan readability. * * **Verified providers** get a hero image, logo (rounded rectangle inside * image area), and "Verified" badge. **Unverified providers** show text * content only with a subtle top accent bar for visibility in mixed lists. * * Composes: Card (interactive, padding="none"), Badge, Typography. * * Usage: * ```tsx * navigate(`/providers/parsons`)} * /> * ``` */ export const ProviderCard = React.forwardRef( ( { name, location, verified = false, imageUrl, logoUrl, rating, reviewCount, capabilityLabel, capabilityColor = 'default', capabilityDescription, selected = false, startingPrice, onClick, sx, ...rest }, ref, ) => { const showImage = verified && imageUrl; const showLogo = verified && logoUrl; return ( {/* ── Image area (verified only) ── */} {showImage && ( {/* Verified badge */} }> Verified {/* Logo — fully inside image area, bottom-left */} {showLogo && ( )} )} {/* ── Content area ── */} {/* Provider name — full width, no logo competition */} {name} {/* Price — "Packages from $X" with subtle size differentiation */} {startingPrice != null && ( Packages from ${startingPrice.toLocaleString('en-AU')} )} {/* Meta row: location + reviews */} {/* Location */} {location} {/* Reviews */} {rating != null && ( {rating} {reviewCount != null && ` (${reviewCount.toLocaleString('en-AU')})`} )} {/* Capability badge — trailing info icon signals hover-for-definition */} {capabilityLabel && ( {capabilityDescription ? ( {capabilityLabel} ) : ( {capabilityLabel} )} )} ); }, ); ProviderCard.displayName = 'ProviderCard'; export default ProviderCard;