"use client"; import React, { useMemo, useState } from "react"; import useSession from "@/lib/supabase/useSession"; import { MeetEventDialog } from "./MeetEventDialog"; import { Clock } from "lucide-react"; import { Separator } from "@/components/ui/separator"; import { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle } from "@/components/ui/card"; import { Table, TableBody, TableCaption, TableCell, TableHeader, TableHead, TableRow, TableFooter, } from "@/components/ui/table"; import { Button } from "@/components/ui/button"; import { useQuery } from "@supabase-cache-helpers/postgrest-react-query"; import { getInvestmentByUserId } from "@/lib/data/investmentQuery"; import { LegacyLoader } from "@/components/loading/LegacyLoader"; import { createSupabaseClient } from "@/lib/supabase/clientComponentClient"; interface Investment { id: any; project_id: any; project_name: any; project_short_description: any; dataroom_id: any; deal_amount: any; investor_id: any; created_time: any; } const DatetimePickerHourCycle = () => { const supabase = createSupabaseClient(); const [showModal, setShowModal] = useState(false); const [currentProjectName, setCurrentProjectName] = useState(""); const [currentProjectId, setCurrentProjectId] = useState(undefined); const { session, loading } = useSession(); const { data: investments = [], error: investmentsError, isLoading: isLoadingInvestments, } = useQuery(getInvestmentByUserId(supabase, session?.user.id ?? ""), { enabled: !!session?.user.id, }); if (investmentsError) { throw "Error load investment data"; } const projectInvestments = useMemo(() => { if (!investments) return {}; return investments.reduce((acc: { [key: string]: Investment[] }, investment: Investment) => { const projectId = investment.project_id; if (!acc[projectId]) { acc[projectId] = []; } acc[projectId].push(investment); return acc; }, {}); }, [investments]); if (loading) { return ; } if (!session || !session?.user.id) { throw "Can't load session!"; } if (isLoadingInvestments) { return ; } return (

Schedule Meeting

{Object.entries(projectInvestments).map(([projectId, projectInvestments]) => ( {projectInvestments[0].project_name} {projectInvestments[0].project_short_description} Investments for this project Investment Id Invested At Amount {projectInvestments.map((investment) => ( {investment.id} {investment.created_time} {investment.deal_amount} ))} Total {projectInvestments .reduce((total, investment) => total + (parseFloat(investment.deal_amount) || 0), 0) .toLocaleString("en-US", { style: "currency", currency: "USD" })}
))}
{ setShowModal(open); if (!open) { setCurrentProjectId(undefined); setCurrentProjectName(""); } }} session={session} projectName={currentProjectName} projectId={currentProjectId!} />
); }; export default DatetimePickerHourCycle;