Skip to content

Commit be055b0

Browse files
Apply suggested fix to src/components/module/singleVideo/listVideos/Pagination.tsx from Copilot Autofix
Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
1 parent 1c643a3 commit be055b0

1 file changed

Lines changed: 15 additions & 9 deletions

File tree

src/components/module/singleVideo/listVideos/Pagination.tsx

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,30 @@
11
import React, { useState } from "react";
22

3+
type PaginationItem = {
4+
id: number;
5+
text: string;
6+
};
7+
38
type PaginationProps = {
49
itemsPerPage?: number;
10+
items?: PaginationItem[];
511
};
612

7-
const Pagination = ({ itemsPerPage = 5 }: PaginationProps) => {
8-
const sampleData = [
9-
{ id: 1, text: "Item 1" },
10-
{ id: 2, text: "Item 2" },
11-
{ id: 3, text: "Item 3" },
13+
const defaultItems: PaginationItem[] = [
14+
{ id: 1, text: "Item 1" },
15+
{ id: 2, text: "Item 2" },
16+
{ id: 3, text: "Item 3" },
1217

13-
// ... داده‌های دیگر
14-
];
18+
// ... داده‌های دیگر
19+
];
1520

21+
const Pagination = ({ itemsPerPage = 5, items = defaultItems }: PaginationProps) => {
1622
const [currentPage, setCurrentPage] = useState(1);
1723
const safeItemsPerPage = Math.max(1, Math.trunc(itemsPerPage));
1824

19-
const totalPages = Math.ceil(sampleData.length / safeItemsPerPage);
25+
const totalPages = Math.ceil(items.length / safeItemsPerPage);
2026
const startIndex = (currentPage - 1) * safeItemsPerPage;
21-
const currentItems = sampleData.slice(
27+
const currentItems = items.slice(
2228
startIndex,
2329
startIndex + safeItemsPerPage
2430
);

0 commit comments

Comments
 (0)