// Copyright 2021 Signal Messenger, LLC // SPDX-License-Identifier: AGPL-3.0-only import type { FunctionComponent, ReactNode } from 'react'; import React from 'react'; import type { LocalizerType } from '../../../../types/Util'; import { assert } from '../../../../util/assert'; import { ModalHost } from '../../../ModalHost'; import { Button, ButtonVariant } from '../../../Button'; import { Spinner } from '../../../Spinner'; import type { ConversationType } from '../../../../state/ducks/conversations'; import { RequestState } from '../util'; import { Intl } from '../../../Intl'; import { Emojify } from '../../Emojify'; import { ContactName } from '../../ContactName'; export type StatePropsType = { groupTitle: string; i18n: LocalizerType; makeRequest: () => void; onClose: () => void; requestState: RequestState; selectedContacts: ReadonlyArray; }; type PropsType = StatePropsType; export const ConfirmAdditionsModal: FunctionComponent = ({ groupTitle, i18n, makeRequest, onClose, requestState, selectedContacts, }) => { const firstContact = selectedContacts[0]; assert( firstContact, 'Expected at least one conversation to be selected but none were picked' ); const groupTitleNode: JSX.Element = ; let headerText: ReactNode; if (selectedContacts.length === 1) { headerText = ( , group: groupTitleNode, }} /> ); } else { headerText = ( ); } let buttonContents: ReactNode; if (requestState === RequestState.Active) { buttonContents = ( ); } else if (selectedContacts.length === 1) { buttonContents = i18n('AddGroupMembersModal--confirm-button--one'); } else { buttonContents = i18n('AddGroupMembersModal--confirm-button--many'); } return (

{headerText}

{requestState === RequestState.InactiveWithError && (
{i18n('updateGroupAttributes__error-message')}
)}
); };