mirror of
https://github.com/Hestia-Homes/assessment-model.git
synced 2026-06-30 12:55:02 +00:00
gets portfolio id from db
This commit is contained in:
parent
8016cc6f26
commit
7a6b6c12bb
4 changed files with 35 additions and 15 deletions
|
|
@ -1 +1 @@
|
|||
npm install;
|
||||
npm install;
|
||||
|
|
|
|||
|
|
@ -16,3 +16,4 @@ export const hubspotCompanyData = pgTable("hubspot_company_data", {
|
|||
.$onUpdate(() => new Date())
|
||||
.notNull(),
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@ interface SurveyedPieChartProps {
|
|||
deals: Record<string, any>[];
|
||||
onOpenTable?: (outcome: string, filteredDeals: Record<string, any>[]) => void;
|
||||
}
|
||||
|
||||
export default function SurveyedPieChart({
|
||||
deals,
|
||||
onOpenTable,
|
||||
|
|
|
|||
|
|
@ -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 (
|
||||
<div className="text-center text-gray-500 mt-8">
|
||||
No information to show.
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
// 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 (
|
||||
<>
|
||||
<LiveTracker deals={deals} />
|
||||
</>
|
||||
);
|
||||
};
|
||||
console.log("Deals:", deals);
|
||||
|
||||
export default Demo;
|
||||
if (!deals || deals.length === 0) {
|
||||
return (
|
||||
<div className="text-center text-gray-500 mt-8">
|
||||
No information to show.
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
return <LiveTracker deals={deals} />;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue