signal-desktop/ts/components/AnnouncementsOnlyGroupBanner.tsx

67 lines
1.8 KiB
TypeScript
Raw Normal View History

2021-07-20 20:18:35 +00:00
// Copyright 2021 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
import React, { useState } from 'react';
import type { ConversationType } from '../state/ducks/conversations';
2021-07-20 20:18:35 +00:00
import { Intl } from './Intl';
2021-11-02 23:01:13 +00:00
import type { LocalizerType, ThemeType } from '../types/Util';
2021-07-20 20:18:35 +00:00
import { Modal } from './Modal';
import { ConversationListItem } from './conversationList/ConversationListItem';
type PropsType = {
groupAdmins: Array<ConversationType>;
i18n: LocalizerType;
openConversation: (conversationId: string) => unknown;
2021-11-02 23:01:13 +00:00
theme: ThemeType;
2021-07-20 20:18:35 +00:00
};
export const AnnouncementsOnlyGroupBanner = ({
groupAdmins,
i18n,
openConversation,
2021-11-02 23:01:13 +00:00
theme,
2021-07-20 20:18:35 +00:00
}: PropsType): JSX.Element => {
const [isShowingAdmins, setIsShowingAdmins] = useState(false);
return (
<>
{isShowingAdmins && (
<Modal
i18n={i18n}
onClose={() => setIsShowingAdmins(false)}
title={i18n('AnnouncementsOnlyGroupBanner--modal')}
>
{groupAdmins.map(admin => (
<ConversationListItem
{...admin}
i18n={i18n}
onClick={() => {
openConversation(admin.id);
}}
draftPreview=""
lastMessage={undefined}
lastUpdated={undefined}
2021-11-02 23:01:13 +00:00
theme={theme}
2021-07-20 20:18:35 +00:00
/>
))}
</Modal>
)}
<div className="AnnouncementsOnlyGroupBanner__banner">
<Intl
i18n={i18n}
id="AnnouncementsOnlyGroupBanner--announcements-only"
components={[
<button
className="AnnouncementsOnlyGroupBanner__banner--admins"
type="button"
onClick={() => setIsShowingAdmins(true)}
>
{i18n('AnnouncementsOnlyGroupBanner--admins')}
</button>,
]}
/>
</div>
</>
);
};