import 'dayjs/locale/ru'; // load on demand

import _ from 'lodash';
import { BsTrash3 } from 'react-icons/bs';

import { ShmChannelMessageType } from '../../../api/types';
import FileTypeIcon from './FileTypeIcon';

const MessageReplayItem = ({ msg, onClick }: {
    msg: ShmChannelMessageType
    onClick: () => void;
}) => {


    const isDeleted = !!msg.deleted;

    return (
        <div className='mb-2 mt-2 border-l-2 border-gray-500 pl-2'>

            <div
                onClick={(e) => {
                    e.stopPropagation();
                    // e.preventDefault();

                    onClick();
                }}
                id={`replay-msg-${msg._id}`}>




                {isDeleted ? <>

                    <div className='opacity-80 text-sm flex items-center gap-2'><BsTrash3 className='w-4 h-4' /> Сообщение удалено</div>
                </> : <>

                    <div>{msg.text}</div>


                    {msg.voice?.url && <div
                        className='text-sm '
                    >Аудио сообщение</div>}

                    {msg.attachments?.map((attachment) => {

                        return <div

                            className="cursor-pointer active:opacity-50 flex items-center space-x-2"
                        >


                            <FileTypeIcon doc={attachment} />

                            <div>{attachment.name}</div>

                        </div>

                    })}
                </>}


            </div>




        </div>

    );
};

export default MessageReplayItem;
