diff --git a/.devcontainer/post-install.sh b/.devcontainer/post-install.sh index 9f018f38..c847f6d5 100644 --- a/.devcontainer/post-install.sh +++ b/.devcontainer/post-install.sh @@ -1 +1 @@ -npm install; \ No newline at end of file +npm install; diff --git a/src/app/db/schema/crm/hubspot_company_table.ts b/src/app/db/schema/crm/hubspot_company_table.ts index 71aa4193..618da191 100644 --- a/src/app/db/schema/crm/hubspot_company_table.ts +++ b/src/app/db/schema/crm/hubspot_company_table.ts @@ -16,3 +16,4 @@ export const hubspotCompanyData = pgTable("hubspot_company_data", { .$onUpdate(() => new Date()) .notNull(), }); + diff --git a/src/app/portfolio/[slug]/(portfolio)/live-projects/SurveyedResultsPieChart.tsx b/src/app/portfolio/[slug]/(portfolio)/live-projects/SurveyedResultsPieChart.tsx index 7cb0d3c0..d5919abc 100644 --- a/src/app/portfolio/[slug]/(portfolio)/live-projects/SurveyedResultsPieChart.tsx +++ b/src/app/portfolio/[slug]/(portfolio)/live-projects/SurveyedResultsPieChart.tsx @@ -7,7 +7,6 @@ interface SurveyedPieChartProps { deals: Record[]; onOpenTable?: (outcome: string, filteredDeals: Record[]) => void; } - export default function SurveyedPieChart({ deals, onOpenTable, diff --git a/src/app/portfolio/[slug]/(portfolio)/live-projects/page.tsx b/src/app/portfolio/[slug]/(portfolio)/live-projects/page.tsx index 08a5a3b9..7eb6dedf 100644 --- a/src/app/portfolio/[slug]/(portfolio)/live-projects/page.tsx +++ b/src/app/portfolio/[slug]/(portfolio)/live-projects/page.tsx @@ -3,11 +3,13 @@ import { AuthOptions } from "@/app/api/auth/[...nextauth]/authOptions"; import { redirect } from "next/navigation"; import { surveyDB } from "../../../../db/surveyDB/connection"; import { hubspotDealData } from "../../../../db/schema/crm/hubspot_deal_table"; +import { hubspotCompanyData } from "@/app/db/schema/crm/hubspot_company_table"; import { eq } from "drizzle-orm"; -import Reports from "./Report"; import LiveTracker from "./Report"; -const Demo = async () => { +export default async function Demo(props: { + params: Promise<{ slug: string }>; +}) { const user = await getServerSession(AuthOptions); if (!user?.user) { @@ -15,20 +17,38 @@ const Demo = async () => { redirect("/"); } - // Abri company id - const companyId = "237615001799"; + const { slug: portfolioId } = await props.params; + // Fetch the single company + const [company] = await surveyDB + .select() + .from(hubspotCompanyData) + .where(eq(hubspotCompanyData.groupId, portfolioId)); + + if (!company) { + console.log("No company found for this portfolioId"); + return ( +
+ No information to show. +
+ ); + } + + // Fetch deals related to that company const deals = await surveyDB .select() .from(hubspotDealData) - .where(eq(hubspotDealData.companyId, companyId)); - console.log(deals); + .where(eq(hubspotDealData.companyId, company.companyId)); - return ( - <> - - - ); -}; + console.log("Deals:", deals); -export default Demo; \ No newline at end of file + if (!deals || deals.length === 0) { + return ( +
+ No information to show. +
+ ); + } + + return ; +}