diff --git a/package.json b/package.json index e0b6340..49b8f59 100644 --- a/package.json +++ b/package.json @@ -19,6 +19,7 @@ "@radix-ui/react-separator": "^1.1.1", "@radix-ui/react-slot": "^1.1.1", "@radix-ui/react-tooltip": "^1.1.7", + "@tanstack/react-table": "^8.20.6", "@vercel/analytics": "^1.4.1", "@vercel/speed-insights": "^1.1.0", "axios": "^1.7.9", @@ -34,6 +35,7 @@ "openai-whisper": "^1.0.2", "react": "^19.0.0", "react-dom": "^19.0.0", + "recharts": "^2.15.0", "svix": "^1.45.1", "tailwind-merge": "^2.6.0", "tailwindcss-animate": "^1.0.7" diff --git a/src/app/(panels)/suite/patient/dashboard/IntensityChart.tsx b/src/app/(panels)/suite/patient/dashboard/IntensityChart.tsx new file mode 100644 index 0000000..bb7d8f7 --- /dev/null +++ b/src/app/(panels)/suite/patient/dashboard/IntensityChart.tsx @@ -0,0 +1,75 @@ +"use client" + +import { CartesianGrid, Line, LineChart, XAxis } from "recharts" + +import { + Card, + CardContent, + CardDescription, + CardHeader, + CardTitle, +} from "@/components/ui/card" +import { + ChartConfig, + ChartContainer, + ChartTooltip, + ChartTooltipContent, +} from "@/components/ui/chart" + +const chartData = { + months: [ "Jan", "Feb", "Mar", "Apr" ], + data: [ 2, 2, 5, 6, 9, 9], +} + +const chartConfig = { + desktop: { + label: "paint index", + color: "hsl(var(--chart-1))", + }, +} satisfies ChartConfig + +export function IntenseChart() { + return ( + + + Intensity of Symtoms + Last 3 months + + + + ({ + month, + desktop: chartData.data[index], + }))} + margin={{ + left: 12, + right: 12, + }} + > + + value.slice(0, 3)} + /> + } + /> + + + + + + ) +} diff --git a/src/app/(panels)/suite/patient/dashboard/MedicationTable.jsx b/src/app/(panels)/suite/patient/dashboard/MedicationTable.jsx new file mode 100644 index 0000000..c790ab4 --- /dev/null +++ b/src/app/(panels)/suite/patient/dashboard/MedicationTable.jsx @@ -0,0 +1,48 @@ +"use client" + +import { + ColumnDef, + flexRender, + getCoreRowModel, + useReactTable, +} from "@tanstack/react-table" + +import { + Table, + TableBody, + TableCell, + TableHead, + TableHeader, + TableRow, +} from "@/components/ui/table" + +export function MedicationTable(medications) { + + + if (!userData) return
Loading...
; + + console.log(userData); + + return ( +
+ + + + Medication + Dosage + Frequency + + + + {medications.map((medication) => ( + + {medication.name} + {medication.dosage} + {medication.frequency} + + ))} + +
+
+ ) +} diff --git a/src/app/(panels)/suite/patient/dashboard/page.jsx b/src/app/(panels)/suite/patient/dashboard/page.jsx new file mode 100644 index 0000000..ea173cc --- /dev/null +++ b/src/app/(panels)/suite/patient/dashboard/page.jsx @@ -0,0 +1,32 @@ +"use client" +import { useState, useEffect } from 'react'; +import axios from 'axios'; +import { useUser } from '@clerk/nextjs'; + +import { IntenseChart } from "./IntensityChart" +import { MedicationTable } from "./MedicationTable" + +export default function Dashboard() { + + const { user } = useUser(); + const [userData, setUserData] = useState(null); + + useEffect(() => { + if (user) { + axios.get(`/api/user?userId=${user.id}`).then(response => { + setUserData(response.data); + }); + } + }, [user]); + + return ( +
+

Dashboard

+
+ + +
+
+ ) +} + diff --git a/src/app/(panels)/suite/patient/dashboard/page.tsx b/src/app/(panels)/suite/patient/dashboard/page.tsx deleted file mode 100644 index 9559023..0000000 --- a/src/app/(panels)/suite/patient/dashboard/page.tsx +++ /dev/null @@ -1,18 +0,0 @@ -"use client" - -export default function Dashboard() { - return ( -
-

Dashboard

-
- {[...Array(6)].map((_, i) => ( -
-

Card {i + 1}

-

This is some placeholder content for Card {i + 1}.

-
- ))} -
-
- ) -} - diff --git a/src/components/ui/chart.tsx b/src/components/ui/chart.tsx new file mode 100644 index 0000000..32dc873 --- /dev/null +++ b/src/components/ui/chart.tsx @@ -0,0 +1,365 @@ +"use client" + +import * as React from "react" +import * as RechartsPrimitive from "recharts" + +import { cn } from "@/lib/utils" + +// Format: { THEME_NAME: CSS_SELECTOR } +const THEMES = { light: "", dark: ".dark" } as const + +export type ChartConfig = { + [k in string]: { + label?: React.ReactNode + icon?: React.ComponentType + } & ( + | { color?: string; theme?: never } + | { color?: never; theme: Record } + ) +} + +type ChartContextProps = { + config: ChartConfig +} + +const ChartContext = React.createContext(null) + +function useChart() { + const context = React.useContext(ChartContext) + + if (!context) { + throw new Error("useChart must be used within a ") + } + + return context +} + +const ChartContainer = React.forwardRef< + HTMLDivElement, + React.ComponentProps<"div"> & { + config: ChartConfig + children: React.ComponentProps< + typeof RechartsPrimitive.ResponsiveContainer + >["children"] + } +>(({ id, className, children, config, ...props }, ref) => { + const uniqueId = React.useId() + const chartId = `chart-${id || uniqueId.replace(/:/g, "")}` + + return ( + +
+ + + {children} + +
+
+ ) +}) +ChartContainer.displayName = "Chart" + +const ChartStyle = ({ id, config }: { id: string; config: ChartConfig }) => { + const colorConfig = Object.entries(config).filter( + ([, config]) => config.theme || config.color + ) + + if (!colorConfig.length) { + return null + } + + return ( +