diff --git a/src/app/portfolio/[slug]/components/propertyTable.tsx b/src/app/portfolio/[slug]/components/propertyTable.tsx index 3095a7b..5c009b8 100644 --- a/src/app/portfolio/[slug]/components/propertyTable.tsx +++ b/src/app/portfolio/[slug]/components/propertyTable.tsx @@ -34,19 +34,7 @@ interface DataTableProps { function fetchData(offset: number) { // Because this is a client component, this will be handled with react query let properties: PropertyWithTarget[] = []; - for (let i = offset; i <= offset + 20; i++) { - properties.push({ - id: i, - portfolioId: 1, - address: `${i}23 Fake Street`, - postcode: `AB${i} 2CD`, - creationStatus: Math.random() < 0.5 ? "complete" : "loading", - status: "assessment", - target: { epc: "C" }, - cost: 1000, - }); - } - + // TODO: implement this return properties; } diff --git a/src/app/portfolio/[slug]/components/propertyTablePagination.tsx b/src/app/portfolio/[slug]/components/propertyTablePagination.tsx index 4bb22ca..006a089 100644 --- a/src/app/portfolio/[slug]/components/propertyTablePagination.tsx +++ b/src/app/portfolio/[slug]/components/propertyTablePagination.tsx @@ -7,7 +7,6 @@ import { import { Table } from "@tanstack/react-table"; import { Button } from "@/app/shadcn_components/ui/button"; -import { useEffect } from "react"; interface DataTablePaginationProps { table: Table; diff --git a/src/app/portfolio/[slug]/page.tsx b/src/app/portfolio/[slug]/page.tsx index 414e518..d40552f 100644 --- a/src/app/portfolio/[slug]/page.tsx +++ b/src/app/portfolio/[slug]/page.tsx @@ -204,7 +204,12 @@ export default async function Page({ energyCostSavings, } = await getPortfolio(portfolioId); - const properties: PropertyWithTarget[] = await getProperties(portfolioId); + // Default limit to 1000 and offset to 0 for now - will handle pagination later + const properties: PropertyWithTarget[] = await getProperties( + portfolioId, + 1000, + 0 + ); return ( <> diff --git a/src/app/portfolio/[slug]/plan-loading/page.tsx b/src/app/portfolio/[slug]/plan-loading/page.tsx index d06e2bc..253c32a 100644 --- a/src/app/portfolio/[slug]/plan-loading/page.tsx +++ b/src/app/portfolio/[slug]/plan-loading/page.tsx @@ -1,28 +1,52 @@ "use client"; import { useRouter } from "next/navigation"; +import { useState, useEffect } from "react"; export default function LoadingPage({ params }: { params: { slug: string } }) { const portfolioId = params.slug; const router = useRouter(); + const [countdown, setCountdown] = useState(10); // Initialize countdown state to 10 seconds const handleBackToPortfolio = () => { if (portfolioId) { - router.push(`/portfolio/${portfolioId}?status=loading`); + router.push(`/portfolio/${portfolioId}`); } else { router.push(`/home`); } }; + useEffect(() => { + // If countdown reaches zero, redirect the user + if (countdown === 0) { + handleBackToPortfolio(); + return; + } + + // Set up interval to decrease countdown by 1 every second + const timer = setInterval(() => { + setCountdown((prevCountdown) => prevCountdown - 1); + }, 1000); + + // Clean up the interval when the component unmounts + return () => clearInterval(timer); + }, [countdown, handleBackToPortfolio]); + return (

We're building your portfolio plan

-
+
This could take a few minutes. Thank you for your patience.
+
+ Click on 'Go back to portfolio'. +
+
+ We'll redirect you automatically in {countdown} seconds... +