import { FC } from 'react';

import { IconMessages } from '@material-hu/icons/tabler';
import CircularProgress from '@material-hu/mui/CircularProgress';
import Stack from '@material-hu/mui/Stack';

import { useConversationList } from 'src/pages/dashboard/Conversations/hooks/useConversationsQueries';
import { useLokaliseTranslation } from 'src/utils/i18n';

import InfoMessage from './components/shared/InfoMessage';

const ConversationsEmpty: FC = () => {
  const { t } = useLokaliseTranslation('chat');

  const { conversations, isLoading } = useConversationList();

  const hasConversations = conversations?.length;

  if (isLoading) {
    return (
      <Stack
        sx={{
          flexDirection: 'row',
          justifyContent: 'center',
          alignItems: 'center',
          width: '100%',
          height: '100%',
        }}
      >
        <CircularProgress />
      </Stack>
    );
  }

  return (
    <InfoMessage
      title={t(`${hasConversations ? 'select_chat' : 'no_messages_yet'}`)}
      subtitle={t(
        `${hasConversations ? 'select_chat_description' : 'no_messages_yet_description'}`,
      )}
      Icon={IconMessages}
    />
  );
};

export default ConversationsEmpty;
