mirror of
https://github.com/Sosokker/B2D-Ventures.git
synced 2025-12-22 23:44:04 +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 useSession from "@/lib/supabase/useSession";
|
||||||
import { getProjectByUserId } from "@/lib/data/projectQuery";
|
import { getProjectByUserId } from "@/lib/data/projectQuery";
|
||||||
import { Loader } from "@/components/loading/loader";
|
import { Loader } from "@/components/loading/loader";
|
||||||
|
import { getInvestmentByProjectsIds } from "@/lib/data/investmentQuery";
|
||||||
|
import { useQuery } from "@supabase-cache-helpers/postgrest-react-query";
|
||||||
|
|
||||||
const data = [
|
const data = [
|
||||||
{
|
{
|
||||||
@ -69,6 +71,14 @@ export default function Dashboard() {
|
|||||||
>([]);
|
>([]);
|
||||||
const [isSuccess, setIsSuccess] = useState(false);
|
const [isSuccess, setIsSuccess] = useState(false);
|
||||||
const [graphType, setGraphType] = useState("line");
|
const [graphType, setGraphType] = useState("line");
|
||||||
|
const investmentDetail = useQuery(
|
||||||
|
getInvestmentByProjectsIds(
|
||||||
|
supabase,
|
||||||
|
projects.map((item) => {
|
||||||
|
return item.id.toString();
|
||||||
|
})
|
||||||
|
)
|
||||||
|
);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const fetchProjects = async () => {
|
const fetchProjects = async () => {
|
||||||
if (userId) {
|
if (userId) {
|
||||||
|
|||||||
@ -10,6 +10,10 @@ export const getInvestmentCountsByProjectsIds = (client: SupabaseClient, project
|
|||||||
.in("project_id", projectIds);
|
.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) => {
|
export const getInvestmentByUserId = (client: SupabaseClient, userId: string) => {
|
||||||
return client
|
return client
|
||||||
.from("investment_deal")
|
.from("investment_deal")
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user