import React, { useState } from 'react'; import { useTheme } from '@mui/material/styles'; import { useMediaQuery } from '@mui/material'; import { Box, Typography, Paper, Table, TableBody, TableCell, TableHead, TableRow, Chip, Pagination, Button, Avatar, TableContainer } from '@mui/material'; import TuneIcon from '@mui/icons-material/Tune'; import { green } from '@mui/material/colors'; import AssignmentIcon from '@mui/icons-material/Assignment'; const TopSellingProduct = ({ data = [] }) => { const theme = useTheme(); const [currentPage, setCurrentPage] = useState(1); const itemsPerPage = 5; const isMobile = useMediaQuery(theme.breakpoints.down('sm')); const pageCount = Math.ceil(data.length / itemsPerPage); const paginatedData = data.slice( (currentPage - 1) * itemsPerPage, currentPage * itemsPerPage ); return ( {/* العنوان وزر الفلاتر */} Top Selling Product {/* جدول البيانات */} Product {!isMobile && Sales} Amount {!isMobile && Price} Status {paginatedData.map((row, i) => ( {row.product} {!isMobile && {row.sales}} ${row.amount.toLocaleString()} {!isMobile && ${row.price}} ))}
{/* التذييل مع الترقيم */} Showing {(currentPage - 1) * itemsPerPage + 1} to {Math.min(currentPage * itemsPerPage, data.length)} of {data.length} setCurrentPage(value)} size={isMobile ? 'small' : 'medium'} sx={{ '& .MuiPaginationItem-root': { fontSize: { xs: '12px', sm: '14px' }, minWidth: { xs: 24, sm: 32 }, height: { xs: 24, sm: 32 }, backgroundColor: '#FFECE0', color: theme.palette.primary.main, borderRadius: '8px', '&.Mui-selected': { backgroundColor: theme.palette.primary.main, color: '#fff', }, '&:hover': { backgroundColor: '#FFD6B5', }, }, }} />
); }; export default TopSellingProduct;