fix CurrentPage ===> จัดการผู้ใช้งาน
This commit is contained in:
parent
8aa17c7648
commit
72ba71c1f6
2 changed files with 26 additions and 1 deletions
19
src/utils/functions.ts
Normal file
19
src/utils/functions.ts
Normal 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;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue