// Copyright 2021 Signal Messenger, LLC // SPDX-License-Identifier: AGPL-3.0-only import React from 'react'; import { isSafetyNumberNotAvailable } from '../util/isSafetyNumberNotAvailable'; import { Modal } from './Modal'; import type { PropsType as SafetyNumberViewerPropsType } from './SafetyNumberViewer'; import { SafetyNumberViewer } from './SafetyNumberViewer'; import { SafetyNumberNotReady } from './SafetyNumberNotReady'; type PropsType = { toggleSafetyNumberModal: () => unknown; } & Omit; export function SafetyNumberModal({ i18n, toggleSafetyNumberModal, ...safetyNumberViewerProps }: PropsType): JSX.Element | null { const { contact } = safetyNumberViewerProps; let title: string | undefined; let content: JSX.Element; let hasXButton = true; if (isSafetyNumberNotAvailable(contact)) { content = ( toggleSafetyNumberModal()} /> ); hasXButton = false; } else { title = i18n('icu:SafetyNumberModal__title'); content = ( ); } return ( {content} ); }