Skip to content

Commit

Permalink
Merge pull request #151 from ballyalley-o/development
Browse files Browse the repository at this point in the history
Redux Course Slice added (#138)
  • Loading branch information
in-a-iii authored Apr 23, 2024
2 parents 2dd0ab5 + efcf987 commit c086bbe
Showing 1 changed file with 28 additions and 3 deletions.
31 changes: 28 additions & 3 deletions src/page/bootcamp/bootcamp.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useEffect } from 'react'
import { useState } from 'react'
import { m } from 'framer-motion'
import { Box, Grid } from '@mui/material'
import { Pagination, Box, Grid } from '@mui/material'
import { SCard } from 'theme/style'
import { useGetAllBootcampQuery } from 'store/slice/bootcamp'
import { BootcampSearch, BootcampCard } from 'section/bootcamp'
Expand All @@ -11,8 +11,13 @@ import { ASSET } from 'config'
import { LABEL, PLACEHOLDER } from 'constant'

function Bootcamp() {
const [currentPage, setCurrentPage] = useState(1)
const { data, error, isLoading } = useGetAllBootcampQuery()

const handlePageChange = (event: any, value: any) => {
setCurrentPage(value)
}

return (
<MotionLazyContainer>
<Box
Expand Down Expand Up @@ -42,6 +47,15 @@ function Bootcamp() {
</Grid>

<Grid item sm={9}>
<Pagination
count={Math.ceil(data?.data?.length ?? 0 / 6)}
page={currentPage}
onChange={handlePageChange}
variant='outlined'
shape='rounded'
color='primary'
sx={{ display: 'flex', justifyContent: 'flex-end', mb: 2 }}
/>
<SCard
sx={{
width: '100%',
Expand All @@ -52,10 +66,21 @@ function Bootcamp() {
{isLoading ? (
<SkeletonLoader cards={8} />
) : (
data?.data?.map((bootcamp: any, index: number) => <BootcampCard key={index} bootcamp={bootcamp} />)
data?.data
?.slice((currentPage - 1) * 6, currentPage * 6)
.map((bootcamp: any, index: number) => <BootcampCard key={index} bootcamp={bootcamp} />)
)}
</Grid>
</SCard>
<Pagination
count={Math.ceil(data?.data?.length ?? 0 / 6)}
page={currentPage}
onChange={handlePageChange}
variant='outlined'
shape='rounded'
color='primary'
sx={{ display: 'flex', justifyContent: 'flex-end', mt: 2 }}
/>
</Grid>
</Grid>
</Box>
Expand Down

0 comments on commit c086bbe

Please sign in to comment.