diff --git a/src/app/dashboard/page.tsx b/src/app/dashboard/page.tsx index 33c7490..f413ec4 100644 --- a/src/app/dashboard/page.tsx +++ b/src/app/dashboard/page.tsx @@ -1,4 +1,4 @@ -import { Metadata } from "next"; +"use client"; import Image from "next/image"; import { Card, @@ -10,13 +10,10 @@ import { import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs"; import { Overview } from "@/components/ui/overview"; import { RecentSales } from "@/components/recent-sales"; - -export const metadata: Metadata = { - title: "Dashboard", - description: "Example dashboard app built using the components.", -}; +import { useState } from "react"; export default function Dashboard() { + const [graphType, setGraphType] = useState("line"); return ( <>
@@ -163,7 +160,24 @@ export default function Dashboard() { Overview - + + {/* tab to switch between line and bar graph */} + + + setGraphType("line")} + > + Line + + setGraphType("bar")} + > + Bar + + + diff --git a/src/components/ui/overview.tsx b/src/components/ui/overview.tsx index 5cc8763..dbe45f8 100644 --- a/src/components/ui/overview.tsx +++ b/src/components/ui/overview.tsx @@ -1,6 +1,6 @@ "use client"; -import { Bar, BarChart, ResponsiveContainer, XAxis, YAxis } from "recharts"; +import { Bar, BarChart, ResponsiveContainer, XAxis, YAxis, LineChart, Line } from "recharts"; const data = [ { @@ -53,31 +53,58 @@ const data = [ }, ]; -export function Overview() { - return ( - - - - `$${value}`} - /> - - - - ); +interface OverViewProps{ + graphType:string; +} + +export function Overview(props: OverViewProps) { + return ( + + {props.graphType === 'line' ? ( + + + `$${value}`} + /> + + + ) : ( + + + `$${value}`} + /> + + + )} + + ); }