import { EnvironmentFilled } from '@ant-design/icons';
import { IChatItem } from '../ChatLogsType';

export const ChatLocation: React.FC<IChatItem> = (props) => {
  function content() {
    try {
      const msg = JSON.parse(props.chat?.content as string);

      return (
        <div style={{ display: 'flex', color: '#000' }}>
          <EnvironmentFilled style={{ fontSize: 40, color: '#FA9D3B', flexShrink: 0 }} />
          <div style={{ wordBreak: 'break-all', paddingLeft: 12 }}>
            <div>{msg.title}</div>
            <div>{msg.address}</div>
          </div>
        </div>
      );
    } catch (_e) {
      return (
        <div>
          <EnvironmentFilled style={{ fontSize: 40, color: '#FA9D3B', flexShrink: 0 }} />
          <div style={{ wordBreak: 'break-all', paddingLeft: 12 }}>{props.chat?.content}</div>
        </div>
      );
    }
  }

  return <>{content()}</>;
};
