"use client"; import Image from "next/image"; import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card"; 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 { getBusinessByUserId } from "@/lib/data/businessQuery"; import { useDealList } from "./hook"; import { createSupabaseClient } from "@/lib/supabase/clientComponentClient"; import { useQuery } from "@supabase-cache-helpers/postgrest-react-query"; import useSession from "@/lib/supabase/useSession"; import { getProjectByUserId } from "@/lib/data/projectQuery"; 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() { let supabase = createSupabaseClient(); const userId = useSession().session?.user.id; const [projects, setProjects] = useState< { id: number; project_name: string; business_id: { user_id: number }[]; dataroom_id: number }[] >([]); 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) { const { data, error } = await getProjectByUserId(supabase, userId); // alert(JSON.stringify(data)); if (error) { console.error("Error while fetching projects"); } if (data) { setProjects(data); console.table(data); } } else { console.error("Error with UserId while fetching projects"); } }; fetchProjects(); }, [supabase, userId]); return ( <>
+20.1% from last month
*/}+180.1% from last month
*/}+19% from last month
*/}+201 since last hour