next-page-disabled-if-zero-page (#6457)

This commit is contained in:
samyakj023 2024-06-18 22:58:03 +05:30 committed by GitHub
parent 55063f545a
commit 161dd72690
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -26,7 +26,7 @@ export const PadPage = ()=>{
const [padToDelete, setPadToDelete] = useState<string>('')
const pages = useMemo(()=>{
if(!pads){
return [0]
return 0;
}
return Math.ceil(pads!.total / searchParams.limit)
@ -166,7 +166,7 @@ export const PadPage = ()=>{
offset: (Number(currentPage)-1)*searchParams.limit})
}}><ChevronLeft/><span>Previous Page</span></button>
<span>{currentPage+1} out of {pages}</span>
<button disabled={pages == currentPage+1} onClick={()=>{
<button disabled={pages == 0 || pages == currentPage+1} onClick={()=>{
const newCurrentPage = currentPage+1
setCurrentPage(newCurrentPage)
setSearchParams({