diff --git a/src/app/(customer)/location/search/page.tsx b/src/app/(customer)/location/search/page.tsx index c339b5c..2008af2 100644 --- a/src/app/(customer)/location/search/page.tsx +++ b/src/app/(customer)/location/search/page.tsx @@ -1,4 +1,5 @@ import { winofyFetch, type PaginatedResponse } from "@/lib/api/winofy"; +import { getLocationServer } from "@/lib/location/server"; import type { Neighborhood } from "@/types/api"; import { NeighborhoodSearch } from "@/components/location/neighborhood-search"; @@ -11,6 +12,7 @@ async function getNeighborhoods() { } export default async function NeighborhoodSearchPage() { - const neighborhoods = await getNeighborhoods(); - return ; + const [neighborhoods, location] = await Promise.all([getNeighborhoods(), getLocationServer()]); + const selectedNeighborhoodUuid = location?.mode === "manual" ? location.neighborhoodUuid : null; + return ; } diff --git a/src/components/location/neighborhood-search.tsx b/src/components/location/neighborhood-search.tsx index 6bb2dc4..9e293d3 100644 --- a/src/components/location/neighborhood-search.tsx +++ b/src/components/location/neighborhood-search.tsx @@ -2,13 +2,19 @@ import { useMemo, useState } from "react"; import { useRouter, useSearchParams } from "next/navigation"; -import { ArrowRight, MapPin, Search, SearchX } from "lucide-react"; -import { setLocation } from "@/lib/location/client"; +import { ArrowRight, Check, MapPin, Search, SearchX, X } from "lucide-react"; +import { setLocation, clearLocation } from "@/lib/location/client"; import type { Neighborhood } from "@/types/api"; // L06 (+ neighborhood-search-results) unified — winofyfrontenddoc (1).md §4.3. // idle / results / empty share ~90% of layout, per the doc's own recommendation. -export function NeighborhoodSearch({ neighborhoods }: { neighborhoods: Neighborhood[] }) { +export function NeighborhoodSearch({ + neighborhoods, + selectedNeighborhoodUuid, +}: { + neighborhoods: Neighborhood[]; + selectedNeighborhoodUuid: string | null; +}) { const router = useRouter(); const searchParams = useSearchParams(); const next = searchParams.get("next") ?? "/"; @@ -37,17 +43,25 @@ export function NeighborhoodSearch({ neighborhoods }: { neighborhoods: Neighborh router.refresh(); } + function deselectNeighborhood() { + clearLocation(); + router.push(next); + router.refresh(); + } + function NeighborhoodRow({ n }: { n: Neighborhood }) { + const isSelected = n.uuid === selectedNeighborhoodUuid; return ( ); } @@ -81,6 +95,17 @@ export function NeighborhoodSearch({ neighborhoods }: { neighborhoods: Neighborh /> + {selectedNeighborhoodUuid && ( + + )} + {state === "empty" && (