// @flow
import type {DirectoryType} from './types'

export default function cleanContact(contact: DirectoryType): DirectoryType {
	const name = contact.displayName
	const title = contact.displayTitle
	const photo = contact.thumbnail
	const building = contact.building
	const room = contact.room ? contact.room : ''
	const office = building || room ? `${building} ${room}` : ''
	const officeHours = contact.officeHours
	const departments = contact.departments
	const phone = contact.officePhone
	const email = contact.email

	let profile = contact.profileUrl
	if (profile && !/^https?:\/\//u.test(profile)) {
		profile = `http://${profile}`
	}

	return {
		...contact,
		name,
		title,
		photo,
		office,
		officeHours,
		departments,
		phone,
		profile,
		email,
	}
}

@@ -28,16 +28,30 @@
 toryType
+, LocationType
 %7D from '
@@ -59,16 +59,16 @@
 /types'%0A
-
 %0Aexport 
@@ -245,152 +245,8 @@
 ail%0A
-%09const building = contact.building%0A%09const room = contact.room ? contact.room : ''%0A%09const office = building %7C%7C room ? %60$%7Bbuilding%7D $%7Broom%7D%60 : ''%0A
 %09con
@@ -388,16 +388,136 @@
 .email%0A%0A
+%09let locations = contact.campusLocations.map(location =%3E (%7B%0A%09%09display: location.display,%0A%09%09phone: location.phone,%0A%09%7D))%0A%0A
 %09let pro
@@ -680,22 +680,25 @@
 hoto,%0A%09%09
-office
+locations
 ,%0A%09%09offi

simplify contact locations (server handles most of that)