Repository URL to install this package:
|
Version:
1.1.3 ▾
|
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