/**
 * filekorolheader: 企业审核分页组件 - 分页控制界面
 * 功能：分页导航、页面跳转、分页信息展示
 * 路径：/central-config/tenant/enterprise-audit/components/AuditPagination
 * 规范：遵循crop-x/docs/开发项目规范.md，使用shadcn/ui组件，TypeScript类型安全
 */

import { Button } from '@/components/ui/button';
import { Input } from '@/components/ui/input';
import { ChevronLeft, ChevronRight } from 'lucide-react';

interface PaginationInfo {
  page: number;
  size: number;
  total: number;
  totalPages: number;
  hasNext: boolean;
  hasPrev: boolean;
}

interface AuditPaginationProps {
  pagination: PaginationInfo;
  onPageChange: (page: number) => void;
  loading?: boolean;
}

export function AuditPagination({
  pagination,
  onPageChange,
  loading = false
}: AuditPaginationProps) {
  const { page, size, total, totalPages, hasNext, hasPrev } = pagination;

  if (total === 0) return null;

  return (
    <div className="flex items-center justify-between">
      <div className="text-sm text-muted-foreground">
        显示第 {(page - 1) * size + 1} - {Math.min(page * size, total)} 条，共 {total} 条记录
      </div>
      <div className="flex items-center gap-2">
        <Button
          variant="outline"
          size="sm"
          onClick={() => onPageChange(page - 1)}
          disabled={!hasPrev || loading}
        >
          <ChevronLeft className="w-4 h-4" />
          上一页
        </Button>

        <div className="flex items-center gap-1">
          <span className="text-sm text-muted-foreground">第</span>
          <Input
            type="number"
            min={1}
            max={totalPages}
            value={page}
            onChange={(e) => {
              const newPage = parseInt(e.target.value);
              if (!isNaN(newPage)) {
                onPageChange(newPage);
              }
            }}
            className="w-16 h-8 text-center"
            disabled={loading}
          />
          <span className="text-sm text-muted-foreground">/ {totalPages} 页</span>
        </div>

        <Button
          variant="outline"
          size="sm"
          onClick={() => onPageChange(page + 1)}
          disabled={!hasNext || loading}
        >
          下一页
          <ChevronRight className="w-4 h-4" />
        </Button>
      </div>
    </div>
  );
}