mirror of
https://github.com/Sosokker/B2D-Ventures.git
synced 2025-12-19 05:54:06 +01:00
refactor: update investor_id retrieve logic + snake case db atr
This commit is contained in:
parent
57c8841709
commit
fc6368f54e
@ -83,12 +83,11 @@ const CheckoutPage = ({
|
|||||||
const supabase = createSupabaseClient();
|
const supabase = createSupabaseClient();
|
||||||
const { data, error } = await supabase.from("investment_deal").insert([
|
const { data, error } = await supabase.from("investment_deal").insert([
|
||||||
{
|
{
|
||||||
investorId: investor_id,
|
investor_id: investor_id,
|
||||||
projectId: project_id,
|
project_id: project_id,
|
||||||
dealAmount: amount,
|
deal_amount: amount,
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
console.log("ADADSADWADWWAD");
|
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
console.error("Supabase Insert Error:", error.message);
|
console.error("Supabase Insert Error:", error.message);
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { useRouter } from "next/navigation";
|
import { useRouter } from "next/navigation";
|
||||||
import { useParams } from "next/navigation";
|
import { useParams } from "next/navigation";
|
||||||
import { Separator } from "@/components/ui/separator";
|
import { Separator } from "@/components/ui/separator";
|
||||||
@ -52,13 +52,26 @@ const term_data = [
|
|||||||
export default function InvestPage() {
|
export default function InvestPage() {
|
||||||
const [checkedTerms, setCheckedTerms] = useState(Array(term_data.length).fill(false));
|
const [checkedTerms, setCheckedTerms] = useState(Array(term_data.length).fill(false));
|
||||||
const [investAmount, setInvestAmount] = useState(10);
|
const [investAmount, setInvestAmount] = useState(10);
|
||||||
|
const [investor_id, setInvestorId] = useState<string>("");
|
||||||
const { session } = useSession();
|
|
||||||
const investor_id = session!.user.id;
|
|
||||||
|
|
||||||
const params = useParams<{ id: string }>();
|
const params = useParams<{ id: string }>();
|
||||||
const supabase = createSupabaseClient();
|
const supabase = createSupabaseClient();
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const fetchInvestorData = async () => {
|
||||||
|
const { data, error } = await supabase.auth.getSession();
|
||||||
|
if (error) {
|
||||||
|
console.error("Error fetching session:", error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (data.session) {
|
||||||
|
setInvestorId(data.session.user.id);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
fetchInvestorData();
|
||||||
|
}, [supabase]);
|
||||||
|
|
||||||
const { data: projectData, isLoading: isLoadingProject } = useQuery(getProjectDataQuery(supabase, Number(params.id)));
|
const { data: projectData, isLoading: isLoadingProject } = useQuery(getProjectDataQuery(supabase, Number(params.id)));
|
||||||
|
|
||||||
const handleCheckboxChange = (index: number) => {
|
const handleCheckboxChange = (index: number) => {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user