signal-desktop/ts/components/conversation/ContactSpoofingReviewDialogPerson.tsx

80 lines
2.4 KiB
TypeScript
Raw Normal View History

2021-04-21 16:31:12 +00:00
// Copyright 2021 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
import type { FunctionComponent, ReactNode } from 'react';
import React from 'react';
2021-04-21 16:31:12 +00:00
import type { ConversationType } from '../../state/ducks/conversations';
2021-11-30 10:07:24 +00:00
import type { LocalizerType, ThemeType } from '../../types/Util';
import type { PreferredBadgeSelectorType } from '../../state/selectors/badges';
2021-04-21 16:31:12 +00:00
import { assert } from '../../util/assert';
import { Avatar, AvatarSize } from '../Avatar';
import { ContactName } from './ContactName';
import { SharedGroupNames } from '../SharedGroupNames';
type PropsType = {
children?: ReactNode;
conversation: ConversationType;
2021-11-30 10:07:24 +00:00
getPreferredBadge: PreferredBadgeSelectorType;
2021-04-21 16:31:12 +00:00
i18n: LocalizerType;
onClick?: () => void;
2021-11-30 10:07:24 +00:00
theme: ThemeType;
2021-04-21 16:31:12 +00:00
};
2021-11-11 22:43:05 +00:00
export const ContactSpoofingReviewDialogPerson: FunctionComponent<PropsType> =
2021-11-30 10:07:24 +00:00
({ children, conversation, getPreferredBadge, i18n, onClick, theme }) => {
2021-11-11 22:43:05 +00:00
assert(
conversation.type === 'direct',
'<ContactSpoofingReviewDialogPerson> expected a direct conversation'
);
2021-04-21 16:31:12 +00:00
2021-11-11 22:43:05 +00:00
const contents = (
<>
<Avatar
{...conversation}
2021-11-30 10:07:24 +00:00
badge={getPreferredBadge(conversation.badges)}
2021-11-11 22:43:05 +00:00
conversationType={conversation.type}
size={AvatarSize.FIFTY_TWO}
className="module-ContactSpoofingReviewDialogPerson__avatar"
i18n={i18n}
2021-11-30 10:07:24 +00:00
theme={theme}
2021-04-21 16:31:12 +00:00
/>
2021-11-11 22:43:05 +00:00
<div className="module-ContactSpoofingReviewDialogPerson__info">
<ContactName
module="module-ContactSpoofingReviewDialogPerson__info__contact-name"
title={conversation.title}
/>
{conversation.phoneNumber ? (
<div className="module-ContactSpoofingReviewDialogPerson__info__property">
{conversation.phoneNumber}
</div>
) : null}
2021-04-21 16:31:12 +00:00
<div className="module-ContactSpoofingReviewDialogPerson__info__property">
2021-11-11 22:43:05 +00:00
<SharedGroupNames
i18n={i18n}
sharedGroupNames={conversation.sharedGroupNames || []}
/>
2021-04-21 16:31:12 +00:00
</div>
2021-11-11 22:43:05 +00:00
{children}
2021-04-21 16:31:12 +00:00
</div>
2021-11-11 22:43:05 +00:00
</>
);
if (onClick) {
return (
<button
type="button"
className="module-ContactSpoofingReviewDialogPerson"
onClick={onClick}
>
{contents}
</button>
);
}
2021-04-21 16:31:12 +00:00
return (
2021-11-11 22:43:05 +00:00
<div className="module-ContactSpoofingReviewDialogPerson">{contents}</div>
2021-04-21 16:31:12 +00:00
);
2021-11-11 22:43:05 +00:00
};