import { MyBetaModalFormProps, MyButtons } from '@/common';
import { Apis } from '@/gen/Apis';
import { message, Modal } from 'antd';

export default function MoveOut(props: MyBetaModalFormProps) {
  const handleRemoveClick = () => {
    Modal.confirm({
      title: '解除申请',
      content: '确定要解除人房关系吗？',
      okText: '确定',
      cancelText: '取消',
      // centered: true,
      onOk: async () => {
        try {
          await Apis.Archive.HouseRegisters.RemoveOwner({
            house_occupants_id: props?.item?.id,
          });
          props.reload?.();
          message.success('申请成功，等待审核');
        } catch (error) {
          message.error('操作失败');
        }
      },
    });
  };

  return (
    <MyButtons.Default
      title={props.title}
      size="small"
      type="link"
      onClick={handleRemoveClick}
      danger
    />
  );
}
