feat: enhance dashboard overview with overall graph data and export Deal interface

This commit is contained in:
THIS ONE IS A LITTLE BIT TRICKY KRUB 2024-11-07 17:08:16 +07:00
parent 9b37b76bd5
commit 4c42b5e50d
2 changed files with 18 additions and 4 deletions

View File

@ -11,7 +11,7 @@ import { getProjectByUserId } from "@/lib/data/projectQuery";
import { Loader } from "@/components/loading/loader"; import { Loader } from "@/components/loading/loader";
import { getInvestmentByProjectsIds } from "@/lib/data/investmentQuery"; import { getInvestmentByProjectsIds } from "@/lib/data/investmentQuery";
import { useQuery } from "@supabase-cache-helpers/postgrest-react-query"; import { useQuery } from "@supabase-cache-helpers/postgrest-react-query";
import { getLatestInvestment } from "../portfolio/[uid]/query"; import { getLatestInvestment, overAllGraphData, Deal } from "../portfolio/[uid]/query";
const data = [ const data = [
{ {
@ -174,7 +174,6 @@ export default function Dashboard() {
</TabsTrigger> </TabsTrigger>
))} ))}
</TabsList> </TabsList>
{currentProjectId}
{projects.map((project) => ( {projects.map((project) => (
<TabsContent value={project.project_name} className="space-y-4"> <TabsContent value={project.project_name} className="space-y-4">
<div className="grid gap-4 md:grid-cols-2 lg:grid-cols-4"> <div className="grid gap-4 md:grid-cols-2 lg:grid-cols-4">
@ -282,7 +281,22 @@ export default function Dashboard() {
<CardTitle>Overview</CardTitle> <CardTitle>Overview</CardTitle>
</CardHeader> </CardHeader>
<CardContent className="pl-2"> <CardContent className="pl-2">
<Overview graphType={graphType} data={data} /> <Overview
graphType={graphType}
data={overAllGraphData(
investmentDetail?.data
?.map((deal) => {
if (deal.project_id === currentProjectId) {
return {
deal_amount: deal.deal_amount,
created_time: deal.created_time,
};
}
return undefined;
})
.filter((deal) => deal !== undefined) as Deal[]
)}
/>
{/* tab to switch between line and bar graph */} {/* tab to switch between line and bar graph */}
<Tabs defaultValue="line" className="space-y-4 ml-[50%] mt-2"> <Tabs defaultValue="line" className="space-y-4 ml-[50%] mt-2">
<TabsList> <TabsList>

View File

@ -105,7 +105,7 @@ async function getBusinessTypeName(supabase: SupabaseClient, projectId: number)
} }
// only use deal that were made at most year ago // only use deal that were made at most year ago
interface Deal { export interface Deal {
created_time: string | number | Date; created_time: string | number | Date;
deal_amount: any; deal_amount: any;
} }