September 12, 2024 11:26 AM (GMT+10) Removed pagination from the filtered view. In forecast mode, the previous/next buttons and total page count are no longer displayed. This creates a cleaner look in the day's forecast view while preserving the pagination logic for other uses of this component. I implemented this by checking if a date is present when the component renders.
const totalPagesToDisplay = date ? Math.ceil(filteredTrades.length / 10) : totalPages;
...
{!date && (
<div className="flex justify-between items-center my-4">
<button
onClick={() => setPage((prevPage) => Math.max(prevPage - 1, 1))}
disabled={page <= 1}
className={`px-4 py-2 rounded-md text-white ${
page <= 1 ? "bg-gray-500 cursor-not-allowed" : "bg-bull-secondary hover:bg-bull-primary"
}`}
>
Previous
</button>
<span className="text-snow">
Page {page} of {totalPagesToDisplay}
</span>
<button
onClick={() => setPage((prev) => Math.min(prev + 1, totalPagesToDisplay))}
disabled={page >= totalPagesToDisplay || totalPagesToDisplay <= 1}
className={`px-4 py-2 rounded-md text-white ${
page >= totalPagesToDisplay || totalPagesToDisplay <= 1
? "bg-gray-500 cursor-not-allowed"
: "bg-bull-secondary hover:bg-bull-primary"
}`}
>
Next
</button>
</div>
)}