From 1bbb3702ad119afa92431af4d2b3f997b51ebd2b Mon Sep 17 00:00:00 2001
From: AKILIMAILI CIZUNGU Innocent
<51681130+Innocent-Akim@users.noreply.github.com>
Date: Thu, 12 Dec 2024 21:20:07 +0200
Subject: [PATCH] [Feat]:Timesheet Skeleton Calendar-View (#3419)
* feat:timesheet skeleton calendar-view
* coderabbitai
* feat: optimize SelectionBar component with reusable ActionButton and improved class handling
* coderabbitai
* coderabbitai
---
.../[memberId]/components/CalendarView.tsx | 54 ++++++++------
.../[memberId]/components/SelectionBar.tsx | 72 +++++++++++++++++++
.../[memberId]/components/TimesheetCard.tsx | 2 +-
.../timesheet/[memberId]/components/index.tsx | 2 +-
.../[locale]/timesheet/[memberId]/page.tsx | 4 +-
5 files changed, 108 insertions(+), 26 deletions(-)
create mode 100644 apps/web/app/[locale]/timesheet/[memberId]/components/SelectionBar.tsx
diff --git a/apps/web/app/[locale]/timesheet/[memberId]/components/CalendarView.tsx b/apps/web/app/[locale]/timesheet/[memberId]/components/CalendarView.tsx
index 6d31d52e8..7518ef2c0 100644
--- a/apps/web/app/[locale]/timesheet/[memberId]/components/CalendarView.tsx
+++ b/apps/web/app/[locale]/timesheet/[memberId]/components/CalendarView.tsx
@@ -12,6 +12,7 @@ import MonthlyTimesheetCalendar from "./MonthlyTimesheetCalendar";
import { useTimelogFilterOptions } from "@/app/hooks";
import WeeklyTimesheetCalendar from "./WeeklyTimesheetCalendar";
import { IUser } from "@/app/interfaces";
+import TimesheetSkeleton from "@components/shared/skeleton/TimesheetSkeleton";
interface BaseCalendarDataViewProps {
t: TranslationHooks
data: GroupedTimesheet[];
@@ -32,31 +33,40 @@ export function CalendarView({ data, loading, user }: { data?: GroupedTimesheet[
t("common.DAYS.fri"),
t("common.DAYS.sat")
];
+
+ if (loading || !data) {
+ return (
+
+ {Array.from({ length: 10 }).map((_, index) => (
+
+ ))}
+
+ );
+ }
+
+ if (data.length === 0) {
+ return (
+
+
{t('pages.timesheet.NO_ENTRIES_FOUND')}
+
+ );
+ }
+
return (
-
- {data ? (
- data.length > 0 ? (
- <>
- {timesheetGroupByDays === 'Monthly' ? (
-
- ) : timesheetGroupByDays === 'Weekly' ? (
-
- ) : (
-
- )}
- >
- ) : (
-
-
{t('pages.timesheet.NO_ENTRIES_FOUND')}
-
- )
- ) : (
-
-
{t('pages.timesheet.LOADING')}
-
- )}
+
+ {(() => {
+ switch (timesheetGroupByDays) {
+ case 'Monthly':
+ return ;
+ case 'Weekly':
+ return ;
+ default:
+ return ;
+ }
+ })()}
);
+
}
const CalendarDataView = ({ data, t }: { data?: GroupedTimesheet[], t: TranslationHooks }) => {
diff --git a/apps/web/app/[locale]/timesheet/[memberId]/components/SelectionBar.tsx b/apps/web/app/[locale]/timesheet/[memberId]/components/SelectionBar.tsx
new file mode 100644
index 000000000..5cdf3bfa1
--- /dev/null
+++ b/apps/web/app/[locale]/timesheet/[memberId]/components/SelectionBar.tsx
@@ -0,0 +1,72 @@
+import { cn } from "@/lib/utils";
+import { useTranslations } from "next-intl";
+
+type ActionButtonProps = {
+ label: string;
+ onClick?: (event: React.MouseEvent
) => void;
+};
+
+const ActionButton = ({ label, onClick }: ActionButtonProps) => (
+
+);
+
+interface SelectionBarProps {
+ fullWidth: boolean;
+ selectedCount: number;
+ onApprove: () => void;
+ onReject: () => void;
+ onDelete: () => void;
+ onClearSelection: () => void;
+}
+
+export const SelectionBar = ({
+ fullWidth,
+ selectedCount,
+ onApprove,
+ onReject,
+ onDelete,
+ onClearSelection
+}: SelectionBarProps) => {
+ const t = useTranslations()
+ return (
+
+
+
+
+ {selectedCount}
+
+
selected
+
+
+
+
+
+
+
+ )
+}
diff --git a/apps/web/app/[locale]/timesheet/[memberId]/components/TimesheetCard.tsx b/apps/web/app/[locale]/timesheet/[memberId]/components/TimesheetCard.tsx
index 3510b831b..1b884c7c4 100644
--- a/apps/web/app/[locale]/timesheet/[memberId]/components/TimesheetCard.tsx
+++ b/apps/web/app/[locale]/timesheet/[memberId]/components/TimesheetCard.tsx
@@ -151,7 +151,7 @@ export const TimesheetCardDetail = ({ data }: { data?: Record
}
>
-
+
- {/* */}
{timesheetNavigator === 'ListView' ? (
)}
+