import React, {memo} from 'react';
import {ChatListItem, ChatType} from '@modules/chat/interfaces';

import {RegularChatRow} from './components/RegularChatRow';
import {TicketChatRow} from './components/TicketChatRow';
import {GroupChatRow} from './components/GroupChatRow';

interface Props {
  chat: ChatListItem;
  disabledActions?: boolean;
  isTicketAgent?: boolean;
}

function ChatRow({chat, disabledActions, isTicketAgent}: Props) {
  return chat.chatType === ChatType.REGULAR_GROUP ? (
    <GroupChatRow chat={chat} disabledActions={disabledActions} />
  ) : chat.chatType === ChatType.REGULAR ? (
    chat.chat.lastMessage ? (
      <RegularChatRow chat={chat} disabledActions={disabledActions} />
    ) : null
  ) : chat.chatType === ChatType.TICKET ? (
    <TicketChatRow chat={chat} isTicketAgent={isTicketAgent} />
  ) : null;
}

export default memo(ChatRow);

export {CHAT_ROW_HEIGHT} from './constants';
