-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b5613c2
commit 50c9ce8
Showing
35 changed files
with
18,768 additions
and
395 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
REACT_APP_CUSTOM_DIR = '' | ||
REACT_APP_API_ENDPOINT = 'http://localhost/pcm/' | ||
REACT_APP_API_ENDPOINT = 'http://localhost/pcm' | ||
REACT_APP_WEBSITE = 'http://tmb.co.ir' |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import React, { useState } from "react"; | ||
import PaginationBar from "./PaginationBar"; | ||
import Table from "../table"; | ||
import _ from "lodash"; | ||
|
||
const LIMIT = 10; | ||
|
||
const PaginatedTable = ({ data, columns }) => { | ||
const [paginationState, setPaginationState] = useState({ | ||
currentPage: 1, | ||
}); | ||
|
||
const getPaginatedData = (data, limit, page) => { | ||
return _.slice(data, (page - 1) * limit, page * limit); | ||
}; | ||
|
||
const handlePageNumberClick = (page) => { | ||
setPaginationState({ currentPage: page }); | ||
}; | ||
|
||
const numberOfPages = Math.ceil(data?.length / LIMIT); | ||
const { currentPage } = paginationState; | ||
|
||
return ( | ||
<React.Fragment> | ||
<Table | ||
data={getPaginatedData(data, LIMIT, currentPage)} | ||
columns={columns} | ||
/> | ||
{numberOfPages > 1 ? ( | ||
<PaginationBar | ||
numberOfPages={numberOfPages} | ||
currentPage={currentPage} | ||
onPageNumberClick={handlePageNumberClick} | ||
/> | ||
) : null} | ||
</React.Fragment> | ||
); | ||
}; | ||
|
||
export default PaginatedTable; |
18 changes: 13 additions & 5 deletions
18
src/components/common/pagination.module.css → ...s/common/Pagination/Pagination.module.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,41 @@ | ||
:root { | ||
--color-one: #2eaf7d; | ||
--color-two: #3fd0c9; | ||
--color-three: #449342; | ||
--color-four: #02353c; | ||
} | ||
|
||
.PaginationBarContainer { | ||
display: flex; | ||
flex-direction: row; | ||
align-items: center; | ||
align-self: center; | ||
max-width: 400px; | ||
max-width: 320px; | ||
margin-top: 20px; | ||
} | ||
|
||
.PaginationBarItem { | ||
display: flex; | ||
font-size: 13px; | ||
justify-content: center; | ||
align-items: center; | ||
cursor: pointer; | ||
box-sizing: border-box; | ||
background-color: #02353c; | ||
background-color: var(--color-four); | ||
transition: 300ms; | ||
color: #fff; | ||
border-radius: 2px; | ||
min-height: 30px; | ||
min-width: 30px; | ||
margin-right: 1px; | ||
margin-left: 1px; | ||
padding: 5px; | ||
padding: 0 4px; | ||
} | ||
|
||
.PaginationBarItem:hover { | ||
background-color: #449342; | ||
background-color: var(--color-three); | ||
} | ||
|
||
.PaginationBarItem.CurrentPage { | ||
background-color: #2eaf7d; | ||
background-color: var(--color-one); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.