diff --git a/src/DataTable/CategoryLookUp.js b/src/DataTable/CategoryLookUp.js index 5b321e1..e8a46c9 100644 --- a/src/DataTable/CategoryLookUp.js +++ b/src/DataTable/CategoryLookUp.js @@ -7389,6 +7389,6 @@ var lookup = { ENVO_00003895: "Manufactured product/paper product", }; -export function ontLookup(val) { +export function onLookup(val) { return lookup[val] === undefined ? val : lookup[val]; } diff --git a/src/DataTable/Pagination.tsx b/src/DataTable/Pagination.tsx new file mode 100644 index 0000000..05d5a46 --- /dev/null +++ b/src/DataTable/Pagination.tsx @@ -0,0 +1,77 @@ +import React from "react"; + +export default function Pagination({ + table, + currentPage, + pageCount, + enteredPageNumber, + setEnteredPageNumber, + handleKeyDown, +}) { + return ( +
+ +
+ {currentPage < 2 ? null : ( + + )} + {currentPage < 3 ? null :

...

} + {currentPage > 0 ? ( +
table.setPageIndex(currentPage - 1)} + > + {currentPage} +
+ ) : null} +
{currentPage + 1}
+ {currentPage + 2 > pageCount ? null : ( + <> +
table.setPageIndex(currentPage + 1)} + > + {currentPage + 2} +
+ {pageCount - currentPage < 4 ? null :

...

} + + )} + {pageCount - currentPage < 3 ? null : ( + + )} +
+ setEnteredPageNumber(e.target.value)} + onKeyDown={handleKeyDown} + className="pageNumberImput" + type="text" + placeholder="Page Number" + /> + + +
+ ); +} diff --git a/src/DataTable/TemplateTable.css b/src/DataTable/TemplateTable.css new file mode 100644 index 0000000..041e1b8 --- /dev/null +++ b/src/DataTable/TemplateTable.css @@ -0,0 +1,70 @@ +.paginationPageCount { + /* width: 120px; */ + display: flex; + gap: 12px; + justify-content: space-around; + align-items: center; +} + +.pagination { + margin-top: 2rem; + display: flex; + align-items: center; + justify-content: flex-end; + gap: 12px; +} + +.paginBtn { + padding: 0.5rem 1rem; + border: none; + background: #def4ff; + color: #282828; + white-space: nowrap; + border-radius: 6px; + user-select: none; +} + +.paginBtn:hover { + background-color: #bfeaff; +} + +.paginBtn:disabled { + background-color: #f5f5f5; +} + +.pageBtn { + background-color: #fff; + display: flex; + align-items: center; + justify-content: center; + width: 20px; + height: 20px; + padding: 8px; + border-radius: 50%; + cursor: pointer; + user-select: none; +} + +.pageCurrent { + background-color: #def4ff; + display: flex; + align-items: center; + justify-content: center; + width: 20px; + height: 20px; + padding: 8px; + border-radius: 50%; + user-select: none; +} + +.pageBtn:hover { + background-color: #f0faff; +} + +.pageNumberImput { + width: 82px; + font-size: 13px; + border-bottom: 1px solid #909090; + font-weight: 300; + padding: 0 6px; +} diff --git a/src/DataTable/TemplateTable.tsx b/src/DataTable/TemplateTable.tsx index 97607f0..2b17db2 100644 --- a/src/DataTable/TemplateTable.tsx +++ b/src/DataTable/TemplateTable.tsx @@ -10,9 +10,13 @@ import { import { useEffect, useState } from "react"; +import Pagination from "./Pagination"; + +import "./TemplateTable.css"; + import { RowsIcon } from "lucide-react"; import { useSetIsShosen } from "../store/store"; -import { ontLookup } from "./CategoryLookUp"; +import { onLookup } from "./CategoryLookUp"; import SortingIcon from "@/IconsComponents/SortingIcon"; const columns = [ @@ -46,7 +50,7 @@ const columns = [ { accessorKey: "PROTOCOL_CATEGORY_CODE", header: "Category", - cell: (props) => ontLookup(props.getValue()), + cell: (props) => onLookup(props.getValue()), }, { accessorKey: "timestamp", @@ -64,6 +68,7 @@ export default function TemplateTable({ data }) { const [sorting, setSorting] = useState([{ id: "timestamp", desc: true }]); const [filtering, setFiltering] = useState(""); + const [enteredPageNumber, setEnteredPageNumber] = useState(""); const table = useReactTable({ data, @@ -94,6 +99,12 @@ export default function TemplateTable({ data }) { const pageCount = table.getPageCount(); const currentPage = table.getState().pagination.pageIndex; + const handleKeyDown = (event) => { + if (event.key === "Enter" && enteredPageNumber - 1 < pageCount) { + table.setPageIndex(enteredPageNumber - 1); + } + }; + const setIdShosen = useSetIsShosen(); useEffect(() => { setIdShosen(data && rowSelection ? data[rowSelection]?.uuid : null); @@ -237,41 +248,15 @@ export default function TemplateTable({ data }) { - {pageCount > 2 ? ( -
- -
-

- page{" "} - - {currentPage + 1} - {" "} - of{" "} - - {pageCount} - -

-
- -
+ {pageCount > 1 ? ( + ) : null}
diff --git a/src/StartScreenComp/StartScreenComp.css b/src/StartScreenComp/StartScreenComp.css index 465ff1e..d5a5742 100644 --- a/src/StartScreenComp/StartScreenComp.css +++ b/src/StartScreenComp/StartScreenComp.css @@ -134,23 +134,6 @@ th { border: none; } -.pagination { - margin-top: 2rem; - display: flex; - align-items: center; - justify-content: flex-end; - gap: 12px; -} - -.paginBtn { - padding: 0.5rem 1rem; - border: none; - background: #def4ff; - color: #282828; - white-space: nowrap; - border-radius: 6px; -} - /* tr:nth-child(even) { background-color: #f6f6f6; } */ diff --git a/src/StartScreenComp/StartScreenComp.tsx b/src/StartScreenComp/StartScreenComp.tsx index b52b90b..5981a0b 100644 --- a/src/StartScreenComp/StartScreenComp.tsx +++ b/src/StartScreenComp/StartScreenComp.tsx @@ -4,6 +4,8 @@ import { Navigate } from "react-router-dom"; import MakeCopyDialog from "../DialogComp/MakeCopyDialog"; import Notification from "../DialogComp/Notification"; +import { onLookup } from "../DataTable/CategoryLookUp"; + import LogoBar from "../MenuBar/LogoBar"; import Button from "../ui/Button"; import config from "../utils/config"; @@ -53,9 +55,16 @@ export default function StartScreenComp({}) { cachePolicy: "no-cache", }); + const mappedCategoryData = + data && + data.template.map((item) => ({ + ...item, + PROTOCOL_CATEGORY_CODE: onLookup(item["PROTOCOL_CATEGORY_CODE"]), + })); + const templateData = []; data && - data.template.map((item) => { + mappedCategoryData.map((item) => { if (mode == "Finalized" && item.template_status == "FINALIZED") { return templateData.push(item); }