import { Address, NominatimReverseGeocodingResponse } from '../../types/Types';
import { formatAddress, formatSelectedAddress } from '../utils/formatAddress';

interface AddressDisplayProps {
    selectedAddress: NominatimReverseGeocodingResponse | null;
    existingAddress?: Address | null;
}

export const AddressDisplay = ({ selectedAddress, existingAddress }: AddressDisplayProps) => {
    const displayText = selectedAddress
        ? formatSelectedAddress(selectedAddress)
        : existingAddress
            ? formatAddress(existingAddress)
            : 'آدرس را به صورت دستی وارد کنید';

    return (
        <div className='px-4 mt-2 bg-container'>
            <span className='text-sm'>
                {displayText}
            </span>
            <hr className='border border-border mt-3 mb-10' />
        </div>
    );
};

