@@ -13,21 +13,21 @@ import Paper from '@material-ui/core/Paper';
13
13
import styles from '../../../assets/jss/material-dashboard-react/views/dashboardStyle' ;
14
14
import { getPushes } from '../../../services/git-push' ;
15
15
import { KeyboardArrowRight } from '@material-ui/icons' ;
16
- import Search from '../../../components/Search/Search' ; // Import the Search component
17
- import Pagination from '../../../components/Pagination/Pagination' ; // Import Pagination component
16
+ import Search from '../../../components/Search/Search' ;
17
+ import Pagination from '../../../components/Pagination/Pagination' ;
18
18
19
19
export default function PushesTable ( props ) {
20
20
const useStyles = makeStyles ( styles ) ;
21
21
const classes = useStyles ( ) ;
22
22
const [ data , setData ] = useState ( [ ] ) ;
23
- const [ filteredData , setFilteredData ] = useState ( [ ] ) ; // State for filtered data
23
+ const [ filteredData , setFilteredData ] = useState ( [ ] ) ;
24
24
const [ isLoading , setIsLoading ] = useState ( false ) ;
25
25
const [ isError , setIsError ] = useState ( false ) ;
26
26
const navigate = useNavigate ( ) ;
27
27
const [ , setAuth ] = useState ( true ) ;
28
- const [ currentPage , setCurrentPage ] = useState ( 1 ) ; // State for current page
28
+ const [ currentPage , setCurrentPage ] = useState ( 1 ) ;
29
29
const itemsPerPage = 5 ;
30
- const [ searchTerm , setSearchTerm ] = useState ( '' ) ; // Define searchTerm state
30
+ const [ searchTerm , setSearchTerm ] = useState ( '' ) ;
31
31
const openPush = ( push ) => navigate ( `/admin/push/${ push } ` , { replace : true } ) ;
32
32
33
33
useEffect ( ( ) => {
@@ -56,27 +56,24 @@ export default function PushesTable(props) {
56
56
setCurrentPage ( 1 ) ;
57
57
} , [ searchTerm , data ] ) ;
58
58
59
- // Handler function for search input
60
59
const handleSearch = ( term ) => setSearchTerm ( term . trim ( ) ) ;
61
60
62
61
const handlePageChange = ( page ) => {
63
- setCurrentPage ( page ) ; // Update current page
62
+ setCurrentPage ( page ) ;
64
63
} ;
65
64
66
- // Logic for pagination (getting items for the current page)
67
65
const indexOfLastItem = currentPage * itemsPerPage ;
68
66
const indexOfFirstItem = indexOfLastItem - itemsPerPage ;
69
67
const currentItems = filteredData . slice ( indexOfFirstItem , indexOfLastItem ) ;
70
68
71
- // Change page
72
69
const paginate = ( pageNumber ) => setCurrentPage ( pageNumber ) ;
73
70
74
71
if ( isLoading ) return < div > Loading...</ div > ;
75
72
if ( isError ) return < div > Something went wrong ...</ div > ;
76
73
77
74
return (
78
75
< div >
79
- < Search onSearch = { handleSearch } /> { /* Use the Search component */ }
76
+ < Search onSearch = { handleSearch } /> { }
80
77
< TableContainer component = { Paper } >
81
78
< Table className = { classes . table } aria-label = 'simple table' >
82
79
< TableHead >
0 commit comments