import { Loader2Icon } from "lucide-react" import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table" import { Badge } from "@/components/ui/badge" import { Button } from "@/components/ui/button" import { Skeleton } from "@/components/ui/skeleton" import { useMyBorrows, useReturnBook } from "./hooks" import { formatDateTime } from "@/lib/formatters" export default function MyBorrowsPage() { const { data: records, isLoading, error } = useMyBorrows() const returnBook = useReturnBook() if (isLoading) return if (error) { return (
加载失败:{error instanceof Error ? error.message : "未知错误"}
) } const list = records ?? [] if (list.length === 0) { return (

暂无借阅记录

去书目页面借阅你感兴趣的图书吧

) } return (

我的借阅

书名 作者 借阅时间 归还时间 状态 操作 {list.map((r) => ( {r.bookBorrowVo.name} {r.bookBorrowVo.author} {formatDateTime(r.borrowTime)} {r.returnTime ? formatDateTime(r.returnTime) : "-"} {r.status === "BORROWED" ? "借阅中" : "已归还"} {r.status === "BORROWED" && ( )} ))}
) } function MyBorrowsSkeleton() { return (
{Array.from({ length: 5 }).map((_, i) => ( ))}
) }