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

86 lines
2.3 KiB
TypeScript
Raw Normal View History

2021-04-21 11:31:12 -05:00
// Copyright 2021 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
2022-11-17 16:45:19 -08:00
import type { ReactNode } from 'react';
import React from 'react';
2021-04-21 11:31:12 -05:00
import type { ConversationType } from '../../state/ducks/conversations';
2021-11-30 04:07:24 -06:00
import type { LocalizerType, ThemeType } from '../../types/Util';
import type { PreferredBadgeSelectorType } from '../../state/selectors/badges';
import { assertDev } from '../../util/assert';
2021-04-21 11:31:12 -05:00
import { Avatar, AvatarSize } from '../Avatar';
import { ContactName } from './ContactName';
import { SharedGroupNames } from '../SharedGroupNames';
type PropsType = {
children?: ReactNode;
conversation: ConversationType;
2021-11-30 04:07:24 -06:00
getPreferredBadge: PreferredBadgeSelectorType;
2021-04-21 11:31:12 -05:00
i18n: LocalizerType;
onClick?: () => void;
2021-11-30 04:07:24 -06:00
theme: ThemeType;
2021-04-21 11:31:12 -05:00
};
2022-11-17 16:45:19 -08:00
export function ContactSpoofingReviewDialogPerson({
children,
conversation,
getPreferredBadge,
i18n,
onClick,
theme,
}: PropsType): JSX.Element {
assertDev(
2022-03-22 13:45:34 -07:00
conversation.type === 'direct',
'<ContactSpoofingReviewDialogPerson> expected a direct conversation'
);
2021-04-21 11:31:12 -05:00
2022-03-22 13:45:34 -07:00
const contents = (
<>
<Avatar
{...conversation}
badge={getPreferredBadge(conversation.badges)}
conversationType={conversation.type}
2022-12-09 13:37:45 -07:00
size={AvatarSize.FORTY_EIGHT}
2022-03-22 13:45:34 -07: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 11:31:12 -05:00
/>
2022-03-22 13:45:34 -07:00
{conversation.phoneNumber ? (
2021-04-21 11:31:12 -05:00
<div className="module-ContactSpoofingReviewDialogPerson__info__property">
2022-03-22 13:45:34 -07:00
{conversation.phoneNumber}
2021-04-21 11:31:12 -05:00
</div>
2022-03-22 13:45:34 -07:00
) : null}
<div className="module-ContactSpoofingReviewDialogPerson__info__property">
<SharedGroupNames
i18n={i18n}
sharedGroupNames={conversation.sharedGroupNames || []}
/>
2021-04-21 11:31:12 -05:00
</div>
2022-03-22 13:45:34 -07:00
{children}
</div>
</>
);
2021-04-21 11:31:12 -05:00
2022-03-22 13:45:34 -07:00
if (onClick) {
2021-04-21 11:31:12 -05:00
return (
2022-03-22 13:45:34 -07:00
<button
type="button"
className="module-ContactSpoofingReviewDialogPerson"
onClick={onClick}
>
{contents}
</button>
2021-04-21 11:31:12 -05:00
);
2022-03-22 13:45:34 -07:00
}
return (
<div className="module-ContactSpoofingReviewDialogPerson">{contents}</div>
);
2022-11-17 16:45:19 -08:00
}