fix CurrentPage ===> จัดการผู้ใช้งาน

This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2025-07-11 10:14:20 +07:00
parent 8aa17c7648
commit 72ba71c1f6
2 changed files with 26 additions and 1 deletions

19
src/utils/functions.ts Normal file
View file

@ -0,0 +1,19 @@
/**
*
*
* @param page
* @param maxPage
* @param total
* @returns
*/
export async function updateCurrentPage(
page: number,
maxPage: number,
total: number
) {
// ถ้าหน้าปัจจุบันไม่ใช่หน้าแรก และเป็นหน้าสุดท้าย และมีข้อมูลเหลือ 1 รายการ ให้กลับไปหน้าก่อนหน้า
if (page > 1 && page === maxPage && total === 1) {
return page - 1;
}
return page;
}