diff --git a/src/app/api/dealApi.ts b/src/app/api/dealApi.ts index 7cdaa0d..cd56925 100644 --- a/src/app/api/dealApi.ts +++ b/src/app/api/dealApi.ts @@ -5,7 +5,6 @@ export type Deal = { created_time: Date; investor_id: string; }; -const supabase = createSupabaseClient(); export async function getDealList(userId: string | undefined) { if (!userId) { diff --git a/src/app/dashboard/hook.ts b/src/app/dashboard/hook.ts index 676d249..0b2cdb8 100644 --- a/src/app/dashboard/hook.ts +++ b/src/app/dashboard/hook.ts @@ -10,7 +10,7 @@ export function useDealList() { const fetchDealList = async () => { // set the state to the deal list of current business user setDealList(await getDealList(await getCurrentUserID())); - } + }; useEffect(() => { fetchDealList(); @@ -28,7 +28,7 @@ export function useGraphData() { if (dealList) { setGraphData(convertToGraphData(dealList)); } - } + }; useEffect(() => { fetchGraphData(); @@ -43,11 +43,11 @@ export function useRecentDealData() { const fetchRecentDealData = async () => { // set the state to the deal list of current business user setRecentDealData(await getRecentDealData(await getCurrentUserID())); - } + }; useEffect(() => { fetchRecentDealData(); }, []); return recentDealData; -} \ No newline at end of file +} diff --git a/src/app/dashboard/page.tsx b/src/app/dashboard/page.tsx index e59b7f3..d506482 100644 --- a/src/app/dashboard/page.tsx +++ b/src/app/dashboard/page.tsx @@ -6,18 +6,73 @@ import { Overview } from "@/components/ui/overview"; import { RecentFunds } from "@/components/recent-funds"; import { useState } from "react"; -import { useDealList, useGraphData, useRecentDealData } from "./hook"; -import { sumByKey } from "@/lib/utils"; +import { useDealList } from "./hook"; + +const data = [ + { + name: "Jan", + value: Math.floor(Math.random() * 5000) + 1000, + }, + { + name: "Feb", + value: Math.floor(Math.random() * 5000) + 1000, + }, + { + name: "Mar", + value: Math.floor(Math.random() * 5000) + 1000, + }, + { + name: "Apr", + value: Math.floor(Math.random() * 5000) + 1000, + }, + { + name: "May", + value: Math.floor(Math.random() * 5000) + 1000, + }, + { + name: "Jun", + value: Math.floor(Math.random() * 5000) + 1000, + }, + { + name: "Jul", + value: Math.floor(Math.random() * 5000) + 1000, + }, + { + name: "Aug", + value: Math.floor(Math.random() * 5000) + 1000, + }, + { + name: "Sep", + value: Math.floor(Math.random() * 5000) + 1000, + }, + { + name: "Oct", + value: Math.floor(Math.random() * 5000) + 1000, + }, + { + name: "Nov", + value: Math.floor(Math.random() * 5000) + 1000, + }, + { + name: "Dec", + value: Math.floor(Math.random() * 5000) + 1000, + }, +]; export default function Dashboard() { const [graphType, setGraphType] = useState("line"); - const graphData = useGraphData(); const dealList = useDealList(); - // #TODO dependency injection refactor + define default value inside function (and not here) - const recentDealData = useRecentDealData() || []; + const totalDealAmount = dealList?.reduce((sum, deal) => sum + deal.deal_amount, 0) || 0; return ( <> + {dealList?.map((deal, index) => ( +
Deal Amount: {deal.deal_amount}
+Created Time: {new Date(deal.created_time).toUTCString()}
+Investor ID: {deal.investor_id}
++20.1% from last month
*/} @@ -150,7 +205,7 @@ export default function Dashboard() {