'use client'; import { FileText, Plus, X } from 'lucide-react'; import * as React from 'react'; import { ReportCard } from '@/components/reports/report-card'; import { REPORT_TYPES } from '@/components/reports/report-type-badge'; import { Button } from '@/components/ui/button'; import { Link } from '@/i18n/navigation'; import { useReportsList, useDeleteReport } from '@/lib/hooks/use-reports'; import type { ReportType } from '@/lib/reports-api'; const PAGE_SIZE = 12; export default function BaoCaoPage() { const [typeFilter, setTypeFilter] = React.useState(); const [page, setPage] = React.useState(1); const offset = (page - 1) * PAGE_SIZE; const { data, isLoading, isError } = useReportsList({ type: typeFilter, limit: PAGE_SIZE, offset, }); const deleteReport = useDeleteReport(); const totalPages = data ? Math.ceil(data.total / PAGE_SIZE) : 0; const handleTypeChange = (type: ReportType | undefined) => { setTypeFilter(type); setPage(1); window.scrollTo({ top: 0, behavior: 'smooth' }); }; const handlePageChange = (newPage: number) => { setPage(newPage); window.scrollTo({ top: 0, behavior: 'smooth' }); }; const handleDelete = (id: string) => { deleteReport.mutate(id); }; return (
{/* Page header */}

Báo cáo

Quản lý và tạo báo cáo phân tích bất động sản

{/* Type filter tabs */}
{REPORT_TYPES.map(({ value, label }) => ( ))} {typeFilter && ( )}
{/* Results */}
{isLoading ? (
{Array.from({ length: 6 }).map((_, i) => (
))}
) : isError ? (

Không thể tải danh sách báo cáo. Vui lòng thử lại.

) : data && data.data.length > 0 ? ( <>

{data.total} báo cáo

{data.data.map((report) => ( ))}
{/* Pagination */} {totalPages > 1 && (
Trang {page} / {totalPages}
)} ) : (

Chưa có báo cáo nào

Tạo báo cáo phân tích đầu tiên của bạn

)}
); }