mirror of
https://github.com/Hestia-Homes/assessment-model.git
synced 2026-06-30 12:55:02 +00:00
retructured urls of search to sit under portfolio
This commit is contained in:
parent
aca66cc8ca
commit
431c416f2d
3 changed files with 9 additions and 15 deletions
|
|
@ -3,7 +3,7 @@
|
|||
import { Menu } from "@headlessui/react";
|
||||
import Link from "next/link";
|
||||
|
||||
export default function AddNew() {
|
||||
export default function AddNew({ portfolioId }: { portfolioId: string }) {
|
||||
return (
|
||||
<Menu as="div" className="relative">
|
||||
<Menu.Button className="rounded-md bg-brandmidblue text-white hover:bg-brandblue">
|
||||
|
|
@ -12,7 +12,7 @@ export default function AddNew() {
|
|||
<Menu.Items className="hover:bg-brandtan absolute right-0 mt-2 w-48 origin-top-right overflow-hidden rounded-md border bg-white shadow-lg focus:outline-none">
|
||||
<Menu.Item>
|
||||
<Link
|
||||
href="/search"
|
||||
href={`portfolio/${portfolioId}/search`}
|
||||
className="flex px-4 py-2 text-sm text-gray-700 justify-start"
|
||||
>
|
||||
Add Unit
|
||||
|
|
|
|||
|
|
@ -93,7 +93,7 @@ export default async function Page({
|
|||
<div className="flex justify-center">
|
||||
<div className="grid w-full max-w-7xl ">
|
||||
<div className="flex justify-end">
|
||||
<AddNew />
|
||||
<AddNew portfolioId={demo_id} />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
"use client";
|
||||
|
||||
import { useState } from "react";
|
||||
import SearchPostcodeButton from "../components/search/SearchPostcodeButton";
|
||||
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";
|
||||
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";
|
||||
|
|
@ -13,7 +13,7 @@ const defaultToggleClass =
|
|||
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() {
|
||||
export default function Search({ params }: { params: { slug: string } }) {
|
||||
const [postcode, setPostcode] = useState("");
|
||||
const [buttonDisabled, setButtonDisabled] = useState(true);
|
||||
const [data, setData] = useState<null | SearchData>(null);
|
||||
|
|
@ -24,12 +24,6 @@ export default function Search() {
|
|||
const [currentlyToggled, setCurrentlyToggled] = useState("");
|
||||
const router = useRouter();
|
||||
|
||||
// Do something better than logging the error
|
||||
// Should probablt redirect to a something went wrong page
|
||||
const redirectToSearch = () => {
|
||||
router.push(`/addresses?postcode=${postcode}`);
|
||||
};
|
||||
|
||||
const handleSubmit = (e: React.KeyboardEvent<HTMLInputElement>) => {
|
||||
if (e.key === "Enter") {
|
||||
e.preventDefault();
|
||||
|
|
@ -72,8 +66,8 @@ export default function Search() {
|
|||
(row: SearchResult) => row["lmk-key"] === currentlyToggled
|
||||
);
|
||||
|
||||
const portfolioId = "portfolioId";
|
||||
const propertyId = "propertyId";
|
||||
const portfolioId = params.slug;
|
||||
const propertyId = res ? ["lmk-key"] : "";
|
||||
|
||||
router.push(`/portfolio/${portfolioId}/property/${propertyId}`);
|
||||
};
|
||||
Loading…
Add table
Reference in a new issue