diff --git a/src/components/FloorPopup.tsx b/src/components/FloorPopup.tsx index 9ad827d..d868553 100644 --- a/src/components/FloorPopup.tsx +++ b/src/components/FloorPopup.tsx @@ -86,7 +86,7 @@ function FloorPopup({ title, complexName, data, onSelect }: FloorPopupProps) { {count}
- {formattedUnitTypes.get(unitType)} + {formattedUnitTypes.get(unitType) || unitType}
)) diff --git a/src/components/SearchFilters.tsx b/src/components/SearchFilters.tsx index 49bf06d..a56fdcc 100644 --- a/src/components/SearchFilters.tsx +++ b/src/components/SearchFilters.tsx @@ -91,11 +91,18 @@ function SearchFilters({ .json- {formattedUnitTypes.get(unitType)} + {formattedUnitTypes.get(unitType) || unitType}
))} diff --git a/src/components/UnitCard.tsx b/src/components/UnitCard.tsx index 1a3753f..2710f94 100644 --- a/src/components/UnitCard.tsx +++ b/src/components/UnitCard.tsx @@ -84,7 +84,7 @@ function UnitCard({ unit }: { unit: Unit }) {{`${formattedUnitTypes.get( unit.unitType - )}, ${unit.squareFt.toLocaleString(undefined, { + ) || unit.unitType}, ${unit.squareFt.toLocaleString(undefined, { maximumFractionDigits: 2, })} Sqft`}
diff --git a/src/components/UnitPopup.tsx b/src/components/UnitPopup.tsx index c422939..368aad8 100644 --- a/src/components/UnitPopup.tsx +++ b/src/components/UnitPopup.tsx @@ -31,7 +31,7 @@ function UnitPopup({- {formattedUnitTypes.get(unitType)} + {formattedUnitTypes.get(unitType) || unitType}
- {formattedUnitTypes.get(unit.unitType)}
+ {formattedUnitTypes.get(unit.unitType) || unit.unitType}
{`, ${unit.squareFt.toLocaleString(undefined, {
maximumFractionDigits: 2,
diff --git a/src/pages/FloorsPage.tsx b/src/pages/FloorsPage.tsx
index 5684aee..c89dc26 100644
--- a/src/pages/FloorsPage.tsx
+++ b/src/pages/FloorsPage.tsx
@@ -2,7 +2,7 @@ import FloorSelect, { FloorsData } from "../components/FloorSelect";
import { useParams } from "react-router";
import FloorSidebar from "../components/FloorSidebar";
-import { useState, useMemo } from "react";
+import { useState, useMemo, useEffect } from "react";
import { useQuery } from "@tanstack/react-query";
import { api } from "../api/ky";
import { SPECIAL_FLOORS } from "../constants/floors";
@@ -19,6 +19,11 @@ function FloorsPage() {
complexName: ComplexName;
}>();
+ // Reset selectedFloor when complexName changes to prevent race condition
+ useEffect(() => {
+ setSelectedFloor(null);
+ }, [complexName]);
+
const { data: floorsData } = useQuery({
queryKey: ["floors-data", complexName],
queryFn: () =>
diff --git a/src/pages/SearchPage.tsx b/src/pages/SearchPage.tsx
index 6206774..6dd356a 100644
--- a/src/pages/SearchPage.tsx
+++ b/src/pages/SearchPage.tsx
@@ -123,15 +123,15 @@ function SearchPage() {
useEffect(() => {
if (allFloors) setFloor([allFloors.min, allFloors.max]);
- }, [allFloors]);
+ }, [allFloors, project]); // Add project dependency to reset when project changes
useEffect(() => {
if (allCost) setCost([allCost.min, allCost.max]);
- }, [allCost]);
+ }, [allCost, project]); // Add project dependency to reset when project changes
useEffect(() => {
if (allArea) setArea([allArea.min, allArea.max]);
- }, [allArea]);
+ }, [allArea, project]); // Add project dependency to reset when project changes
const { data, fetchNextPage, isLoading, hasNextPage, isFetchingNextPage } =
useInfiniteQuery({
@@ -199,6 +199,10 @@ function SearchPage() {
useEffect(() => {
setSelectedUnitTypes([]);
setView("Any view");
+ // Reset filters to prevent race condition with old filter data
+ setCost([-1, -1]);
+ setFloor([-1, -1]);
+ setArea([-1, -1]);
}, [project]);
return (
diff --git a/src/pages/UnitPage.tsx b/src/pages/UnitPage.tsx
index 112efbf..8875679 100644
--- a/src/pages/UnitPage.tsx
+++ b/src/pages/UnitPage.tsx
@@ -139,7 +139,7 @@ function UnitPage() {
{unit.project}
- {formattedUnitTypes.get(unit.unitType)}
+ {formattedUnitTypes.get(unit.unitType) || unit.unitType}