import React from 'react'; import { useTranslation } from 'react-i18next'; import { Clock, MapPin, User, Calendar, CheckCircle2, AlertCircle } from 'lucide-react'; import { Service, Business } from '../../types'; import Card from '../ui/Card'; import Badge from '../ui/Badge'; interface CustomerPreviewProps { service: Service | null; // Null when creating new business: Business; previewData?: Partial; // Live form data } export const CustomerPreview: React.FC = ({ service, business, previewData }) => { const { t } = useTranslation(); // Merge existing service data with live form preview const data = { ...service, ...previewData, price: previewData?.price ?? service?.price ?? 0, name: previewData?.name || service?.name || 'New Service', description: previewData?.description || service?.description || 'Service description will appear here...', durationMinutes: previewData?.durationMinutes ?? service?.durationMinutes ?? 30, }; const formatPrice = (price: number | string) => { const numPrice = typeof price === 'string' ? parseFloat(price) : price; return new Intl.NumberFormat('en-US', { style: 'currency', currency: 'USD', }).format(numPrice); }; const formatDuration = (minutes: number) => { const hours = Math.floor(minutes / 60); const mins = minutes % 60; if (hours > 0) return `${hours}h ${mins > 0 ? `${mins}m` : ''}`; return `${mins}m`; }; return (

Customer Preview

Live Preview
{/* Booking Page Card Simulation */}
{/* Cover Image Placeholder */}
{data.name.charAt(0)}

{data.name}

{formatDuration(data.durationMinutes)} {data.category?.name || 'General'}
{data.variable_pricing ? ( 'Variable' ) : ( formatPrice(data.price) )}
{data.deposit_amount && data.deposit_amount > 0 && (
{formatPrice(data.deposit_amount)} deposit
)}

{data.description}

Online booking available
{(data.resource_ids?.length || 0) > 0 && !data.all_resources && (
Specific staff only
)}

This is how your service will appear to customers on your booking page.

); }; export default CustomerPreview;