mirror of
https://github.com/Sosokker/B2D-Ventures.git
synced 2025-12-18 21:44:06 +01:00
feat: add investment query functionality to dashboard
This commit is contained in:
parent
a1158907fb
commit
fa554bfb51
@ -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) {
|
||||
|
||||
@ -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")
|
||||
|
||||
Loading…
Reference in New Issue
Block a user