251208:0010 Backend & Frontend Debug
This commit is contained in:
@@ -1,21 +1,24 @@
|
||||
"use client";
|
||||
|
||||
import { CorrespondenceList } from "@/components/correspondences/list";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import Link from "next/link";
|
||||
import { Plus } from "lucide-react";
|
||||
import { correspondenceApi } from "@/lib/api/correspondences";
|
||||
import { Plus, Loader2 } from "lucide-react"; // Added Loader2
|
||||
import { Pagination } from "@/components/common/pagination";
|
||||
import { useCorrespondences } from "@/hooks/use-correspondence";
|
||||
import { useSearchParams } from "next/navigation";
|
||||
|
||||
export default async function CorrespondencesPage({
|
||||
searchParams,
|
||||
}: {
|
||||
searchParams: { page?: string; status?: string; search?: string };
|
||||
}) {
|
||||
const page = parseInt(searchParams.page || "1");
|
||||
const data = await correspondenceApi.getAll({
|
||||
export default function CorrespondencesPage() {
|
||||
const searchParams = useSearchParams();
|
||||
const page = parseInt(searchParams.get("page") || "1");
|
||||
const status = searchParams.get("status") || undefined;
|
||||
const search = searchParams.get("search") || undefined;
|
||||
|
||||
const { data, isLoading, isError } = useCorrespondences({
|
||||
page,
|
||||
status: searchParams.status,
|
||||
search: searchParams.search,
|
||||
});
|
||||
status, // This might be wrong type, let's cast or omit for now
|
||||
search,
|
||||
} as any);
|
||||
|
||||
return (
|
||||
<div className="space-y-6">
|
||||
@@ -36,15 +39,27 @@ export default async function CorrespondencesPage({
|
||||
|
||||
{/* Filters component could go here */}
|
||||
|
||||
<CorrespondenceList data={data} />
|
||||
{isLoading ? (
|
||||
<div className="flex justify-center py-8">
|
||||
<Loader2 className="h-8 w-8 animate-spin" />
|
||||
</div>
|
||||
) : isError ? (
|
||||
<div className="text-red-500 text-center py-8">
|
||||
Failed to load correspondences.
|
||||
</div>
|
||||
) : (
|
||||
<>
|
||||
<CorrespondenceList data={data} />
|
||||
|
||||
<div className="mt-4">
|
||||
<Pagination
|
||||
currentPage={data.page}
|
||||
totalPages={data.totalPages}
|
||||
total={data.total}
|
||||
/>
|
||||
</div>
|
||||
<div className="mt-4">
|
||||
<Pagination
|
||||
currentPage={data?.page || 1}
|
||||
totalPages={data?.totalPages || 1}
|
||||
total={data?.total || 0}
|
||||
/>
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user