import React from 'react';
import { Empty, Table } from 'antd';

export const RoomsTable: React.FC<{
  columns: any[];
  data: any[];
  loading: boolean;
  selectedRowKeys: number[];
  onSelect: (keys: number[]) => void;
}> = ({ columns, data, loading, selectedRowKeys, onSelect }) => {
  return (
    <>
      <Table
        columns={columns}
        dataSource={data}
        rowKey="id"
        scroll={{ x: 1200 }}
        loading={loading}
        locale={{ emptyText: <Empty description="暂无数据" /> }}
        pagination={{
          defaultPageSize: 20,
          showSizeChanger: true,
          pageSizeOptions: [20, 50, 100],
          showTotal: (total) => `共 ${total} 间`,
        }}
        rowClassName={(record) => (record.status === 'archived' ? 'archived-row' : '')}
        rowSelection={{
          selectedRowKeys,
          onChange: (keys) => onSelect(keys as number[]),
        }}
      />
      <style>{`.archived-row { opacity: 0.6; background: #fafafa !important; }`}</style>
    </>
  );
};
