blob: d26785e4f5ec28ff7c4b0f4a30e08f95d35106f3 [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 {
Ziwei Wang046fb202023-01-17 18:27:17 -050027 contactDetail: ContactDetailType | undefined;
Ziwei Wange8d77032023-01-11 15:57:38 -050028 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'),
Ziwei Wang046fb202023-01-17 18:27:17 -050037 value: contactDetail?.id,
Ziwei Wange8d77032023-01-11 15:57:38 -050038 },
39 {
40 label: t('contact_details_identifier'),
Ziwei Wang046fb202023-01-17 18:27:17 -050041 value: contactDetail?.id,
Ziwei Wange8d77032023-01-11 15:57:38 -050042 },
43 {
44 label: t('contact_details_qr_code'),
Ziwei Wang046fb202023-01-17 18:27:17 -050045 value: <QRCodeCanvas size={80} value={`${contactDetail?.id}`} />,
Ziwei Wange8d77032023-01-11 15:57:38 -050046 },
47 ];
48
49 return (
50 <InfosDialog
51 open={open}
52 onClose={onClose}
53 icon={
54 <ConversationAvatar
55 sx={{ width: 'inherit', height: 'inherit' }}
Ziwei Wang046fb202023-01-17 18:27:17 -050056 displayName={contactDetail?.id || contactDetail?.id}
Ziwei Wange8d77032023-01-11 15:57:38 -050057 />
58 }
Ziwei Wang046fb202023-01-17 18:27:17 -050059 title={contactDetail?.id || 'No contact selected'}
Ziwei Wange8d77032023-01-11 15:57:38 -050060 content={<DialogContentList title={t('contact_details_dialog_title')} items={items} />}
61 />
62 );
63};
64
65export default ContactDetailDialog;