feat: add pagination music

This commit is contained in:
2026-06-12 15:34:19 +03:30
parent 1b2d2dec7d
commit 60a054710a
3 changed files with 119 additions and 3 deletions
+39 -1
View File
@@ -8,7 +8,7 @@ import {
type TextareaHTMLAttributes,
useEffect,
} from "react";
import { cn } from "@/lib/utils";
import { cn, toFa } from "@/lib/utils";
import { CloseIcon, SpinnerIcon } from "./icons";
/* ------------------------------- Button -------------------------------- */
@@ -192,6 +192,44 @@ export function Badge({
);
}
export function Pagination({
page,
lastPage,
total,
onChange,
}: {
page: number;
lastPage: number;
total?: number;
onChange: (p: number) => void;
}) {
if (lastPage <= 1) return null;
return (
<div className="mt-4 flex items-center justify-between gap-3 text-sm">
<span className="text-muted">
{total != null && `${toFa(total)} مورد · `}
صفحه {toFa(page)} از {toFa(lastPage)}
</span>
<div className="flex items-center gap-2">
<Button
variant="secondary"
onClick={() => onChange(page - 1)}
disabled={page <= 1}
>
قبلی
</Button>
<Button
variant="secondary"
onClick={() => onChange(page + 1)}
disabled={page >= lastPage}
>
بعدی
</Button>
</div>
</div>
);
}
export function EmptyState({
title,
message,