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

81 lines
2.3 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
};
2022-03-22 20:45:34 +00:00
export const ContactSpoofingReviewDialogPerson: FunctionComponent<
PropsType
> = ({ children, conversation, getPreferredBadge, i18n, onClick, theme }) => {
assert(
conversation.type === 'direct',
'<ContactSpoofingReviewDialogPerson> expected a direct conversation'
);
2021-04-21 16:31:12 +00:00
2022-03-22 20:45:34 +00:00
const contents = (
<>
<Avatar
{...conversation}
badge={getPreferredBadge(conversation.badges)}
conversationType={conversation.type}
size={AvatarSize.FIFTY_TWO}
className="module-ContactSpoofingReviewDialogPerson__avatar"
i18n={i18n}
theme={theme}
/>
<div className="module-ContactSpoofingReviewDialogPerson__info">
<ContactName
module="module-ContactSpoofingReviewDialogPerson__info__contact-name"
title={conversation.title}
2021-04-21 16:31:12 +00:00
/>
2022-03-22 20:45:34 +00:00
{conversation.phoneNumber ? (
2021-04-21 16:31:12 +00:00
<div className="module-ContactSpoofingReviewDialogPerson__info__property">
2022-03-22 20:45:34 +00:00
{conversation.phoneNumber}
2021-04-21 16:31:12 +00:00
</div>
2022-03-22 20:45:34 +00:00
) : null}
<div className="module-ContactSpoofingReviewDialogPerson__info__property">
<SharedGroupNames
i18n={i18n}
sharedGroupNames={conversation.sharedGroupNames || []}
/>
2021-04-21 16:31:12 +00:00
</div>
2022-03-22 20:45:34 +00:00
{children}
</div>
</>
);
2021-04-21 16:31:12 +00:00
2022-03-22 20:45:34 +00:00
if (onClick) {
2021-04-21 16:31:12 +00:00
return (
2022-03-22 20:45:34 +00:00
<button
type="button"
className="module-ContactSpoofingReviewDialogPerson"
onClick={onClick}
>
{contents}
</button>
2021-04-21 16:31:12 +00:00
);
2022-03-22 20:45:34 +00:00
}
return (
<div className="module-ContactSpoofingReviewDialogPerson">{contents}</div>
);
};