+
+ Page {currentPage} of {totalPages} ({dates?.length} items of {totalGroups})
+
+
+
+
+
+
+ {getPageNumbers().map((pageNumber, index) => (
+
+ {pageNumber === '...' ? (
+
+ ) : (
+ goToPage(pageNumber as number)}>
+ {pageNumber}
+
+ )}
+
+ ))}
+
+
+
+
+
+ )
+ }
+ >
+ )
+
+}
+
+export default TimesheetPagination
diff --git a/apps/web/app/[locale]/timesheet/[memberId]/page.tsx b/apps/web/app/[locale]/timesheet/[memberId]/page.tsx
index 0b3a6a9cc..d79febb07 100644
--- a/apps/web/app/[locale]/timesheet/[memberId]/page.tsx
+++ b/apps/web/app/[locale]/timesheet/[memberId]/page.tsx
@@ -21,9 +21,12 @@ import { differenceBetweenHours, getGreeting, secondsToTime } from '@/app/helper
import { useTimesheet } from '@/app/hooks/features/useTimesheet';
import { endOfMonth, startOfMonth } from 'date-fns';
import TimesheetDetailModal from './components/TimesheetDetailModal';
+import { useTimesheetPagination } from '@/app/hooks/features/useTimesheetPagination';
+import TimesheetPagination from './components/TimesheetPagination';
type TimesheetViewMode = 'ListView' | 'CalendarView';
export type TimesheetDetailMode = 'Pending' | 'MenHours' | 'MemberWork';
+const TIMESHEET_PAGE_SIZE = 10;
type ViewToggleButtonProps = {
mode: TimesheetViewMode;
@@ -52,13 +55,30 @@ const TimeSheet = React.memo(function TimeSheetPage({ params }: { params: { memb
to: endOfMonth(new Date()),
});
- const { timesheet: filterDataTimesheet, statusTimesheet, loadingTimesheet, isManage } = useTimesheet({
+ const { timesheet: filterDataTimesheet, statusTimesheet, loadingTimesheet, isManage, timesheetGroupByDays } = useTimesheet({
startDate: dateRange.from!,
endDate: dateRange.to!,
timesheetViewMode: timesheetNavigator,
inputSearch: search
});
+ const {
+ paginatedGroups,
+ currentPage,
+ totalPages,
+ goToPage,
+ nextPage,
+ previousPage,
+ getPageNumbers,
+ totalGroups,
+ dates
+ } = useTimesheetPagination({
+ data: filterDataTimesheet,
+ pageSize: TIMESHEET_PAGE_SIZE
+ });;
+
+
+
React.useEffect(() => {
getOrganizationProjects();
}, [getOrganizationProjects])
@@ -103,6 +123,10 @@ const TimeSheet = React.memo(function TimeSheetPage({ params }: { params: { memb
],
[activeTeam?.name, currentLocale, t]
);
+ const shouldRenderPagination =
+ timesheetNavigator === 'ListView' ||
+ (timesheetGroupByDays === 'Daily' && timesheetNavigator === 'CalendarView');
+
return (
<>
{isTimesheetDetailOpen
@@ -230,16 +254,33 @@ const TimeSheet = React.memo(function TimeSheetPage({ params }: { params: { memb
{timesheetNavigator === 'ListView' ? (