-
Plan
+
+
+
{title}
+
+
+
+
CO2 Emissions: {co2Emissions}
+
+
+
Work Hours: {workHours}
+
);
+};
+
+export default function Plan({
+ params,
+ searchParams,
+}: {
+ params: { slug: string; lmkKey: string };
+ searchParams: { [key: string]: string | string[] | undefined };
+}) {
+ const router = useRouter();
+
+ const portfolioId = params.slug;
+ const lmkKey = params.lmkKey;
+ const postcode = searchParams.postcode;
+ const targetEpcRating = searchParams.targetEpcRating ?? "C";
+
+ const [budget, setBudget] = useState("Not set");
+ const [totalCost, setTotalCost] = useState("Not set");
+ const [installTime, setInstallTime] = useState("Not set");
+
+ if (postcode === undefined) {
+ router.push(`/portfolio/${portfolioId}/error`);
+ }
+
+ const { data, error, isLoading } = useQuery
({
+ queryKey: ["search", postcode],
+ queryFn: async () => fetchData(postcode as string),
+ });
+
+ // TODO: Add a loading state and error handling
+ if (isLoading) {
+ return Loading...
;
+ }
+
+ if (error) {
+ return Error fetching data: {error.message}
;
+ }
+
+ const propertyData = data.rows.filter((row) => row["lmk-key"] === lmkKey)[0];
+ return (
+
+
+
+
Your Retrofit Plan
+
{propertyData.address}
+
+
+
+ {/* Clickable Cards */}
+ {/* Replace this with your actual clickable cards */}
+
+
+ Clickable Card 2
+
+ {/* Add more clickable cards as needed */}
+
+
+
+
Summary
+
+ -
+ Target EPC: {targetEpcRating}
+
+
+ - Total cost: {totalCost}
+ - Budget: {budget}
+ - Installation Time: {installTime}
+ {/* flex items-center text-brandmidblue hover:text-brandblue transition-colors duration-200 cursor-pointer */}
+ -
+ Edit Property Details
+
+
+
+
+
+
+
+
+ );
}
diff --git a/src/app/portfolio/[slug]/property/[lmkKey]/utils.tsx b/src/app/portfolio/[slug]/property/[lmkKey]/utils.tsx
new file mode 100644
index 00000000..14c826d5
--- /dev/null
+++ b/src/app/portfolio/[slug]/property/[lmkKey]/utils.tsx
@@ -0,0 +1,14 @@
+import { SearchData } from "@/types/epc";
+
+export async function fetchData(postcode: string): Promise {
+ // TODO - add strict typing to the api response
+
+ const response = await fetch(`/api/search?postcode=${postcode}`);
+
+ if (!response.ok) {
+ // This will activate the closest `error.js` Error Boundary
+ throw new Error("Failed to fetch data");
+ }
+
+ return response.json();
+}
diff --git a/src/app/portfolio/[slug]/search/layout.tsx b/src/app/portfolio/[slug]/search/layout.tsx
new file mode 100644
index 00000000..091be683
--- /dev/null
+++ b/src/app/portfolio/[slug]/search/layout.tsx
@@ -0,0 +1,20 @@
+import BackToPortfolio from "@/app/components/portfolio/BackToPortfolio";
+
+export default function Layout({
+ children,
+ params,
+}: {
+ children: React.ReactNode;
+ params: { slug: string; lmkKey: string };
+}) {
+ const portfolioId = params.slug;
+
+ return (
+
+ );
+}