-
+
{status === 'DENIED' ? 'REJECTED' : status}
- ({rows.length})
+ ({rows.length})
@@ -262,10 +264,10 @@ const BaseCalendarDataView = ({ data, daysLabels, CalendarComponent }: BaseCalen
);
};
-const MonthlyCalendarDataView = (props: { data: GroupedTimesheet[], daysLabels?: string[] }) => (
+const MonthlyCalendarDataView = (props: { data: GroupedTimesheet[], t: TranslationHooks, daysLabels?: string[] }) => (
);
-const WeeklyCalendarDataView = (props: { data: GroupedTimesheet[], daysLabels?: string[] }) => (
+const WeeklyCalendarDataView = (props: { data: GroupedTimesheet[], t: TranslationHooks, daysLabels?: string[] }) => (
);
diff --git a/apps/web/app/[locale]/timesheet/[memberId]/components/FilterWithStatus.tsx b/apps/web/app/[locale]/timesheet/[memberId]/components/FilterWithStatus.tsx
index 14ac28f0c..8e4c98a06 100644
--- a/apps/web/app/[locale]/timesheet/[memberId]/components/FilterWithStatus.tsx
+++ b/apps/web/app/[locale]/timesheet/[memberId]/components/FilterWithStatus.tsx
@@ -3,6 +3,7 @@ import React, { HTMLAttributes } from 'react';
import { Button } from 'lib/components';
import { clsxm } from '@app/utils';
import { TimesheetLog, TimesheetStatus } from '@/app/interfaces';
+import { useTranslations } from 'next-intl';
export type FilterStatus = 'All Tasks' | 'Pending' | 'Approved' | 'In review' | 'Draft' | 'Rejected';
export function FilterWithStatus({
@@ -17,6 +18,7 @@ export function FilterWithStatus({
onToggle: (status: FilterStatus) => void;
className?: HTMLAttributes;
}>) {
+ const t = useTranslations();
const statusIcons: Record = {
'All Tasks': 'icon-all',
@@ -29,12 +31,12 @@ export function FilterWithStatus({
const buttonData = React.useMemo(() => {
const counts = {
- 'All Tasks': Object.values(data ?? {}).reduce((total, tasks) => total + (tasks?.length ?? 0), 0),
- Pending: data?.PENDING?.length ?? 0,
- Approved: data?.APPROVED?.length ?? 0,
- 'In review': data?.['IN REVIEW']?.length ?? 0,
- Draft: data?.DRAFT?.length ?? 0,
- Rejected: data?.DENIED?.length ?? 0,
+ [t('pages.timesheet.ALL_TASKS')]: Object.values(data ?? {}).reduce((total, tasks) => total + (tasks?.length ?? 0), 0),
+ [t('pages.timesheet.PENDING')]: data?.PENDING?.length ?? 0,
+ [t('pages.timesheet.APPROVED')]: data?.APPROVED?.length ?? 0,
+ [t('pages.timesheet.IN_REVIEW')]: data?.['IN REVIEW']?.length ?? 0,
+ [t('pages.timesheet.DRAFT')]: data?.DRAFT?.length ?? 0,
+ [t('pages.timesheet.REJECTED')]: data?.DENIED?.length ?? 0,
};
return Object.entries(counts).map(([label, count]) => ({
label: label as FilterStatus,
diff --git a/apps/web/app/[locale]/timesheet/[memberId]/components/MonthlyTimesheetCalendar.tsx b/apps/web/app/[locale]/timesheet/[memberId]/components/MonthlyTimesheetCalendar.tsx
index 55f6daad5..c2da23148 100644
--- a/apps/web/app/[locale]/timesheet/[memberId]/components/MonthlyTimesheetCalendar.tsx
+++ b/apps/web/app/[locale]/timesheet/[memberId]/components/MonthlyTimesheetCalendar.tsx
@@ -1,12 +1,14 @@
import React, { useMemo, useState, useCallback } from "react";
-import { format, addMonths, eachDayOfInterval, startOfMonth, endOfMonth, addDays, Locale } from "date-fns";
+import { format, addMonths, eachDayOfInterval, startOfMonth, endOfMonth, addDays, Locale, isLeapYear } from "date-fns";
import { GroupedTimesheet } from "@/app/hooks/features/useTimesheet";
import { enGB } from 'date-fns/locale';
import { cn } from "@/lib/utils";
import { TotalDurationByDate } from "@/lib/features";
import { formatDate } from "@/app/helpers";
+import { TranslationHooks } from "next-intl";
type MonthlyCalendarDataViewProps = {
+ t: TranslationHooks
data?: GroupedTimesheet[];
onDateClick?: (date: Date) => void;
renderDayContent?: (date: Date, plan?: GroupedTimesheet) => React.ReactNode;
@@ -26,7 +28,14 @@ const defaultDaysLabels = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
const generateFullCalendar = (currentMonth: Date) => {
const monthStart = startOfMonth(currentMonth);
- const monthEnd = endOfMonth(currentMonth);
+ const monthEnd = (() => {
+ const month = monthStart.getMonth();
+ if (month === 1) {
+ const year = monthStart.getFullYear();
+ return new Date(year, 1, isLeapYear(monthStart) ? 29 : 28);
+ }
+ return endOfMonth(monthStart);
+ })();
const startDate = addDays(monthStart, -monthStart.getDay());
const endDate = addDays(monthEnd, 6 - monthEnd.getDay());
return eachDayOfInterval({ start: startDate, end: endDate });
@@ -40,7 +49,8 @@ const MonthlyTimesheetCalendar: React.FC = ({
locale = enGB,
daysLabels = defaultDaysLabels,
noDataText = "No Data",
- classNames = {}
+ classNames = {},
+ t
}) => {
const [currentMonth, setCurrentMonth] = useState(new Date());
const calendarDates = useMemo(() => generateFullCalendar(currentMonth), [currentMonth]);
@@ -60,7 +70,7 @@ const MonthlyTimesheetCalendar: React.FC = ({
onClick={handlePreviousMonth}
className="px-4 py-2 bg-gray-200 rounded hover:bg-gray-300 dark:bg-primary-light hover:dark:bg-primary-light"
>
- Previous
+ {t('common.PREV')}
{format(currentMonth, "MMMM yyyy", { locale: locale })}
@@ -69,7 +79,7 @@ const MonthlyTimesheetCalendar: React.FC = ({
onClick={handleNextMonth}
className="px-4 py-2 bg-gray-200 dark:bg-primary-light rounded hover:bg-gray-300 hover:dark:bg-primary-light"
>
- Next
+ {t('common.NEXT')}
diff --git a/apps/web/app/[locale]/timesheet/[memberId]/components/TimeSheetFilterPopover.tsx b/apps/web/app/[locale]/timesheet/[memberId]/components/TimeSheetFilterPopover.tsx
index 8eb858acc..8cb3c1675 100644
--- a/apps/web/app/[locale]/timesheet/[memberId]/components/TimeSheetFilterPopover.tsx
+++ b/apps/web/app/[locale]/timesheet/[memberId]/components/TimeSheetFilterPopover.tsx
@@ -6,9 +6,9 @@ import { MultiSelect } from 'lib/components/custom-select';
import { Popover, PopoverContent, PopoverTrigger } from '@components/ui/popover';
import { SettingFilterIcon } from '@/assets/svg';
import { useTranslations } from 'next-intl';
-import { clsxm } from '@/app/utils';
import { useTimelogFilterOptions } from '@/app/hooks';
import { useTimesheet } from '@/app/hooks/features/useTimesheet';
+import { cn } from '@/lib/utils';
export const TimeSheetFilterPopover = React.memo(function TimeSheetFilterPopover() {
const [shouldRemoveItems, setShouldRemoveItems] = React.useState(false);
@@ -61,7 +61,7 @@ export const TimeSheetFilterPopover = React.memo(function TimeSheetFilterPopover