// Copyright 2020 Signal Messenger, LLC // SPDX-License-Identifier: AGPL-3.0-only import * as React from 'react'; import type { PropsType as ContactNameProps } from './ContactName'; import { ContactName } from './ContactName'; import { ConfirmationDialog } from '../ConfirmationDialog'; import { Intl } from '../Intl'; import type { LocalizerType } from '../../types/Util'; export enum MessageRequestState { blocking, deleting, unblocking, default, } export type Props = { acceptConversation(conversationId: string): unknown; blockAndReportSpam(conversationId: string): unknown; blockConversation(conversationId: string): unknown; conversationId: string; conversationType: 'group' | 'direct'; deleteConversation(conversationId: string): unknown; i18n: LocalizerType; isBlocked?: boolean; onChangeState(state: MessageRequestState): unknown; state: MessageRequestState; } & Omit; export function MessageRequestActionsConfirmation({ acceptConversation, blockAndReportSpam, blockConversation, conversationId, conversationType, deleteConversation, i18n, onChangeState, state, title, }: Props): JSX.Element | null { if (state === MessageRequestState.blocking) { return ( { onChangeState(MessageRequestState.default); }} title={ ]} /> } actions={[ ...(conversationType === 'direct' ? [ { text: i18n('MessageRequests--block-and-report-spam'), action: () => blockAndReportSpam(conversationId), style: 'negative' as const, }, ] : []), { text: i18n('MessageRequests--block'), action: () => blockConversation(conversationId), style: 'negative', }, ]} > {i18n(`MessageRequests--block-${conversationType}-confirm-body`)} ); } if (state === MessageRequestState.unblocking) { return ( { onChangeState(MessageRequestState.default); }} title={ , }} /> } actions={[ { text: i18n('MessageRequests--unblock'), action: () => acceptConversation(conversationId), style: 'affirmative', }, ]} > {i18n(`MessageRequests--unblock-${conversationType}-confirm-body`)} ); } if (state === MessageRequestState.deleting) { return ( { onChangeState(MessageRequestState.default); }} title={ ]} /> } actions={[ { text: i18n(`MessageRequests--delete-${conversationType}`), action: () => deleteConversation(conversationId), style: 'negative', }, ]} > {i18n(`MessageRequests--delete-${conversationType}-confirm-body`)} ); } return null; }