Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
@skava/utils / src / address / fromAddressToString.ts
Size: Mime:
import { isObjWithKeys } from 'exotic'
import { AddressType } from './typings'

function fromAddressToString(shippingAddress: AddressType): string {
  if (isObjWithKeys(shippingAddress)) {
    const {
      firstName,
      lastName,
      addressLine1,
      addressLine2,
      city,
      state,
      country,
      postalCode,
      phoneNumber,
      telephone,
      email,
    } = shippingAddress

    const addressString = `${firstName},${lastName},${addressLine1},${addressLine2},${city},${state},${country},${postalCode},
    ${telephone ? telephone : phoneNumber},${email}`

    return addressString
  } else {
    if (process.env.NODE_ENV !== 'production') {
      console.warn('[utils] non object with keys given to fromAddressToString')
    }
    return ''
  }
}

export { fromAddressToString }
export default fromAddressToString