import React from 'react';
import type { MessageBlock } from '@/store/commStore';

interface VideoBlockProps {
  block: MessageBlock;
}

const VideoBlock: React.FC<VideoBlockProps> = ({ block }) => {
  const { url, thumbnail } = block.block_data;

  if (!url) {
    return null;
  }

  const poster: string | undefined = typeof thumbnail === 'string' ? thumbnail : undefined;

  return (
    <div className="space-y-1">
      <video
        src={url}
        controls
        poster={poster}
        className="w-full rounded-lg"
        preload="metadata"
      />
    </div>
  );
};

export default VideoBlock;
