diff --git a/src/app/dashboard/page.tsx b/src/app/dashboard/page.tsx index d95c6f2..9eb0d3c 100644 --- a/src/app/dashboard/page.tsx +++ b/src/app/dashboard/page.tsx @@ -9,6 +9,8 @@ import { createSupabaseClient } from "@/lib/supabase/clientComponentClient"; import useSession from "@/lib/supabase/useSession"; 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"; const data = [ { @@ -69,6 +71,14 @@ export default function Dashboard() { >([]); const [isSuccess, setIsSuccess] = useState(false); const [graphType, setGraphType] = useState("line"); + const investmentDetail = useQuery( + getInvestmentByProjectsIds( + supabase, + projects.map((item) => { + return item.id.toString(); + }) + ) + ); useEffect(() => { const fetchProjects = async () => { if (userId) { diff --git a/src/app/dashboard/hook.ts b/src/app/dashboard/query.ts similarity index 100% rename from src/app/dashboard/hook.ts rename to src/app/dashboard/query.ts diff --git a/src/lib/data/investmentQuery.ts b/src/lib/data/investmentQuery.ts index da17b3b..bba485f 100644 --- a/src/lib/data/investmentQuery.ts +++ b/src/lib/data/investmentQuery.ts @@ -10,6 +10,10 @@ export const getInvestmentCountsByProjectsIds = (client: SupabaseClient, project .in("project_id", projectIds); }; +export const getInvestmentByProjectsIds = (client: SupabaseClient, projectIds: string[]) => { + return client.from("investment_deal").select("*").in("project_id", projectIds); +}; + export const getInvestmentByUserId = (client: SupabaseClient, userId: string) => { return client .from("investment_deal")