// Copyright 2024 Signal Messenger, LLC // SPDX-License-Identifier: AGPL-3.0-only import React, { useState } from 'react'; import type { LocalizerType } from '../../types/I18N'; import { SystemMessage } from './SystemMessage'; import { Button, ButtonSize, ButtonVariant } from '../Button'; import { MessageRequestState } from './MessageRequestActionsConfirmation'; import { SafetyTipsModal } from '../SafetyTipsModal'; import { MessageRequestResponseEvent } from '../../types/MessageRequestResponseEvent'; export type MessageRequestResponseNotificationData = { messageRequestResponseEvent: MessageRequestResponseEvent; }; export type MessageRequestResponseNotificationProps = MessageRequestResponseNotificationData & { i18n: LocalizerType; isBlocked: boolean; isGroup: boolean; onOpenMessageRequestActionsConfirmation(state: MessageRequestState): void; }; export function MessageRequestResponseNotification({ i18n, isBlocked, isGroup, messageRequestResponseEvent: event, onOpenMessageRequestActionsConfirmation, }: MessageRequestResponseNotificationProps): JSX.Element | null { const [isSafetyTipsModalOpen, setIsSafetyTipsModalOpen] = useState(false); return ( <> {event === MessageRequestResponseEvent.ACCEPT && ( { onOpenMessageRequestActionsConfirmation( MessageRequestState.acceptedOptions ); }} > {i18n( 'icu:MessageRequestResponseNotification__Button--Options' )} ) } /> )} {event === MessageRequestResponseEvent.BLOCK && ( )} {event === MessageRequestResponseEvent.UNBLOCK && ( )} {event === MessageRequestResponseEvent.SPAM && ( { setIsSafetyTipsModalOpen(true); }} > {i18n( 'icu:MessageRequestResponseNotification__Button--LearnMore' )} } /> )} {isSafetyTipsModalOpen && ( { setIsSafetyTipsModalOpen(false); }} /> )} ); }