diff --git a/src/components/dashboard/Dashboard.tsx b/src/components/dashboard/Dashboard.tsx index 752c5a2..77e7145 100644 --- a/src/components/dashboard/Dashboard.tsx +++ b/src/components/dashboard/Dashboard.tsx @@ -13,6 +13,7 @@ import ShareButton from "@/components/ui/ShareButton"; import { getUserFootprints } from "@/lib/firebase/firestore"; import { exportToCSV, ActivityHistoryEntry } from "@/utils/exportCSV"; import { ArrowDownTrayIcon } from "@heroicons/react/24/outline"; +import EmptyState from "@/components/ui/EmptyState"; // Import EmptyState type SortOption = "newest" | "oldest" | "highest_impact" | "lowest_impact"; @@ -238,21 +239,16 @@ export default function Dashboard({ ); } - if (!dashboardData) { + if (!dashboardData || activityHistory.length === 0) { return ( -
-
- 🌱 -

- Welcome to Carbon Tracker! -

-

- Start tracking your digital activities to see your carbon footprint. -

- -
+
+ onNavigate("activities")} + />
); } @@ -463,4 +459,4 @@ export default function Dashboard({ )}
); -} \ No newline at end of file +} diff --git a/src/components/ui/EmptyState.tsx b/src/components/ui/EmptyState.tsx new file mode 100644 index 0000000..6df5b96 --- /dev/null +++ b/src/components/ui/EmptyState.tsx @@ -0,0 +1,41 @@ +import React from 'react'; + +interface EmptyStateProps { + title: string; + description: string; + actionLabel: string; + onAction: () => void; + icon?: string; // Can be an emoji or a path to an SVG +} + +const EmptyState: React.FC = ({ + title, + description, + actionLabel, + onAction, + icon, +}) => { + return ( +
+ {icon && ( +
+ {icon.startsWith(' + ) : ( + {icon} + )} +
+ )} +

{title}

+

{description}

+ +
+ ); +}; + +export default EmptyState;