/** * External dependencies */ import { useState } from '@wordpress/element'; /** * WordPress dependencies */ import { useDispatch, useSelect } from '@wordpress/data'; import { SandBox } from '@wordpress/components'; import { __ } from '@wordpress/i18n'; /** * SolidWP dependencies */ import { Button, Text, TextSize, TextVariant, TextWeight } from '@ithemes/ui'; /** * Internal dependencies */ import ConfirmationDialog from "../../../components/confirmation-dialog"; import { STORE_NAME as LogsStore } from '../../../data/src/logs/constants'; import { Logo } from '../../../components/icons'; import { Body, Empty, Header, StyledNotice, StyledSurface } from './styles'; // Fix for iframe height miscalculation. const sandBoxStyle = ` html, body, body > div { height: auto !important; } `; /** * Component for displaying the details of a log. */ function LogDetail() { const { selectedLog, currentPage } = useSelect( ( select ) => ( { selectedLog: select( LogsStore ).getSelectedLog(), currentPage: select( LogsStore ).getCurrentPage(), } ), [] ); const { deleteLog } = useDispatch( LogsStore ); const [ isDialogOpen, setIsDialogOpen ] = useState( false ); const [ isDeleting, setIsDeleting ] = useState( false ) // Handle delete confirmation const handleDelete = () => { setIsDialogOpen( true ); }; // Confirm deletion and proceed with log deletion const handleConfirmDelete = async () => { setIsDeleting( true ) await deleteLog( [ selectedLog.mail_id ], currentPage ); setIsDialogOpen( false ); setIsDeleting( false ) }; // Cancel deletion const handleCancelDelete = () => { setIsDialogOpen(false); }; if ( selectedLog === null || selectedLog === undefined ) { return ( ); } return ( <> { selectedLog.error !== null && selectedLog.error.length > 0 && ( ) }
{ selectedLog.to } { selectedLog.timestamp }
{ __( 'Subject', 'LION' ) }:{ ' ' } { selectedLog.subject } { __( 'Body', 'LION' ) } { isDialogOpen && ( ) } ); } export default LogDetail;