// Copyright 2021 Signal Messenger, LLC // SPDX-License-Identifier: AGPL-3.0-only import type { ReactNode } from 'react'; import React from 'react'; import type { LocalizerType } from '../../../../types/Util'; import { assertDev } 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 { ContactName } from '../../ContactName'; import { UserText } from '../../../UserText'; export type StatePropsType = { groupTitle: string; i18n: LocalizerType; makeRequest: () => void; onClose: () => void; requestState: RequestState; selectedContacts: ReadonlyArray; }; type PropsType = StatePropsType; export function ConfirmAdditionsModal({ groupTitle, i18n, makeRequest, onClose, requestState, selectedContacts, }: PropsType): JSX.Element { const firstContact = selectedContacts[0]; assertDev( 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('icu:AddGroupMembersModal--confirm-button--one'); } else { buttonContents = i18n('icu:AddGroupMembersModal--confirm-button--many'); } return (

{headerText}

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