Skip to content

Commit

Permalink
indexing in UI
Browse files Browse the repository at this point in the history
  • Loading branch information
Prakhar-commits committed Nov 3, 2023
1 parent 5605b3d commit b10ac58
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
@@ -1 +1 @@
NEXT_PUBLIC_DB_URL = ""
NEXT_PUBLIC_DB_URL = "https://localhost:3000"
18 changes: 11 additions & 7 deletions src/components/displayTable/DataDisplay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,19 @@ const DataDisplay: React.FC = () => {
.slice()
.reverse()
.map((row, i) => (
<TableRow row={row} index={i} key={i} />
<TableRow
row={row}
index={i}
key={i}
currentPage={currentPage}
itemsPerPage={itemsPerPage}
/>
))}
</tbody>
</table>
<ReactPaginate
previousLabel={"previous"}
nextLabel={"next"}
breakLabel={"..."}
previousLabel={"Previous"}
nextLabel={"Next"}
breakClassName={"break-me px-2 py-1"}
marginPagesDisplayed={0}
pageRangeDisplayed={0}
Expand All @@ -58,16 +63,15 @@ const DataDisplay: React.FC = () => {
setCurrentPage(selected);
}}
containerClassName={
"pagination flex flex-wrap justify-center items-center my-4"
"pagination flex flex-wrap justify-between items-center my-4"
}
pageClassName={"mx-1"}
pageClassName={"mx-1 hidden"}
previousClassName={
"mx-1 bg-[#B52326] text-white rounded px-2 py-1 sm:px-3 sm:py-2 hover: bg-[#B52326]"
}
nextClassName={
"mx-1 bg-[#B52326] text-white rounded px-2 py-1 sm:px-3 sm:py-2 hover:bg- bg-[#B52326]"
}
activeClassName={" bg-[#B52326] text-white rounded px-3 py-2"}
disabledClassName={"opacity-50 cursor-not-allowed"}
/>
</div>
Expand Down
16 changes: 14 additions & 2 deletions src/components/displayTable/Row.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,17 @@ import { Copy, Edit, Link, Trash2 } from "react-feather";
import { RowType } from "@/types/types";
import { DbTypes } from "@/types/ResponseTypes";

const TableRow = ({ row, index }: { row: DbTypes; index: number }) => {
const TableRow = ({
row,
index,
currentPage,
itemsPerPage,
}: {
row: DbTypes;
index: number;
currentPage: number;
itemsPerPage: number;
}) => {
const [isExpand, setIsExpand] = useState<boolean>(false);
const {
meta_data,
Expand Down Expand Up @@ -34,10 +44,12 @@ const TableRow = ({ row, index }: { row: DbTypes; index: number }) => {
const startTime = new Date(start_time!).toLocaleTimeString();
const endTime = new Date(end_time!).toLocaleTimeString();

const actualIndex = currentPage * itemsPerPage + index + 1;

return (
<>
<tr className="border text-center" onClick={() => setIsExpand(!isExpand)}>
<td className="border p-2">{index}</td>
<td className="border p-2">{actualIndex}</td>
<td className="border p-2">{batch}</td>
<td className="border p-2">{name}</td>
<td className="border p-2">{startDate}</td>
Expand Down

0 comments on commit b10ac58

Please sign in to comment.