From 47ab151843ac4146683743727a78f3bf60d235ba Mon Sep 17 00:00:00 2001 From: inmake Date: Mon, 26 Jan 2026 16:21:16 +0500 Subject: [PATCH] Update unit type display logic across multiple components to fallback on unitType if formatted type is unavailable; enhance search filters to ensure proper initialization and reset behavior; add new brochures to project data for improved resource availability. --- src/components/FloorPopup.tsx | 2 +- src/components/SearchFilters.tsx | 24 ++++++++----- src/components/SelectedComplexCard.tsx | 2 +- src/components/UnitCard.tsx | 2 +- src/components/UnitPopup.tsx | 2 +- src/components/UnitTypesSelect.tsx | 2 +- src/components/ui/BrochureButton.tsx | 2 +- src/data/brochures.ts | 49 ++++++++++++++++++++------ src/data/formattedUnitTypes.ts | 4 --- src/pages/FavoritesPage.tsx | 2 +- src/pages/FloorsPage.tsx | 7 +++- src/pages/SearchPage.tsx | 10 ++++-- src/pages/UnitPage.tsx | 2 +- 13 files changed, 75 insertions(+), 35 deletions(-) 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(), enabled: !!project && - !!allUnitTypes && - !!allCost.min && - !!allFloors.min && - !!allArea.min && - !!allViews.length, + allUnitTypes !== undefined && + allCost !== undefined && + allFloors !== undefined && + allArea !== undefined && + allViews !== undefined && + // Wait until filters are initialized to prevent duplicate requests + cost[0] >= 0 && + cost[1] >= 0 && + floor[0] >= 0 && + floor[1] >= 0 && + area[0] >= 0 && + area[1] >= 0, }); function handleSelectProject(project: Project | null) { @@ -125,9 +132,10 @@ function SearchFilters({ function resetFilters() { setView("Any view"); setSelectedUnitTypes([]); - setCost([allCost?.min || -1, allCost?.max || -1]); - setFloor([allFloors?.min || -1, allFloors?.max || -1]); - setArea([allArea?.min || -1, allArea?.max || -1]); + // Use actual min/max values if available, otherwise use 0 to keep query enabled + if (allCost) setCost([allCost.min, allCost.max]); + if (allFloors) setFloor([allFloors.min, allFloors.max]); + if (allArea) setArea([allArea.min, allArea.max]); if (inModal) setInModal(false); } diff --git a/src/components/SelectedComplexCard.tsx b/src/components/SelectedComplexCard.tsx index 458c80d..916d009 100644 --- a/src/components/SelectedComplexCard.tsx +++ b/src/components/SelectedComplexCard.tsx @@ -75,7 +75,7 @@ function SelectedComplexCard({ 4

- {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}

{wing && ( diff --git a/src/components/UnitTypesSelect.tsx b/src/components/UnitTypesSelect.tsx index 28a85df..57c9970 100644 --- a/src/components/UnitTypesSelect.tsx +++ b/src/components/UnitTypesSelect.tsx @@ -38,7 +38,7 @@ function UnitTypesSelect({ : "ring-[#E2E2DC] text-[#0D1922]/70" )} > - {formattedUnitTypes.get(unitType)} + {formattedUnitTypes.get(unitType) || unitType}

))}
diff --git a/src/components/ui/BrochureButton.tsx b/src/components/ui/BrochureButton.tsx index bdb65f0..c7ef9af 100644 --- a/src/components/ui/BrochureButton.tsx +++ b/src/components/ui/BrochureButton.tsx @@ -26,7 +26,7 @@ export default function BrochureButton({ onClick={handleDownload} > {title} - + diff --git a/src/data/brochures.ts b/src/data/brochures.ts index 44ce5f6..3c10c6e 100644 --- a/src/data/brochures.ts +++ b/src/data/brochures.ts @@ -24,6 +24,14 @@ export const projectBrochures: ProjectBrochures[] = [ title: "Technical Brochure", link: "/files/brochures/marasi-drive/Technical Brochure.pdf", }, + { + title: "Factsheet", + link: "/files/brochures/marasi-drive/Factsheet.pdf", + }, + { + title: "Reasons to buy", + link: "/files/brochures/marasi-drive/Reasons to buy.pdf", + }, ], }, { @@ -38,8 +46,24 @@ export const projectBrochures: ProjectBrochures[] = [ link: "/files/brochures/downtown/Amenities Brochure.pdf", }, { - title: "Technical Brochure", - link: "/files/brochures/downtown/Technical Brochure.pdf", + title: "Factsheet", + link: "/files/brochures/downtown/Factsheet.pdf", + }, + { + title: "Reasons to buy", + link: "/files/brochures/downtown/Reasons to buy.pdf", + }, + { + title: "Typical Floor plan 14-19", + link: "/files/brochures/downtown/Typical Floor plan 14-19.pdf", + }, + { + title: "Typical Floor plan 2-13", + link: "/files/brochures/downtown/Typical Floor plan 2-13.pdf", + }, + { + title: "Unit Plan", + link: "/files/brochures/downtown/Unit Plan.pdf", }, ], }, @@ -58,18 +82,21 @@ export const projectBrochures: ProjectBrochures[] = [ title: "Technical Brochure", link: "/files/brochures/dubai-marina/Technical Brochure.pdf", }, - ], - }, - { - projectTitle: "Rove Home HQ", - brochures: [ { - title: "Main Brochure", - link: "/files/brochures/hq/Main Brochure.pdf", + title: "Factsheet", + link: "/files/brochures/dubai-marina/Factsheet.pdf", }, { - title: "Technical Brochure", - link: "/files/brochures/hq/Technical Brochure.pdf", + title: "RHDM Arabic", + link: "/files/brochures/dubai-marina/RHDM Arabic.pdf", + }, + { + title: "RHDM Russian", + link: "/files/brochures/dubai-marina/RHDM Russian.pdf", + }, + { + title: "RHDM Turkish", + link: "/files/brochures/dubai-marina/RHDM Turkish.pdf", }, ], }, diff --git a/src/data/formattedUnitTypes.ts b/src/data/formattedUnitTypes.ts index 63a4fdf..09f92db 100644 --- a/src/data/formattedUnitTypes.ts +++ b/src/data/formattedUnitTypes.ts @@ -1,13 +1,9 @@ export const formattedUnitTypes = new Map([ - ["1 Bedroom Combined Type C", "1 Bedroom Combined Type C"], - ["1 Bedroom Combined Type D", "1 Bedroom Combined Type D"], ["1 BR Squared", "1 Bedroom²"], ["One Bedroom Square", "1 Bedroom²"], ["2 BR Squared", "2 Bedroom²"], - ["2 Bedroom Combined", "2 Bedroom Combined"], ["One Bedroom Loft", "1 Bedroom Loft"], ["Two Bedroom Loft", "2 Bedroom Loft"], - ["Studio Flex", "Studio Flex"], ["Studio Square", "Studio²"], ["Studio Squared", "Studio²"], ]); diff --git a/src/pages/FavoritesPage.tsx b/src/pages/FavoritesPage.tsx index 7c1f93c..7412ec1 100644 --- a/src/pages/FavoritesPage.tsx +++ b/src/pages/FavoritesPage.tsx @@ -230,7 +230,7 @@ function FavoritesPage() {

- {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() {

- {formattedUnitTypes.get(unit.unitType)} + {formattedUnitTypes.get(unit.unitType) || unit.unitType}

{unit.project}