import React from 'react' import classnames from 'classnames' import { buildAriaProps, buildCss, buildDataProps, buildHtmlProps } from '../utilities/props' import { globalProps } from '../utilities/globalProps' import Caption from '../pb_caption/_caption' import Contact from '../pb_contact/_contact' import Person from '../pb_person/_person' import { GenericObject } from '../types' type ContactItem = { contactType: string, contactValue: string, contactDetail: string, } type PersonContactProps = { aria?: { [key: string]: string }, className?: string | string[], data?: GenericObject, firstName: string, htmlOptions?: {[key: string]: string | number | boolean | (() => void)}, id?: string, lastName: string, contacts?: ContactItem[], } const PersonContact = (props: PersonContactProps): React.ReactElement => { const { aria = {}, className, contacts = [], data = {}, firstName, htmlOptions = {}, id, lastName, } = props const ariaProps = buildAriaProps(aria) const dataProps = buildDataProps(data) const htmlProps = buildHtmlProps(htmlOptions) const classes = classnames( buildCss('pb_person_contact_kit'), globalProps(props), className ) const wrongContacts = () => ( contacts.filter((contactObject) => ( contactObject.contactType === 'wrong-phone' )) ) const validContacts = () => ( contacts.filter((contactObject) => ( contactObject.contactType !== 'wrong-phone' )) ) return (
{validContacts().map((contactObject, index) => ( ))} {wrongContacts().map((contactObject, index) => (
))}
) } export default PersonContact