// SPDX-FileCopyrightText: © 2017 EteSync Authors
// SPDX-License-Identifier: AGPL-3.0-only
import * as React from "react";
import moment from "moment";
import { List, ListItem, ListDivider as Divider } from "../widgets/List";
import IconHome from "@material-ui/icons/Home";
import IconDate from "@material-ui/icons/DateRange";
import CommunicationCall from "@material-ui/icons/Call";
import CommunicationChatBubble from "@material-ui/icons/ChatBubble";
import CommunicationEmail from "@material-ui/icons/Email";
import CopyIcon from "../icons/Copy";
import PimItemHeader from "../components/PimItemHeader";
import { ContactType } from "../pim-types";
import { IconButton, Avatar } from "@material-ui/core";
class Contact extends React.PureComponent {
public props: {
item?: ContactType;
};
public render() {
if (this.props.item === undefined) {
throw Error("Contact should be defined!");
}
const contact = this.props.item;
const name = contact.fn;
const revProp = contact.comp.getFirstProperty("rev");
const lastModified = (revProp) ?
"Modified: " + moment(revProp.getFirstValue().toJSDate()).format("LLLL") : undefined;
const lists = [];
function getAllType(
propName: string,
props_: any,
valueToHref?: (value: string, type: string) => string,
primaryTransform?: (value: string, type: string) => string,
secondaryTransform?: (value: string, type: string) => string) {
return contact.comp.getAllProperties(propName).map((prop, idx) => {
const type = prop.toJSON()[1].type;
const values = prop.getValues().map((val) => {
const primaryText = primaryTransform ? primaryTransform(val, type) : val;
const clipboardButton = (
{note}
{items}