import { FileTextFilled } from '@ant-design/icons'; import { useRef, useState } from 'react'; import { IChatItem } from '../ChatLogsType'; import styles from './index.module.scss'; export const ChatVoice: React.FC = (props) => { const [open, setOpen] = useState(false); const audioRef = useRef(); function content() { try { const msg = JSON.parse(props.chat?.content as string); return (
{ const audios = document.querySelectorAll('audio'); if (audios) { audios.forEach((el) => { el.pause(); }); } audioRef.current.play().catch((error: any) => { console.log(error); }); setOpen(true); }} > {msg.play_length}"
); } catch (_e) { return (
{props.chat?.content}
); } } return ( <> {props.from?.user_id == props.chat?.msg_from ? (
{props.from?.name}
{content()}
{props.from?.name[0]}
) : (
{props.to?.cust_info.name}
{content()}
)} ); };