diff --git a/src/app/dashboard/hook.ts b/src/app/dashboard/hook.ts index 0b2cdb8..e69de29 100644 --- a/src/app/dashboard/hook.ts +++ b/src/app/dashboard/hook.ts @@ -1,53 +0,0 @@ -import { useEffect, useState } from "react"; -import { Deal, getDealList, convertToGraphData, getRecentDealData } from "../api/dealApi"; -import { RecentDealData } from "@/components/recent-funds"; -import { getCurrentUserID } from "../api/userApi"; - -// custom hook for deal list -export function useDealList() { - const [dealList, setDealList] = useState([]); - - const fetchDealList = async () => { - // set the state to the deal list of current business user - setDealList(await getDealList(await getCurrentUserID())); - }; - - useEffect(() => { - fetchDealList(); - }, []); - - return dealList; -} - -export function useGraphData() { - const [graphData, setGraphData] = useState({}); - - const fetchGraphData = async () => { - // fetch the state to the deal list of current business user - const dealList = await getDealList(await getCurrentUserID()); - if (dealList) { - setGraphData(convertToGraphData(dealList)); - } - }; - - useEffect(() => { - fetchGraphData(); - }, []); - - return graphData; -} - -export function useRecentDealData() { - const [recentDealData, setRecentDealData] = useState(); - - const fetchRecentDealData = async () => { - // set the state to the deal list of current business user - setRecentDealData(await getRecentDealData(await getCurrentUserID())); - }; - - useEffect(() => { - fetchRecentDealData(); - }, []); - - return recentDealData; -} diff --git a/src/app/dashboard/page.tsx b/src/app/dashboard/page.tsx index 78f14b9..d95c6f2 100644 --- a/src/app/dashboard/page.tsx +++ b/src/app/dashboard/page.tsx @@ -5,7 +5,6 @@ import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs"; import { Overview } from "@/components/ui/overview"; import { RecentFunds } from "@/components/recent-funds"; import { useEffect, useState } from "react"; -import { useDealList } from "./hook"; import { createSupabaseClient } from "@/lib/supabase/clientComponentClient"; import useSession from "@/lib/supabase/useSession"; import { getProjectByUserId } from "@/lib/data/projectQuery"; @@ -70,8 +69,6 @@ export default function Dashboard() { >([]); const [isSuccess, setIsSuccess] = useState(false); const [graphType, setGraphType] = useState("line"); - const dealList = useDealList(); - const totalDealAmount = dealList?.reduce((sum, deal) => sum + deal.deal_amount, 0) || 0; useEffect(() => { const fetchProjects = async () => { if (userId) { @@ -91,6 +88,7 @@ export default function Dashboard() { }; fetchProjects(); }, [supabase, userId]); + // console.table(projects); return ( <> @@ -116,7 +114,7 @@ export default function Dashboard() {

Business Dashboard

- + {projects.map((project) => ( @@ -124,81 +122,82 @@ export default function Dashboard() { ))} - -
- - - Total Funds Raised - - - - - -
${totalDealAmount}
- {/*

+ {projects.map((project) => ( + +

+ + + Total Funds Raised + + + + + +
${}
+ {/*

+20.1% from last month

*/} -
-
- - - Profile Views - - - - - - -
+2350
- {/*

+ + + + + Profile Views + + + + + + +

+2350
+ {/*

+180.1% from last month

*/} -
-
- - - Total Followers - - - - - - - -
+12,234
- {/*

+ + + + + Total Followers + + + + + + + +

+12,234
+ {/*

+19% from last month

*/} -
-
- {/* + + + {/* Active Now @@ -223,38 +222,39 @@ export default function Dashboard() {

*/} -
-
- - - Overview - - - - {/* tab to switch between line and bar graph */} - - - setGraphType("line")}> - Line - - setGraphType("bar")}> - Bar - - - - - - - - Recent Funds - You made {dealList?.length || 0} sales this month. - - - - - -
- +
+
+ + + Overview + + + + {/* tab to switch between line and bar graph */} + + + setGraphType("line")}> + Line + + setGraphType("bar")}> + Bar + + + + + + + + Recent Funds + You had {} investors invest this month. + + + + + +
+
+ ))}