blob: ee9daff7467669cffeae943ac2333a23b4157966 [file] [log] [blame]
Ziwei Wange8d77032023-01-11 15:57:38 -05001/*
2 * Copyright (C) 2022 Savoir-faire Linux Inc.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Affero General Public License as
6 * published by the Free Software Foundation; either version 3 of the
7 * License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Affero General Public License for more details.
13 *
14 * You should have received a copy of the GNU Affero General Public
15 * License along with this program. If not, see
16 * <https://www.gnu.org/licenses/>.
17 */
18import { ContactDetails as ContactDetailType } from 'jami-web-common';
19import { QRCodeCanvas } from 'qrcode.react';
20import { useTranslation } from 'react-i18next';
21
22import ConversationAvatar from './ConversationAvatar';
23import { InfosDialog } from './Dialog';
24import { DialogContentList } from './Dialog';
25
26interface ContactDetailDialogProps {
27 contactDetail: ContactDetailType;
28 open: boolean;
29 onClose: () => void;
30}
31
32const ContactDetailDialog = ({ contactDetail, open, onClose }: ContactDetailDialogProps) => {
33 const { t } = useTranslation();
34 const items = [
35 {
36 label: t('contact_details_name'),
37 value: contactDetail.id,
38 },
39 {
40 label: t('contact_details_identifier'),
41 value: contactDetail.id,
42 },
43 {
44 label: t('contact_details_qr_code'),
45 value: <QRCodeCanvas size={80} value={`${contactDetail.id}`} />,
46 },
47 ];
48
49 return (
50 <InfosDialog
51 open={open}
52 onClose={onClose}
53 icon={
54 <ConversationAvatar
55 sx={{ width: 'inherit', height: 'inherit' }}
56 displayName={contactDetail.id || contactDetail.id}
57 />
58 }
59 title={contactDetail.id}
60 content={<DialogContentList title={t('contact_details_dialog_title')} items={items} />}
61 />
62 );
63};
64
65export default ContactDetailDialog;