2021-04-21 16:31:12 +00:00
|
|
|
// Copyright 2021 Signal Messenger, LLC
|
|
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
2022-11-18 00:45:19 +00:00
|
|
|
import type { ReactNode } from 'react';
|
2021-10-26 19:15:33 +00:00
|
|
|
import React from 'react';
|
2021-04-21 16:31:12 +00:00
|
|
|
|
2021-10-26 19:15:33 +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';
|
2022-09-15 19:17:15 +00:00
|
|
|
import { assertDev } from '../../util/assert';
|
2021-04-21 16:31:12 +00:00
|
|
|
|
|
|
|
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-11-18 00:45:19 +00:00
|
|
|
export function ContactSpoofingReviewDialogPerson({
|
|
|
|
children,
|
|
|
|
conversation,
|
|
|
|
getPreferredBadge,
|
|
|
|
i18n,
|
|
|
|
onClick,
|
|
|
|
theme,
|
|
|
|
}: PropsType): JSX.Element {
|
2022-09-15 19:17:15 +00:00
|
|
|
assertDev(
|
2022-03-22 20:45:34 +00:00
|
|
|
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}
|
2022-12-09 20:37:45 +00:00
|
|
|
size={AvatarSize.FORTY_EIGHT}
|
2022-03-22 20:45:34 +00:00
|
|
|
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>
|
|
|
|
);
|
2022-11-18 00:45:19 +00:00
|
|
|
}
|