45 lines
1.0 KiB
TypeScript
45 lines
1.0 KiB
TypeScript
import type { Contact } from "@/lib/compose-context"
|
|
|
|
export interface ContactAddress {
|
|
street?: string
|
|
city?: string
|
|
region?: string
|
|
postalCode?: string
|
|
country?: string
|
|
label: string
|
|
}
|
|
|
|
export interface FullContact {
|
|
id: string
|
|
namePrefix?: string
|
|
firstName: string
|
|
middleName?: string
|
|
lastName: string
|
|
nameSuffix?: string
|
|
phoneticFirstName?: string
|
|
phoneticLastName?: string
|
|
nicknames?: string[]
|
|
company?: string
|
|
department?: string
|
|
jobTitle?: string
|
|
emails: { value: string; label: string }[]
|
|
phones: { value: string; label: string }[]
|
|
addresses?: ContactAddress[]
|
|
birthday?: { day?: number; month?: number; year?: number }
|
|
notes?: string
|
|
labels?: string[]
|
|
avatarUrl?: string
|
|
createdAt: number
|
|
updatedAt: number
|
|
}
|
|
|
|
export function fullContactDisplayName(c: FullContact): string {
|
|
return `${c.firstName} ${c.lastName}`.trim()
|
|
}
|
|
|
|
export function toComposeContact(c: FullContact): Contact {
|
|
const name = fullContactDisplayName(c)
|
|
const email = c.emails[0]?.value ?? ""
|
|
return { name, email }
|
|
}
|