Skip to content

Commit

Permalink
feat: enhance dashboard overview with overall graph data and export D…
Browse files Browse the repository at this point in the history
…eal interface
  • Loading branch information
GGWPXXXX committed Nov 7, 2024
1 parent 9b37b76 commit 4c42b5e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
20 changes: 17 additions & 3 deletions src/app/dashboard/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { getProjectByUserId } from "@/lib/data/projectQuery";
import { Loader } from "@/components/loading/loader";
import { getInvestmentByProjectsIds } from "@/lib/data/investmentQuery";
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 = [
{
Expand Down Expand Up @@ -174,7 +174,6 @@ export default function Dashboard() {
</TabsTrigger>
))}
</TabsList>
{currentProjectId}
{projects.map((project) => (
<TabsContent value={project.project_name} className="space-y-4">
<div className="grid gap-4 md:grid-cols-2 lg:grid-cols-4">
Expand Down Expand Up @@ -282,7 +281,22 @@ export default function Dashboard() {
<CardTitle>Overview</CardTitle>
</CardHeader>
<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 */}
<Tabs defaultValue="line" className="space-y-4 ml-[50%] mt-2">
<TabsList>
Expand Down
2 changes: 1 addition & 1 deletion src/app/portfolio/[uid]/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ async function getBusinessTypeName(supabase: SupabaseClient, projectId: number)
}

// only use deal that were made at most year ago
interface Deal {
export interface Deal {
created_time: string | number | Date;
deal_amount: any;
}
Expand Down

0 comments on commit 4c42b5e

Please sign in to comment.