diff --git a/package-lock.json b/package-lock.json index 827099c6..ccd0d7c8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -47,7 +47,7 @@ "eslint-config-next": "13.4.3", "framer-motion": "^12.23.24", "lucide-react": "^0.233.0", - "next": "^15.4.2", + "next": "^15.5.7", "next-auth": "^4.22.1", "next-axiom": "^1.9.2", "next-themes": "^0.3.0", diff --git a/package.json b/package.json index 41c47e89..2f908b37 100644 --- a/package.json +++ b/package.json @@ -53,7 +53,7 @@ "eslint-config-next": "13.4.3", "framer-motion": "^12.23.24", "lucide-react": "^0.233.0", - "next": "^15.4.2", + "next": "^15.5.7", "next-auth": "^4.22.1", "next-axiom": "^1.9.2", "next-themes": "^0.3.0", diff --git a/src/app/portfolio/[slug]/(portfolio)/layout.tsx b/src/app/portfolio/[slug]/(portfolio)/layout.tsx index 05d20208..f997ae62 100644 --- a/src/app/portfolio/[slug]/(portfolio)/layout.tsx +++ b/src/app/portfolio/[slug]/(portfolio)/layout.tsx @@ -5,7 +5,7 @@ import * as React from "react"; export default async function PortfolioLayout(props: { children: React.ReactNode; - params: Promise<{ slug: string; propertyId: string }>; + params: Promise<{ slug: string }>; }) { const params = await props.params; diff --git a/src/app/portfolio/[slug]/building-passport/[propertyId]/layout.tsx b/src/app/portfolio/[slug]/building-passport/[propertyId]/layout.tsx index ba669f7c..7b5b3335 100644 --- a/src/app/portfolio/[slug]/building-passport/[propertyId]/layout.tsx +++ b/src/app/portfolio/[slug]/building-passport/[propertyId]/layout.tsx @@ -4,7 +4,6 @@ import BackToPortfolioButton from "@/app/components/building-passport/BackToPort import { ExclamationCircleIcon } from "@heroicons/react/24/outline"; // import "@tremor/react/dist/esm/tremor.css"; - function EstimatedDataNotification() { return (
@@ -27,7 +26,6 @@ export default async function DashboardLayout(props: { const propertyId = params.propertyId ?? ""; const portfolioId = params.slug ?? ""; - // The layout is a server component by default so we can fetch meta data here const propertyMeta = await getPropertyMeta(params.propertyId); diff --git a/src/app/portfolio/[slug]/search/layout.tsx b/src/app/portfolio/[slug]/search/layout.tsx deleted file mode 100644 index 47c1ae15..00000000 --- a/src/app/portfolio/[slug]/search/layout.tsx +++ /dev/null @@ -1,25 +0,0 @@ -import BackToPortfolio from "@/app/components/portfolio/BackToPortfolio"; - -export default async function Layout( - props: { - children: React.ReactNode; - params: Promise<{ slug: string; lmkKey: string }>; - } -) { - const params = await props.params; - - const { - children - } = props; - - const portfolioId = params.slug; - - return ( -
-
- -
- {children} -
- ); -} diff --git a/src/app/portfolio/[slug]/search/page.tsx b/src/app/portfolio/[slug]/search/page.tsx deleted file mode 100644 index 3305e161..00000000 --- a/src/app/portfolio/[slug]/search/page.tsx +++ /dev/null @@ -1,145 +0,0 @@ -"use client"; - -import { useState, use } from "react"; -import SearchPostcodeButton from "../../../components/search/SearchPostcodeButton"; -import { useRouter } from "next/navigation"; -import { SearchData, SearchResult } from "@/types/epc"; -import SelectAddressButton from "../../../components/search/SelectAddressButton"; -import ToggleAddressButton from "../../../components/search/ToggleAddressButton"; - -const defaultToggleClass = - "mb-1 block max-w-sm rounded-lg border border-gray-200 bg-white p-6 shadow hover:bg-gray-100 dark:border-gray-700 dark:bg-gray-800 dark:hover:bg-gray-700"; - -const toggledButtonClass = - "text-white mb-1 block max-w-sm rounded-lg border border-gray-200 bg-brandblue p-6 shadow hover:bg-hoverblue dark:border-gray-700 dark:bg-gray-800 dark:hover:bg-gray-700"; - -export default function Search(props: { params: Promise<{ slug: string }> }) { - const params = use(props.params); - const [postcode, setPostcode] = useState(""); - const [buttonDisabled, setButtonDisabled] = useState(true); - const [data, setData] = useState(null); - const [address, setAddress] = useState(""); - const [addressButtonDisabled, setAddressButtonDisabled] = useState(true); - // Keep track of which lmk-key is currently toggled. Initially, none - // are toggled - const [currentlyToggled, setCurrentlyToggled] = useState(""); - const router = useRouter(); - - const handleSubmit = (e: React.KeyboardEvent) => { - if (e.key === "Enter") { - e.preventDefault(); - fetchData().catch((error) => { - console.log(error); - }); - } - }; - - const handlePostcodeChange = (e: React.ChangeEvent) => { - // If the text is empty, disable the button, otherwise enable it - setPostcode(e.target.value); - if (e.target.value) { - setButtonDisabled(false); - return; - } - setButtonDisabled(true); - return; - }; - - // TODO: This might take a moment to fetch data, add a loading state? - async function fetchData() { - // TODO - add strict typing to the api response - setCurrentlyToggled(""); - setAddressButtonDisabled(true); - try { - const response = await fetch(`/api/search?postcode=${postcode}`); - const data = (await response.json()) as SearchData; - - setData(data); - } catch (error) { - console.error("Error fetching data:", error); - } - } - - const redirectToProperty = () => { - if (data === null) return; - - const res = data.rows.find( - (row: SearchResult) => row["lmk-key"] === currentlyToggled - ) as SearchResult; - - const portfolioId = params.slug; - const lmkKey = res["lmk-key"]; - - router.push( - `/portfolio/${portfolioId}/property/${lmkKey}?postcode=${postcode}` - ); - }; - - const submitProps = { - buttonDisabled: buttonDisabled, - onClickFunc: fetchData, - }; - - return ( -
-
-
- We will search for the most recent data about your property, so we can - begin to build a profile of the works that can be done and the impact - that will have -
-
- -
- -
- - - {data && ( -
-
- Scroll to find your address from the list -
-
    - {data.rows.map((row: SearchResult) => { - return ( - - ); - })} -
-
- -
-
- )} -
-
- ); -}