import React from 'react';
import { Room as MatrixRoom } from 'matrix-js-sdk';
import { useNavigate } from 'react-router-dom';
import { useTranslation } from 'react-i18next';
import { Button, Text } from 'folds';
import { getDirectRoomPath } from '../../pathUtils';

type BotOpenChatActionProps = {
  room: MatrixRoom;
};

// Shared «escape hatch» CTA used by BotKicked, BotInvitePending and
// BotUnsafeRoom. Drops the user into the underlying control DM via /direct/
// so they can see members, accept invites, kick offenders or read raw bot
// replies — anything Bots tab refuses to surface.
export function BotOpenChatAction({ room }: BotOpenChatActionProps) {
  const { t } = useTranslation();
  const navigate = useNavigate();

  return (
    <Button
      variant="Secondary"
      fill="Soft"
      size="500"
      radii="400"
      onClick={() => navigate(getDirectRoomPath(room.roomId))}
    >
      <Text size="B500">{t('Bots.open_chat')}</Text>
    </Button>
  );
}
