-
- ABOUT THE DEVELOPER
-
-
-
-
- IRTH’s vision is long-term, supported with a proactive approach,
- swift actions, strong financial backing, and high-quality
- projects - bridging the gap between ambition and success. IRTH
- continues seeking new opportunities and broadening horizons –
- thriving in any market situation through an extensive land bank
- and strategic partnerships.
-
-
- At IRTH, we take pride in offering the best-inclass locations
- and properties for value-based investment opportunities -
- setting new standards in the real estate market in the region.
- We are IRTH – The Future of Real Estate.
-
-
-
+
+
-
-
-
+
+
- {/* MAIN CONSULTANTS */}
-
-
+
+
+ Founded under Alshamsi family, IRTH is a real estate investment
+ platform - based on the philosophy of value creation, innovation and
+ building world-class living experiences.
+
+
+
+ ABOUT THE DEVELOPER
+
+
+
+
+
+
+
+ IRTH’s vision is long-term, supported with a proactive
+ approach, swift actions, strong financial backing, and
+ high-quality projects - bridging the gap between ambition
+ and success. IRTH continues seeking new opportunities and
+ broadening horizons – thriving in any market situation
+ through an extensive land bank and strategic partnerships.
+
+
+ At IRTH, we take pride in offering the best-inclass
+ locations and properties for value-based investment
+ opportunities - setting new standards in the real estate
+ market in the region. We are IRTH – The Future of Real
+ Estate.
+
+
+
+
Learn more
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
Landscape architect
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Sales and marketing
-
-
-
+
+
-
+
);
}
diff --git a/client/src/pages/FavoritesPage.tsx b/client/src/pages/FavoritesPage.tsx
index cede359..e1a6ed1 100644
--- a/client/src/pages/FavoritesPage.tsx
+++ b/client/src/pages/FavoritesPage.tsx
@@ -1,237 +1,325 @@
-import { useState, useEffect } from "react";
-import { sortCardBy } from "../calc/sortCard";
+// import { useState } from "react";
+// import ChevronDownIcon from "../components/icons/ChevronDownIcon";
+import useFavoritesStore from "../store/useFavoritesStore";
+import useModal from "../store/useModal";
+import HeartIcon from "../components/icons/HeartIcon";
+import UnitModalForSearchPage from "../components/modals/UnitModalForSearchPage";
+import unitTypes from "../data/unitTypes.json";
+import HeartFilledIcon from "../components/icons/HeartFilledIcon";
import Button from "../components/Button";
-import Footer from "../components/Footer";
-import TrashIcon from "../components/icons/TrashIcon";
-import SortButton from "../components/searchPage/SortButton";
-import { initialSortList } from "../consts/initialMasterplanFilters";
-import Switch from "../components/Switch";
-import { ISwitcher } from "../types/switcher";
-import FavoritesSlider from "../components/favoritesPage/FavoriteSlider";
-import FavoriteCardList from "../components/favoritesPage/FavoriteCardList";
-import useFavorites from "../store/useFavorites";
+import BookingIcon from "../components/icons/BookingIcon";
+import IUnit from "../types/IUnit";
-// const favoriteCards: ILayoutCard[] = [
-// {
-// id: "1",
-// roveHome: "Marasi Drive",
-// apartmentType: "Studio Flex",
-// wing: "East Wing",
-// floorStart: 11,
-// floorEnd: 35,
-// units: 234,
-// cost: 10488888,
-// square: 619,
-// },
-// {
-// id: "2",
-// roveHome: "Marasi Drive",
-// apartmentType: "1 Bedroom",
-// wing: "East Wing",
-// floorStart: 11,
-// floorEnd: 35,
-// units: 234,
-// cost: 1668888,
-// square: 619,
-// },
-// {
-// id: "3",
-// roveHome: "Marasi Drive",
-// apartmentType: "1 Bedroom",
-// wing: "East Wing",
-// floorStart: 11,
-// floorEnd: 35,
-// units: 234,
-// cost: 1668888,
-// square: 609,
-// },
-// {
-// id: "4",
-// roveHome: "Marasi Drive",
-// apartmentType: "1 Bedroom",
-// wing: "East Wing",
-// floorStart: 11,
-// floorEnd: 35,
-// units: 234,
-// cost: 1138888,
-// square: 609,
-// },
-// {
-// id: "5",
-// roveHome: "Marasi Drive",
-// apartmentType: "Studio Flex",
-// wing: "East Wing",
-// floorStart: 11,
-// floorEnd: 35,
-// units: 234,
-// cost: 10488888,
-// square: 609,
-// },
-// {
-// id: "6",
-// roveHome: "Marasi Drive",
-// apartmentType: "1 Bedroom",
-// wing: "East Wing",
-// floorStart: 11,
-// floorEnd: 35,
-// units: 234,
-// cost: 1668888,
-// square: 609,
-// },
-// {
-// id: "7",
-// roveHome: "Marasi Drive",
-// apartmentType: "1 Bedroom",
-// wing: "East Wing",
-// floorStart: 11,
-// floorEnd: 35,
-// units: 234,
-// cost: 1668888,
-// square: 609,
-// },
-// {
-// id: "8",
-// roveHome: "Marasi Drive",
-// apartmentType: "1 Bedroom",
-// wing: "East Wing",
-// floorStart: 11,
-// floorEnd: 35,
-// units: 234,
-// cost: 1138888,
-// square: 609,
-// },
-// {
-// id: "9",
-// roveHome: "Marasi Drive",
-// apartmentType: "Studio Flex",
-// wing: "East Wing",
-// floorStart: 11,
-// floorEnd: 35,
-// units: 234,
-// cost: 10488888,
-// square: 609,
-// },
-// {
-// id: "10",
-// roveHome: "Marasi Drive",
-// apartmentType: "1 Bedroom",
-// wing: "East Wing",
-// floorStart: 11,
-// floorEnd: 35,
-// units: 234,
-// cost: 1668888,
-// square: 609,
-// },
-// {
-// id: "11",
-// roveHome: "Marasi Drive",
-// apartmentType: "1 Bedroom",
-// wing: "East Wing",
-// floorStart: 11,
-// floorEnd: 35,
-// units: 234,
-// cost: 1668888,
-// square: 609,
-// },
-// {
-// id: "12",
-// roveHome: "Marasi Drive",
-// apartmentType: "1 Bedroom",
-// wing: "East Wing",
-// floorStart: 11,
-// floorEnd: 35,
-// units: 234,
-// cost: 1138888,
-// square: 609,
-// },
-// ];
+function FavoritesPage() {
+ const { favoriteUnits, setFavoriteUnits } = useFavoritesStore();
+ // const [isSortPriceAsc, setIsSortPriceAsc] = useState(false);
+ const { setModal } = useModal();
-const initialCollectionCompareSwitcher: ISwitcher = {
- id: "1",
- title: "collection/compare",
- isSwitched: false,
-};
+ function getTypeByUnitNo(unitNo: string) {
+ const side = unitNo[0] === "E" ? "East" : "West";
+ const floor = Number(unitNo.split("-")[1].slice(0, -2));
+ const number = Number(unitNo.split("-")[1].slice(-2));
-const FavoritesPage = () => {
- const [sortList, setSortList] = useState(initialSortList);
- const [switcher, setSwitcher] = useState(initialCollectionCompareSwitcher);
- const { favorites, setFavorites } = useFavorites();
+ console.log(side, floor, number);
- const handleOnSortClick = (sortId: string) => {
- const updatedSortList = sortList.map((sort) => {
- const isSelected = sort.id === sortId;
- return { ...sort, isSelected: isSelected };
- });
- setSortList(updatedSortList);
- };
-
- const handleOnSwitchClick = () => {
- setSwitcher((prev) => {
- return { ...prev, isSwitched: !prev.isSwitched };
- });
- };
-
- const handleOnDeleteFavoriteClick = () => {
- localStorage.removeItem("Favorites");
- setFavorites([]);
- };
-
- useEffect(() => {
- const favoriteCards = localStorage.getItem("Favorites");
- if (favoriteCards) {
- const convertedCards = JSON.parse(favoriteCards);
- const sortedCards = sortCardBy(sortList, convertedCards);
- setFavorites(sortedCards);
+ if (side === "East") {
+ if ([1].includes(number)) {
+ return "2br-type-a";
+ } else if ([2, 4, 5, 11, 12, 13, 14].includes(number)) {
+ return "studio-2";
+ } else if ([3].includes(number)) {
+ return "1br-type-d";
+ } else if ([6, 7, 10, 15, 16].includes(number)) {
+ return "1br-type-c";
+ } else if ([8, 9].includes(number)) {
+ return "1br-type-b";
+ }
+ } else if (side === "West") {
+ if (floor <= 21) {
+ // Floors 5-21
+ if ([1].includes(number)) {
+ return "2br-type-a";
+ } else if ([2, 4, 5].includes(number)) {
+ return "studio-2";
+ } else if ([3, 6].includes(number)) {
+ return "1br-type-d";
+ } else if ([7, 8].includes(number)) {
+ return "1br-type-a";
+ } else if ([9, 10, 11, 12, 13, 14].includes(number)) {
+ return "studio-flex";
+ } else if ([15, 16].includes(number)) {
+ return "1br-type-c";
+ } else if ([17].includes(number)) {
+ return "2br-type-b";
+ }
+ } else {
+ // Floors 24-31
+ if ([1].includes(number)) {
+ return "2br-type-a";
+ } else if ([2, 4, 5, 10, 11].includes(number)) {
+ return "studio-2";
+ } else if ([3, 6, 9, 12].includes(number)) {
+ return "1br-type-d";
+ } else if ([7, 8].includes(number)) {
+ return "1br-type-a";
+ } else if ([13, 14].includes(number)) {
+ return "1br-type-c";
+ } else if ([15].includes(number)) {
+ return "2br-type-b";
+ }
+ }
}
- }, [setFavorites, sortList]);
+
+ // TODO Connect to DB
+
+ return "";
+ }
+
+ function getImageSrc(unitNo: string): string {
+ const side = unitNo[0];
+ const floor = Number(unitNo.split("-")[1].slice(0, -2));
+ const unitNumber = Number(unitNo.split("-")[1].slice(-2));
+
+ if (side === "W") {
+ // Side "W"
+ if (floor < 24) {
+ switch (unitNumber) {
+ case 1:
+ return "/images/layouts/2br_a_left.png";
+ case 2:
+ return "/images/layouts/studio_left.png";
+ case 3:
+ return "/images/layouts/1br_d_left.png";
+ case 4:
+ return "/images/layouts/studio_left.png";
+ case 5:
+ return "/images/layouts/studio_left.png";
+ case 6:
+ return "/images/layouts/1br_d_left.png";
+ case 7:
+ return "/images/layouts/1br_a_left.png";
+ case 8:
+ return "/images/layouts/1br_a_left.png";
+ case 9:
+ return "/images/layouts/studio_flex_left.png";
+ case 10:
+ return "/images/layouts/studio_flex_left.png";
+ case 11:
+ return "/images/layouts/studio_flex_left.png";
+ case 12:
+ return "/images/layouts/studio_flex_left.png";
+ case 13:
+ return "/images/layouts/studio_flex_left.png";
+ case 14:
+ return "/images/layouts/studio_flex_left.png";
+ case 15:
+ return "/images/layouts/1br_c_left.png";
+ case 16:
+ return "/images/layouts/1br_c_left.png";
+ case 17:
+ return "/images/layouts/2br_b_left.png";
+ }
+ } else {
+ switch (unitNumber) {
+ case 1:
+ return "/images/layouts/2br_a_left.png";
+ case 2:
+ return "/images/layouts/studio_left.png";
+ case 3:
+ return "/images/layouts/1br_d_left.png";
+ case 4:
+ return "/images/layouts/studio_left.png";
+ case 5:
+ return "/images/layouts/studio_left.png";
+ case 6:
+ return "/images/layouts/1br_d_left.png";
+ case 7:
+ return "/images/layouts/1br_a_left.png";
+ case 8:
+ return "/images/layouts/1br_a_left.png";
+ case 9:
+ return "/images/layouts/1br_d_left.png";
+ case 10:
+ return "/images/layouts/studio_left.png";
+ case 11:
+ return "/images/layouts/studio_left.png";
+ case 12:
+ return "/images/layouts/1br_d_left.png";
+ case 13:
+ return "/images/layouts/1br_c_left.png";
+ case 14:
+ return "/images/layouts/1br_c_left.png";
+ case 15:
+ return "/images/layouts/2br_b_left.png";
+ }
+ }
+ } else {
+ // Side "E"
+ switch (unitNumber) {
+ case 1:
+ return "/images/layouts/2br_a_left.png";
+ case 2:
+ return "/images/layouts/studio_left.png";
+ case 3:
+ return "/images/layouts/1br_d_left.png";
+ case 4:
+ return "/images/layouts/studio_left.png";
+ case 5:
+ return "/images/layouts/studio_left.png";
+ case 6:
+ return "/images/layouts/1br_c_left.png";
+ case 7:
+ return "/images/layouts/1br_c_left.png";
+ case 8:
+ return "/images/layouts/1br_b_left.png";
+ case 9:
+ return "/images/layouts/1br_b_left.png";
+ case 10:
+ return "/images/layouts/1br_c_left.png";
+ case 11:
+ return "/images/layouts/studio_left.png";
+ case 12:
+ return "/images/layouts/studio_left.png";
+ case 13:
+ return "/images/layouts/studio_left.png";
+ case 14:
+ return "/images/layouts/studio_left.png";
+ case 15:
+ return "/images/layouts/1br_c_left.png";
+ case 16:
+ return "/images/layouts/1br_c_left.png";
+ }
+ }
+
+ console.log(side, floor, unitNumber);
+
+ return "";
+ }
+
+ function addOrRemoveFromFavorites(unit: IUnit) {
+ if (!favoriteUnits.some((favoriteUnit) => favoriteUnit.id === unit.id)) {
+ setFavoriteUnits([...favoriteUnits, unit]);
+ } else {
+ setFavoriteUnits(
+ favoriteUnits.filter((favoriteUnit) => favoriteUnit.id !== unit.id)
+ );
+ }
+ }
return (
-
-
-
-
-
-
-
Units
-
{favorites.length}
-
-
-
-
-
-
}
- className="text-[#73787C]"
- text="Remove all"
- onClick={handleOnDeleteFavoriteClick}
- />
-
-
- Collection
-
-
-
- Compare
-
-
-
-
-
+
+
+
+
+ Favorites {" "}
+ {favoriteUnits.length}
+
+ {/*
setIsSortPriceAsc((prev) => !prev)}
+ >
+ Sort by ascending price
+
+ */}
+
+
+ {favoriteUnits.map((unit) => (
+
+
+
+
{unit.projectName}
+
+
+ {unit.unitNo[0] === "E" ? "East" : "West"} Wing
+
+
+
{unit.floor}
+
+
{unit.unitNo}
+
+
+
addOrRemoveFromFavorites(unit)}
+ >
+ {favoriteUnits.some(
+ (favoriteUnit) => favoriteUnit.id === unit.id
+ ) ? (
+
+ ) : (
+
+ )}
+
+
+
+ setModal(
+
+ unitType.type === getTypeByUnitNo(unit.unitNo)
+ )?.type || ""
+ }
+ />
+ )
+ }
+ >
+
+
+
+ setModal(
+
+ unitType.type === getTypeByUnitNo(unit.unitNo)
+ )?.type || ""
+ }
+ />
+ )
+ }
+ >
+
+ {unit.unitType}, {unit.totalArea} Sqft
+
+
+ {(unit.unitPrice &&
+ `AED ${unit.unitPrice.toLocaleString()}`) ||
+ "Unavailable"}
+
+
+
+ }
+ text="Send Enquiry"
+ className="justify-center text-sm disabled:hover:bg-[#ECEDEE] w-full"
+ disabled
+ />
+
+
+ ))}
- {switcher.isSwitched ?
:
}
-
);
-};
+}
export default FavoritesPage;
diff --git a/client/src/pages/FavoritesPage2.tsx b/client/src/pages/FavoritesPage2.tsx
deleted file mode 100644
index a456a1a..0000000
--- a/client/src/pages/FavoritesPage2.tsx
+++ /dev/null
@@ -1,325 +0,0 @@
-// import { useState } from "react";
-// import ChevronDownIcon from "../components/icons/ChevronDownIcon";
-import useFavoritesStore from "../store/useFavoritesStore";
-import useModal from "../store/useModal";
-import HeartIcon from "../components/icons/HeartIcon";
-import UnitModalForSearchPage from "../components/modals/UnitModalForSearchPage";
-import unitTypes from "../data/unitTypes.json";
-import HeartFilledIcon from "../components/icons/HeartFilledIcon";
-import Button from "../components/Button";
-import BookingIcon from "../components/icons/BookingIcon";
-import IUnit from "../types/IUnit";
-
-function FavoritesPage2() {
- const { favoriteUnits, setFavoriteUnits } = useFavoritesStore();
- // const [isSortPriceAsc, setIsSortPriceAsc] = useState(false);
- const { setModal } = useModal();
-
- function getTypeByUnitNo(unitNo: string) {
- const side = unitNo[0] === "E" ? "East" : "West";
- const floor = Number(unitNo.split("-")[1].slice(0, -2));
- const number = Number(unitNo.split("-")[1].slice(-2));
-
- console.log(side, floor, number);
-
- if (side === "East") {
- if ([1].includes(number)) {
- return "2br-type-a";
- } else if ([2, 4, 5, 11, 12, 13, 14].includes(number)) {
- return "studio-2";
- } else if ([3].includes(number)) {
- return "1br-type-d";
- } else if ([6, 7, 10, 15, 16].includes(number)) {
- return "1br-type-c";
- } else if ([8, 9].includes(number)) {
- return "1br-type-b";
- }
- } else if (side === "West") {
- if (floor <= 21) {
- // Floors 5-21
- if ([1].includes(number)) {
- return "2br-type-a";
- } else if ([2, 4, 5].includes(number)) {
- return "studio-2";
- } else if ([3, 6].includes(number)) {
- return "1br-type-d";
- } else if ([7, 8].includes(number)) {
- return "1br-type-a";
- } else if ([9, 10, 11, 12, 13, 14].includes(number)) {
- return "studio-flex";
- } else if ([15, 16].includes(number)) {
- return "1br-type-c";
- } else if ([17].includes(number)) {
- return "2br-type-b";
- }
- } else {
- // Floors 24-31
- if ([1].includes(number)) {
- return "2br-type-a";
- } else if ([2, 4, 5, 10, 11].includes(number)) {
- return "studio-2";
- } else if ([3, 6, 9, 12].includes(number)) {
- return "1br-type-d";
- } else if ([7, 8].includes(number)) {
- return "1br-type-a";
- } else if ([13, 14].includes(number)) {
- return "1br-type-c";
- } else if ([15].includes(number)) {
- return "2br-type-b";
- }
- }
- }
-
- // TODO Connect to DB
-
- return "";
- }
-
- function getImageSrc(unitNo: string): string {
- const side = unitNo[0];
- const floor = Number(unitNo.split("-")[1].slice(0, -2));
- const unitNumber = Number(unitNo.split("-")[1].slice(-2));
-
- if (side === "W") {
- // Side "W"
- if (floor < 24) {
- switch (unitNumber) {
- case 1:
- return "/images/layouts/2br_a_left.png";
- case 2:
- return "/images/layouts/studio_left.png";
- case 3:
- return "/images/layouts/1br_d_left.png";
- case 4:
- return "/images/layouts/studio_left.png";
- case 5:
- return "/images/layouts/studio_left.png";
- case 6:
- return "/images/layouts/1br_d_left.png";
- case 7:
- return "/images/layouts/1br_a_left.png";
- case 8:
- return "/images/layouts/1br_a_left.png";
- case 9:
- return "/images/layouts/studio_flex_left.png";
- case 10:
- return "/images/layouts/studio_flex_left.png";
- case 11:
- return "/images/layouts/studio_flex_left.png";
- case 12:
- return "/images/layouts/studio_flex_left.png";
- case 13:
- return "/images/layouts/studio_flex_left.png";
- case 14:
- return "/images/layouts/studio_flex_left.png";
- case 15:
- return "/images/layouts/1br_c_left.png";
- case 16:
- return "/images/layouts/1br_c_left.png";
- case 17:
- return "/images/layouts/2br_b_left.png";
- }
- } else {
- switch (unitNumber) {
- case 1:
- return "/images/layouts/2br_a_left.png";
- case 2:
- return "/images/layouts/studio_left.png";
- case 3:
- return "/images/layouts/1br_d_left.png";
- case 4:
- return "/images/layouts/studio_left.png";
- case 5:
- return "/images/layouts/studio_left.png";
- case 6:
- return "/images/layouts/1br_d_left.png";
- case 7:
- return "/images/layouts/1br_a_left.png";
- case 8:
- return "/images/layouts/1br_a_left.png";
- case 9:
- return "/images/layouts/1br_d_left.png";
- case 10:
- return "/images/layouts/studio_left.png";
- case 11:
- return "/images/layouts/studio_left.png";
- case 12:
- return "/images/layouts/1br_d_left.png";
- case 13:
- return "/images/layouts/1br_c_left.png";
- case 14:
- return "/images/layouts/1br_c_left.png";
- case 15:
- return "/images/layouts/2br_b_left.png";
- }
- }
- } else {
- // Side "E"
- switch (unitNumber) {
- case 1:
- return "/images/layouts/2br_a_left.png";
- case 2:
- return "/images/layouts/studio_left.png";
- case 3:
- return "/images/layouts/1br_d_left.png";
- case 4:
- return "/images/layouts/studio_left.png";
- case 5:
- return "/images/layouts/studio_left.png";
- case 6:
- return "/images/layouts/1br_c_left.png";
- case 7:
- return "/images/layouts/1br_c_left.png";
- case 8:
- return "/images/layouts/1br_b_left.png";
- case 9:
- return "/images/layouts/1br_b_left.png";
- case 10:
- return "/images/layouts/1br_c_left.png";
- case 11:
- return "/images/layouts/studio_left.png";
- case 12:
- return "/images/layouts/studio_left.png";
- case 13:
- return "/images/layouts/studio_left.png";
- case 14:
- return "/images/layouts/studio_left.png";
- case 15:
- return "/images/layouts/1br_c_left.png";
- case 16:
- return "/images/layouts/1br_c_left.png";
- }
- }
-
- console.log(side, floor, unitNumber);
-
- return "";
- }
-
- function addOrRemoveFromFavorites(unit: IUnit) {
- if (!favoriteUnits.some((favoriteUnit) => favoriteUnit.id === unit.id)) {
- setFavoriteUnits([...favoriteUnits, unit]);
- } else {
- setFavoriteUnits(
- favoriteUnits.filter((favoriteUnit) => favoriteUnit.id !== unit.id)
- );
- }
- }
-
- return (
-
-
-
-
- Favorites {" "}
- {favoriteUnits.length}
-
- {/*
setIsSortPriceAsc((prev) => !prev)}
- >
- Sort by ascending price
-
- */}
-
-
- {favoriteUnits.map((unit) => (
-
-
-
-
{unit.projectName}
-
-
- {unit.unitNo[0] === "E" ? "East" : "West"} Wing
-
-
-
{unit.floor}
-
-
{unit.unitNo}
-
-
-
addOrRemoveFromFavorites(unit)}
- >
- {favoriteUnits.some(
- (favoriteUnit) => favoriteUnit.id === unit.id
- ) ? (
-
- ) : (
-
- )}
-
-
-
- setModal(
-
- unitType.type === getTypeByUnitNo(unit.unitNo)
- )?.type || ""
- }
- />
- )
- }
- >
-
-
-
- setModal(
-
- unitType.type === getTypeByUnitNo(unit.unitNo)
- )?.type || ""
- }
- />
- )
- }
- >
-
- {unit.unitType}, {unit.totalArea} Sqft
-
-
- {(unit.unitPrice &&
- `AED ${unit.unitPrice.toLocaleString()}`) ||
- "Unavailable"}
-
-
-
- }
- text="Send Enquiry"
- className="justify-center text-sm disabled:hover:bg-[#ECEDEE] w-full"
- disabled
- />
-
-
- ))}
-
-
-
- );
-}
-
-export default FavoritesPage2;
diff --git a/client/src/pages/SearchPage.tsx b/client/src/pages/SearchPage.tsx
index b4735e8..645caaa 100644
--- a/client/src/pages/SearchPage.tsx
+++ b/client/src/pages/SearchPage.tsx
@@ -1,17 +1,896 @@
-import Footer from "../components/Footer";
-import LayoutOptions from "../components/searchPage/LayoutOptions";
-import SidebarFilters from "../components/searchPage/SidebarFilters";
+/* eslint-disable react-hooks/exhaustive-deps */
+import { useEffect, useState } from "react";
+import RestartIcon from "../components/icons/RestartIcon";
+import api from "../utils/api";
+import IUnit from "../types/IUnit";
+import Checkbox2 from "../components/Checkbox2";
+import HeartIcon from "../components/icons/HeartIcon";
+import RangeSlider from "react-range-slider-input";
+import Input from "../components/Input";
+import ChevronDownIcon from "../components/icons/ChevronDownIcon";
+import useModal from "../store/useModal";
+import unitTypes from "../data/unitTypes.json";
+import UnitModalForSearchPage from "../components/modals/UnitModalForSearchPage";
+import useFavoritesStore from "../store/useFavoritesStore";
+import HeartFilledIcon from "../components/icons/HeartFilledIcon";
+import { useSearchParams } from "react-router-dom";
+
+function SearchPage() {
+ const [units, setUnits] = useState
([]);
+ const [filteredUnits, setFilteredUnits] = useState([]);
+ const [unitTypeFilters, setUnitTypeFilters] = useState([]);
+ const [unitViewFilters, setUnitViewFilters] = useState([]);
+ const [minCost, setMinCost] = useState(0);
+ const [maxCost, setMaxCost] = useState(1000000);
+ const [cost, setCost] = useState([minCost, maxCost]);
+ const [minTotalArea] = useState(341);
+ const [maxTotalArea] = useState(1058);
+ const [totalArea, setTotalArea] = useState([
+ minTotalArea,
+ maxTotalArea,
+ ]);
+ const [minFloor] = useState(5);
+ const [maxFloor] = useState(31);
+ const [floor, setFloor] = useState([minFloor, maxFloor]);
+ const [isSortPriceAsc, setIsSortPriceAsc] = useState();
+ const { setModal } = useModal();
+ const { favoriteUnits, setFavoriteUnits } = useFavoritesStore();
+ const [searchParams, setSearchParams] = useSearchParams();
+
+ async function getUnits() {
+ try {
+ const result: IUnit[] = await api.get("units").json();
+
+ setUnits(result);
+ } catch (error) {
+ //
+ }
+ }
+
+ function getImageSrc(unitNo: string): string {
+ const side = unitNo[0];
+ const floor = Number(unitNo.split("-")[1].slice(0, -2));
+ const unitNumber = Number(unitNo.split("-")[1].slice(-2));
+
+ if (side === "W") {
+ // Side "W"
+ if (floor < 24) {
+ switch (unitNumber) {
+ case 1:
+ return "/images/layouts/2br_a_left.png";
+ case 2:
+ return "/images/layouts/studio_left.png";
+ case 3:
+ return "/images/layouts/1br_d_left.png";
+ case 4:
+ return "/images/layouts/studio_left.png";
+ case 5:
+ return "/images/layouts/studio_left.png";
+ case 6:
+ return "/images/layouts/1br_d_left.png";
+ case 7:
+ return "/images/layouts/1br_a_left.png";
+ case 8:
+ return "/images/layouts/1br_a_left.png";
+ case 9:
+ return "/images/layouts/studio_flex_left.png";
+ case 10:
+ return "/images/layouts/studio_flex_left.png";
+ case 11:
+ return "/images/layouts/studio_flex_left.png";
+ case 12:
+ return "/images/layouts/studio_flex_left.png";
+ case 13:
+ return "/images/layouts/studio_flex_left.png";
+ case 14:
+ return "/images/layouts/studio_flex_left.png";
+ case 15:
+ return "/images/layouts/1br_c_left.png";
+ case 16:
+ return "/images/layouts/1br_c_left.png";
+ case 17:
+ return "/images/layouts/2br_b_left.png";
+ }
+ } else {
+ switch (unitNumber) {
+ case 1:
+ return "/images/layouts/2br_a_left.png";
+ case 2:
+ return "/images/layouts/studio_left.png";
+ case 3:
+ return "/images/layouts/1br_d_left.png";
+ case 4:
+ return "/images/layouts/studio_left.png";
+ case 5:
+ return "/images/layouts/studio_left.png";
+ case 6:
+ return "/images/layouts/1br_d_left.png";
+ case 7:
+ return "/images/layouts/1br_a_left.png";
+ case 8:
+ return "/images/layouts/1br_a_left.png";
+ case 9:
+ return "/images/layouts/1br_d_left.png";
+ case 10:
+ return "/images/layouts/studio_left.png";
+ case 11:
+ return "/images/layouts/studio_left.png";
+ case 12:
+ return "/images/layouts/1br_d_left.png";
+ case 13:
+ return "/images/layouts/1br_c_left.png";
+ case 14:
+ return "/images/layouts/1br_c_left.png";
+ case 15:
+ return "/images/layouts/2br_b_left.png";
+ }
+ }
+ } else {
+ // Side "E"
+ switch (unitNumber) {
+ case 1:
+ return "/images/layouts/2br_a_left.png";
+ case 2:
+ return "/images/layouts/studio_left.png";
+ case 3:
+ return "/images/layouts/1br_d_left.png";
+ case 4:
+ return "/images/layouts/studio_left.png";
+ case 5:
+ return "/images/layouts/studio_left.png";
+ case 6:
+ return "/images/layouts/1br_c_left.png";
+ case 7:
+ return "/images/layouts/1br_c_left.png";
+ case 8:
+ return "/images/layouts/1br_b_left.png";
+ case 9:
+ return "/images/layouts/1br_b_left.png";
+ case 10:
+ return "/images/layouts/1br_c_left.png";
+ case 11:
+ return "/images/layouts/studio_left.png";
+ case 12:
+ return "/images/layouts/studio_left.png";
+ case 13:
+ return "/images/layouts/studio_left.png";
+ case 14:
+ return "/images/layouts/studio_left.png";
+ case 15:
+ return "/images/layouts/1br_c_left.png";
+ case 16:
+ return "/images/layouts/1br_c_left.png";
+ }
+ }
+
+ console.log(side, floor, unitNumber);
+
+ return "";
+ }
+
+ function refreshFilters() {
+ console.log("call func refreshFilters");
+ setUnitTypeFilters([]);
+ setUnitViewFilters([]);
+ setCost([minCost, maxCost]);
+ setTotalArea([minTotalArea, maxTotalArea]);
+ setFloor([minFloor, maxFloor]);
+ }
+
+ function getTypeByUnitNo(unitNo: string) {
+ const side = unitNo[0] === "E" ? "East" : "West";
+ const floor = Number(unitNo.split("-")[1].slice(0, -2));
+ const number = Number(unitNo.split("-")[1].slice(-2));
+
+ console.log(side, floor, number);
+
+ if (side === "East") {
+ if ([1].includes(number)) {
+ return "2br-type-a";
+ } else if ([2, 4, 5, 11, 12, 13, 14].includes(number)) {
+ return "studio-2";
+ } else if ([3].includes(number)) {
+ return "1br-type-d";
+ } else if ([6, 7, 10, 15, 16].includes(number)) {
+ return "1br-type-c";
+ } else if ([8, 9].includes(number)) {
+ return "1br-type-b";
+ }
+ } else if (side === "West") {
+ if (floor <= 21) {
+ // Floors 5-21
+ if ([1].includes(number)) {
+ return "2br-type-a";
+ } else if ([2, 4, 5].includes(number)) {
+ return "studio-2";
+ } else if ([3, 6].includes(number)) {
+ return "1br-type-d";
+ } else if ([7, 8].includes(number)) {
+ return "1br-type-a";
+ } else if ([9, 10, 11, 12, 13, 14].includes(number)) {
+ return "studio-flex";
+ } else if ([15, 16].includes(number)) {
+ return "1br-type-c";
+ } else if ([17].includes(number)) {
+ return "2br-type-b";
+ }
+ } else {
+ // Floors 24-31
+ if ([1].includes(number)) {
+ return "2br-type-a";
+ } else if ([2, 4, 5, 10, 11].includes(number)) {
+ return "studio-2";
+ } else if ([3, 6, 9, 12].includes(number)) {
+ return "1br-type-d";
+ } else if ([7, 8].includes(number)) {
+ return "1br-type-a";
+ } else if ([13, 14].includes(number)) {
+ return "1br-type-c";
+ } else if ([15].includes(number)) {
+ return "2br-type-b";
+ }
+ }
+ }
+
+ // TODO Connect to DB
+
+ return "";
+ }
+
+ function addOrRemoveFromFavorites(unit: IUnit) {
+ if (!favoriteUnits.some((favoriteUnit) => favoriteUnit.id === unit.id)) {
+ setFavoriteUnits([...favoriteUnits, unit]);
+ } else {
+ setFavoriteUnits(
+ favoriteUnits.filter((favoriteUnit) => favoriteUnit.id !== unit.id)
+ );
+ }
+ }
+
+ function handleClickCard(unit: IUnit) {
+ setModal(
+ unitType.type === getTypeByUnitNo(unit.unitNo)
+ )?.type || ""
+ }
+ />
+ );
+
+ searchParams.set("unitNo", unit.unitNo);
+ setSearchParams(searchParams);
+ }
+
+ useEffect(() => {
+ let newFilteredUnits = units
+ .filter((unit) =>
+ unitTypeFilters.length ? unitTypeFilters.includes(unit.unitType) : unit
+ )
+ .filter((unit) =>
+ unitViewFilters.length
+ ? unitViewFilters.some((unitViewFilter) =>
+ unit.unitView.includes(unitViewFilter)
+ )
+ : unit
+ )
+ .filter(
+ (unit) =>
+ unit.totalArea >= totalArea[0] && unit.totalArea <= totalArea[1]
+ )
+ .filter((unit) => unit.floor >= floor[0] && unit.floor <= floor[1]);
+
+ console.log("isSortPriceAsc", isSortPriceAsc);
+
+ if (isSortPriceAsc !== undefined) {
+ if (isSortPriceAsc) {
+ newFilteredUnits = newFilteredUnits.sort(
+ (a, b) => (b.unitPrice || 0) - (a.unitPrice || 0)
+ );
+ } else {
+ newFilteredUnits = newFilteredUnits.sort(
+ (a, b) => (a.unitPrice || 0) - (b.unitPrice || 0)
+ );
+ }
+ }
+
+ setFilteredUnits(newFilteredUnits);
+
+ setMinCost(
+ Math.min(
+ ...newFilteredUnits.map((unit) => unit.unitPrice!).filter(Boolean)
+ )
+ );
+ setMaxCost(
+ Math.max(
+ ...newFilteredUnits.map((unit) => unit.unitPrice!).filter(Boolean)
+ )
+ );
+ setCost([
+ Math.min(
+ ...newFilteredUnits.map((unit) => unit.unitPrice!).filter(Boolean)
+ ),
+ Math.max(
+ ...newFilteredUnits.map((unit) => unit.unitPrice!).filter(Boolean)
+ ),
+ ]);
+
+ // setMinTotalArea(
+ // Math.round(
+ // Math.min(
+ // ...newFilteredUnits.map((unit) => unit.totalArea).filter(Boolean)
+ // )
+ // )
+ // );
+ // setMaxTotalArea(
+ // Math.round(
+ // Math.max(
+ // ...newFilteredUnits.map((unit) => unit.totalArea).filter(Boolean)
+ // )
+ // )
+ // );
+ // setTotalArea([
+ // Math.round(
+ // Math.min(
+ // ...newFilteredUnits.map((unit) => unit.totalArea).filter(Boolean)
+ // )
+ // ),
+ // Math.round(
+ // Math.max(
+ // ...newFilteredUnits.map((unit) => unit.totalArea).filter(Boolean)
+ // )
+ // ),
+ // ]);
+
+ // setMinFloor(
+ // Math.min(...newFilteredUnits.map((unit) => unit.floor).filter(Boolean))
+ // );
+ // setMaxFloor(
+ // Math.max(...newFilteredUnits.map((unit) => unit.floor).filter(Boolean))
+ // );
+ // setFloor([
+ // Math.min(...newFilteredUnits.map((unit) => unit.floor).filter(Boolean)),
+ // Math.max(...newFilteredUnits.map((unit) => unit.floor).filter(Boolean)),
+ // ]);
+ }, [
+ units,
+ unitTypeFilters,
+ unitViewFilters,
+ totalArea,
+ floor,
+ isSortPriceAsc,
+ ]);
+
+ // useEffect(() => {
+ // if (!units.length) return;
+
+ // setMinCost(
+ // Math.min(...units.map((unit) => unit.unitPrice!).filter(Boolean))
+ // );
+ // setMaxCost(
+ // Math.max(...units.map((unit) => unit.unitPrice!).filter(Boolean))
+ // );
+ // setCost([
+ // Math.min(...units.map((unit) => unit.unitPrice!).filter(Boolean)),
+ // Math.max(...units.map((unit) => unit.unitPrice!).filter(Boolean)),
+ // ]);
+ // }, [units]);
+
+ useEffect(() => {
+ getUnits();
+ }, []);
+
+ useEffect(() => {
+ if (searchParams.has("unitNo")) {
+ const unitNo = searchParams.get("unitNo");
+
+ if (!unitNo) return;
+
+ const type = getTypeByUnitNo(unitNo);
+ const unit = units.find((unit) => unit.unitNo === unitNo);
+
+ if (!unit) return;
+
+ setModal( );
+ }
+ }, [units]);
-const SearchPage = () => {
return (
-
-
-
-
+
+
+
+
+
Apartment type
+
+
+
+
unitTypeFilter === "Studio Flex"
+ )}
+ onChange={(isChecked, filterName) => {
+ if (isChecked) {
+ setUnitTypeFilters((prev) => [...prev, filterName]);
+ } else {
+ setUnitTypeFilters(
+ unitTypeFilters.filter(
+ (unitTypeFilter) => unitTypeFilter !== filterName
+ )
+ );
+ }
+ }}
+ />
+ Studio Flex
+
+
+
+ {
+ units.filter((unit) => unit.unitType === "Studio Flex")
+ .length
+ }
+
+
+
+
+
+
unitTypeFilter === "Studio Squared"
+ )}
+ onChange={(isChecked, filterName) => {
+ if (isChecked) {
+ setUnitTypeFilters((prev) => [...prev, filterName]);
+ } else {
+ setUnitTypeFilters(
+ unitTypeFilters.filter(
+ (unitTypeFilter) => unitTypeFilter !== filterName
+ )
+ );
+ }
+ }}
+ />
+ Studio²
+
+
+
+ {
+ units.filter((unit) => unit.unitType === "Studio Squared")
+ .length
+ }
+
+
+
+
+
+
unitTypeFilter === "1 BR Squared"
+ )}
+ onChange={(isChecked, filterName) => {
+ if (isChecked) {
+ setUnitTypeFilters((prev) => [...prev, filterName]);
+ } else {
+ setUnitTypeFilters(
+ unitTypeFilters.filter(
+ (unitTypeFilter) => unitTypeFilter !== filterName
+ )
+ );
+ }
+ }}
+ />
+ 1 Bedroom²
+
+
+
+ {
+ units.filter((unit) => unit.unitType === "1 BR Squared")
+ .length
+ }
+
+
+
+
+
+
unitTypeFilter === "2 BR Squared"
+ )}
+ onChange={(isChecked, filterName) => {
+ if (isChecked) {
+ setUnitTypeFilters((prev) => [...prev, filterName]);
+ } else {
+ setUnitTypeFilters(
+ unitTypeFilters.filter(
+ (unitTypeFilter) => unitTypeFilter !== filterName
+ )
+ );
+ }
+ }}
+ />
+ 2 Bedroom²
+
+
+
+ {
+ units.filter((unit) => unit.unitType === "2 BR Squared")
+ .length
+ }
+
+
+
+
+
+
+
+
+
+
View
+
+
+
+
unitViewFilter === "BK/DT"
+ )}
+ onChange={(isChecked, filterName) => {
+ if (isChecked) {
+ setUnitViewFilters((prev) => [...prev, filterName]);
+ } else {
+ setUnitViewFilters(
+ unitViewFilters.filter(
+ (unitViewFilter) => unitViewFilter !== filterName
+ )
+ );
+ }
+ }}
+ />
+ Burj Khalifa / Downtown
+
+
+
+ {
+ units.filter((unit) => unit.unitView.includes("BK/DT"))
+ .length
+ }
+
+
+
+
+
+
unitViewFilter === "Business Bay"
+ )}
+ onChange={(isChecked, filterName) => {
+ if (isChecked) {
+ setUnitViewFilters((prev) => [...prev, filterName]);
+ } else {
+ setUnitViewFilters(
+ unitViewFilters.filter(
+ (unitViewFilter) => unitViewFilter !== filterName
+ )
+ );
+ }
+ }}
+ />
+ Business Bay
+
+
+
+ {
+ units.filter((unit) => unit.unitView === "Business Bay")
+ .length
+ }
+
+
+
+
+
+
unitViewFilter === "Amenities"
+ )}
+ onChange={(isChecked, filterName) => {
+ if (isChecked) {
+ setUnitViewFilters((prev) => [...prev, filterName]);
+ } else {
+ setUnitViewFilters(
+ unitViewFilters.filter(
+ (unitViewFilter) => unitViewFilter !== filterName
+ )
+ );
+ }
+ }}
+ />
+ Amenities
+
+
+
+ {
+ units.filter((unit) => unit.unitView.includes("Amenities"))
+ .length
+ }
+
+
+
+
+
+
unitViewFilter === "Canal"
+ )}
+ onChange={(isChecked, filterName) => {
+ if (isChecked) {
+ setUnitViewFilters((prev) => [...prev, filterName]);
+ } else {
+ setUnitViewFilters(
+ unitViewFilters.filter(
+ (unitViewFilter) => unitViewFilter !== filterName
+ )
+ );
+ }
+ }}
+ />
+ Canal
+
+
+
+ {
+ units.filter((unit) => unit.unitView.includes("Canal"))
+ .length
+ }
+
+
+
+
+
+
unitViewFilter === "Park"
+ )}
+ onChange={(isChecked, filterName) => {
+ if (isChecked) {
+ setUnitViewFilters((prev) => [...prev, filterName]);
+ } else {
+ setUnitViewFilters(
+ unitViewFilters.filter(
+ (unitViewFilter) => unitViewFilter !== filterName
+ )
+ );
+ }
+ }}
+ />
+ Park
+
+
+
+ {
+ units.filter((unit) => unit.unitView.includes("Park"))
+ .length
+ }
+
+
+
+
+
+
+
+
+
+
+ Units {" "}
+ {filteredUnits.length}
+
+
setIsSortPriceAsc((prev) => !prev)}
+ >
+ Sort by ascending price
+ {/* descending */}
+
+
+
+
+ {filteredUnits.map((unit) => (
+
+
+
+
{unit.projectName}
+
+
+ {unit.unitNo[0] === "E" ? "East" : "West"} Wing
+
+
+
{unit.floor}
+
+
{unit.unitNo}
+
+
+
addOrRemoveFromFavorites(unit)}
+ >
+ {favoriteUnits.some(
+ (favoriteUnit) => favoriteUnit.id === unit.id
+ ) ? (
+
+ ) : (
+
+ )}
+
+
+
handleClickCard(unit)}
+ >
+
+
+
handleClickCard(unit)}
+ >
+
+ {unit.unitName}, {unit.totalArea} Sqft
+
+
+ {(unit.unitPrice &&
+ `AED ${unit.unitPrice.toLocaleString()}`) ||
+ "Unavailable"}
+
+
+
+ ))}
+
+
-
);
-};
+}
export default SearchPage;
diff --git a/client/src/pages/SearchPage2.tsx b/client/src/pages/SearchPage2.tsx
deleted file mode 100644
index 73f6aa6..0000000
--- a/client/src/pages/SearchPage2.tsx
+++ /dev/null
@@ -1,896 +0,0 @@
-/* eslint-disable react-hooks/exhaustive-deps */
-import { useEffect, useState } from "react";
-import RestartIcon from "../components/icons/RestartIcon";
-import api from "../utils/api";
-import IUnit from "../types/IUnit";
-import Checkbox2 from "../components/Checkbox2";
-import HeartIcon from "../components/icons/HeartIcon";
-import RangeSlider from "react-range-slider-input";
-import Input from "../components/Input";
-import ChevronDownIcon from "../components/icons/ChevronDownIcon";
-import useModal from "../store/useModal";
-import unitTypes from "../data/unitTypes.json";
-import UnitModalForSearchPage from "../components/modals/UnitModalForSearchPage";
-import useFavoritesStore from "../store/useFavoritesStore";
-import HeartFilledIcon from "../components/icons/HeartFilledIcon";
-import { useSearchParams } from "react-router-dom";
-
-function SearchPage2() {
- const [units, setUnits] = useState
([]);
- const [filteredUnits, setFilteredUnits] = useState([]);
- const [unitTypeFilters, setUnitTypeFilters] = useState([]);
- const [unitViewFilters, setUnitViewFilters] = useState([]);
- const [minCost, setMinCost] = useState(0);
- const [maxCost, setMaxCost] = useState(1000000);
- const [cost, setCost] = useState([minCost, maxCost]);
- const [minTotalArea] = useState(341);
- const [maxTotalArea] = useState(1058);
- const [totalArea, setTotalArea] = useState([
- minTotalArea,
- maxTotalArea,
- ]);
- const [minFloor] = useState(5);
- const [maxFloor] = useState(31);
- const [floor, setFloor] = useState([minFloor, maxFloor]);
- const [isSortPriceAsc, setIsSortPriceAsc] = useState();
- const { setModal } = useModal();
- const { favoriteUnits, setFavoriteUnits } = useFavoritesStore();
- const [searchParams, setSearchParams] = useSearchParams();
-
- async function getUnits() {
- try {
- const result: IUnit[] = await api.get("units").json();
-
- setUnits(result);
- } catch (error) {
- //
- }
- }
-
- function getImageSrc(unitNo: string): string {
- const side = unitNo[0];
- const floor = Number(unitNo.split("-")[1].slice(0, -2));
- const unitNumber = Number(unitNo.split("-")[1].slice(-2));
-
- if (side === "W") {
- // Side "W"
- if (floor < 24) {
- switch (unitNumber) {
- case 1:
- return "/images/layouts/2br_a_left.png";
- case 2:
- return "/images/layouts/studio_left.png";
- case 3:
- return "/images/layouts/1br_d_left.png";
- case 4:
- return "/images/layouts/studio_left.png";
- case 5:
- return "/images/layouts/studio_left.png";
- case 6:
- return "/images/layouts/1br_d_left.png";
- case 7:
- return "/images/layouts/1br_a_left.png";
- case 8:
- return "/images/layouts/1br_a_left.png";
- case 9:
- return "/images/layouts/studio_flex_left.png";
- case 10:
- return "/images/layouts/studio_flex_left.png";
- case 11:
- return "/images/layouts/studio_flex_left.png";
- case 12:
- return "/images/layouts/studio_flex_left.png";
- case 13:
- return "/images/layouts/studio_flex_left.png";
- case 14:
- return "/images/layouts/studio_flex_left.png";
- case 15:
- return "/images/layouts/1br_c_left.png";
- case 16:
- return "/images/layouts/1br_c_left.png";
- case 17:
- return "/images/layouts/2br_b_left.png";
- }
- } else {
- switch (unitNumber) {
- case 1:
- return "/images/layouts/2br_a_left.png";
- case 2:
- return "/images/layouts/studio_left.png";
- case 3:
- return "/images/layouts/1br_d_left.png";
- case 4:
- return "/images/layouts/studio_left.png";
- case 5:
- return "/images/layouts/studio_left.png";
- case 6:
- return "/images/layouts/1br_d_left.png";
- case 7:
- return "/images/layouts/1br_a_left.png";
- case 8:
- return "/images/layouts/1br_a_left.png";
- case 9:
- return "/images/layouts/1br_d_left.png";
- case 10:
- return "/images/layouts/studio_left.png";
- case 11:
- return "/images/layouts/studio_left.png";
- case 12:
- return "/images/layouts/1br_d_left.png";
- case 13:
- return "/images/layouts/1br_c_left.png";
- case 14:
- return "/images/layouts/1br_c_left.png";
- case 15:
- return "/images/layouts/2br_b_left.png";
- }
- }
- } else {
- // Side "E"
- switch (unitNumber) {
- case 1:
- return "/images/layouts/2br_a_left.png";
- case 2:
- return "/images/layouts/studio_left.png";
- case 3:
- return "/images/layouts/1br_d_left.png";
- case 4:
- return "/images/layouts/studio_left.png";
- case 5:
- return "/images/layouts/studio_left.png";
- case 6:
- return "/images/layouts/1br_c_left.png";
- case 7:
- return "/images/layouts/1br_c_left.png";
- case 8:
- return "/images/layouts/1br_b_left.png";
- case 9:
- return "/images/layouts/1br_b_left.png";
- case 10:
- return "/images/layouts/1br_c_left.png";
- case 11:
- return "/images/layouts/studio_left.png";
- case 12:
- return "/images/layouts/studio_left.png";
- case 13:
- return "/images/layouts/studio_left.png";
- case 14:
- return "/images/layouts/studio_left.png";
- case 15:
- return "/images/layouts/1br_c_left.png";
- case 16:
- return "/images/layouts/1br_c_left.png";
- }
- }
-
- console.log(side, floor, unitNumber);
-
- return "";
- }
-
- function refreshFilters() {
- console.log("call func refreshFilters");
- setUnitTypeFilters([]);
- setUnitViewFilters([]);
- setCost([minCost, maxCost]);
- setTotalArea([minTotalArea, maxTotalArea]);
- setFloor([minFloor, maxFloor]);
- }
-
- function getTypeByUnitNo(unitNo: string) {
- const side = unitNo[0] === "E" ? "East" : "West";
- const floor = Number(unitNo.split("-")[1].slice(0, -2));
- const number = Number(unitNo.split("-")[1].slice(-2));
-
- console.log(side, floor, number);
-
- if (side === "East") {
- if ([1].includes(number)) {
- return "2br-type-a";
- } else if ([2, 4, 5, 11, 12, 13, 14].includes(number)) {
- return "studio-2";
- } else if ([3].includes(number)) {
- return "1br-type-d";
- } else if ([6, 7, 10, 15, 16].includes(number)) {
- return "1br-type-c";
- } else if ([8, 9].includes(number)) {
- return "1br-type-b";
- }
- } else if (side === "West") {
- if (floor <= 21) {
- // Floors 5-21
- if ([1].includes(number)) {
- return "2br-type-a";
- } else if ([2, 4, 5].includes(number)) {
- return "studio-2";
- } else if ([3, 6].includes(number)) {
- return "1br-type-d";
- } else if ([7, 8].includes(number)) {
- return "1br-type-a";
- } else if ([9, 10, 11, 12, 13, 14].includes(number)) {
- return "studio-flex";
- } else if ([15, 16].includes(number)) {
- return "1br-type-c";
- } else if ([17].includes(number)) {
- return "2br-type-b";
- }
- } else {
- // Floors 24-31
- if ([1].includes(number)) {
- return "2br-type-a";
- } else if ([2, 4, 5, 10, 11].includes(number)) {
- return "studio-2";
- } else if ([3, 6, 9, 12].includes(number)) {
- return "1br-type-d";
- } else if ([7, 8].includes(number)) {
- return "1br-type-a";
- } else if ([13, 14].includes(number)) {
- return "1br-type-c";
- } else if ([15].includes(number)) {
- return "2br-type-b";
- }
- }
- }
-
- // TODO Connect to DB
-
- return "";
- }
-
- function addOrRemoveFromFavorites(unit: IUnit) {
- if (!favoriteUnits.some((favoriteUnit) => favoriteUnit.id === unit.id)) {
- setFavoriteUnits([...favoriteUnits, unit]);
- } else {
- setFavoriteUnits(
- favoriteUnits.filter((favoriteUnit) => favoriteUnit.id !== unit.id)
- );
- }
- }
-
- function handleClickCard(unit: IUnit) {
- setModal(
- unitType.type === getTypeByUnitNo(unit.unitNo)
- )?.type || ""
- }
- />
- );
-
- searchParams.set("unitNo", unit.unitNo);
- setSearchParams(searchParams);
- }
-
- useEffect(() => {
- let newFilteredUnits = units
- .filter((unit) =>
- unitTypeFilters.length ? unitTypeFilters.includes(unit.unitType) : unit
- )
- .filter((unit) =>
- unitViewFilters.length
- ? unitViewFilters.some((unitViewFilter) =>
- unit.unitView.includes(unitViewFilter)
- )
- : unit
- )
- .filter(
- (unit) =>
- unit.totalArea >= totalArea[0] && unit.totalArea <= totalArea[1]
- )
- .filter((unit) => unit.floor >= floor[0] && unit.floor <= floor[1]);
-
- console.log("isSortPriceAsc", isSortPriceAsc);
-
- if (isSortPriceAsc !== undefined) {
- if (isSortPriceAsc) {
- newFilteredUnits = newFilteredUnits.sort(
- (a, b) => (b.unitPrice || 0) - (a.unitPrice || 0)
- );
- } else {
- newFilteredUnits = newFilteredUnits.sort(
- (a, b) => (a.unitPrice || 0) - (b.unitPrice || 0)
- );
- }
- }
-
- setFilteredUnits(newFilteredUnits);
-
- setMinCost(
- Math.min(
- ...newFilteredUnits.map((unit) => unit.unitPrice!).filter(Boolean)
- )
- );
- setMaxCost(
- Math.max(
- ...newFilteredUnits.map((unit) => unit.unitPrice!).filter(Boolean)
- )
- );
- setCost([
- Math.min(
- ...newFilteredUnits.map((unit) => unit.unitPrice!).filter(Boolean)
- ),
- Math.max(
- ...newFilteredUnits.map((unit) => unit.unitPrice!).filter(Boolean)
- ),
- ]);
-
- // setMinTotalArea(
- // Math.round(
- // Math.min(
- // ...newFilteredUnits.map((unit) => unit.totalArea).filter(Boolean)
- // )
- // )
- // );
- // setMaxTotalArea(
- // Math.round(
- // Math.max(
- // ...newFilteredUnits.map((unit) => unit.totalArea).filter(Boolean)
- // )
- // )
- // );
- // setTotalArea([
- // Math.round(
- // Math.min(
- // ...newFilteredUnits.map((unit) => unit.totalArea).filter(Boolean)
- // )
- // ),
- // Math.round(
- // Math.max(
- // ...newFilteredUnits.map((unit) => unit.totalArea).filter(Boolean)
- // )
- // ),
- // ]);
-
- // setMinFloor(
- // Math.min(...newFilteredUnits.map((unit) => unit.floor).filter(Boolean))
- // );
- // setMaxFloor(
- // Math.max(...newFilteredUnits.map((unit) => unit.floor).filter(Boolean))
- // );
- // setFloor([
- // Math.min(...newFilteredUnits.map((unit) => unit.floor).filter(Boolean)),
- // Math.max(...newFilteredUnits.map((unit) => unit.floor).filter(Boolean)),
- // ]);
- }, [
- units,
- unitTypeFilters,
- unitViewFilters,
- totalArea,
- floor,
- isSortPriceAsc,
- ]);
-
- // useEffect(() => {
- // if (!units.length) return;
-
- // setMinCost(
- // Math.min(...units.map((unit) => unit.unitPrice!).filter(Boolean))
- // );
- // setMaxCost(
- // Math.max(...units.map((unit) => unit.unitPrice!).filter(Boolean))
- // );
- // setCost([
- // Math.min(...units.map((unit) => unit.unitPrice!).filter(Boolean)),
- // Math.max(...units.map((unit) => unit.unitPrice!).filter(Boolean)),
- // ]);
- // }, [units]);
-
- useEffect(() => {
- getUnits();
- }, []);
-
- useEffect(() => {
- if (searchParams.has("unitNo")) {
- const unitNo = searchParams.get("unitNo");
-
- if (!unitNo) return;
-
- const type = getTypeByUnitNo(unitNo);
- const unit = units.find((unit) => unit.unitNo === unitNo);
-
- if (!unit) return;
-
- setModal( );
- }
- }, [units]);
-
- return (
-
-
-
-
-
Apartment type
-
-
-
-
unitTypeFilter === "Studio Flex"
- )}
- onChange={(isChecked, filterName) => {
- if (isChecked) {
- setUnitTypeFilters((prev) => [...prev, filterName]);
- } else {
- setUnitTypeFilters(
- unitTypeFilters.filter(
- (unitTypeFilter) => unitTypeFilter !== filterName
- )
- );
- }
- }}
- />
- Studio Flex
-
-
-
- {
- units.filter((unit) => unit.unitType === "Studio Flex")
- .length
- }
-
-
-
-
-
-
unitTypeFilter === "Studio Squared"
- )}
- onChange={(isChecked, filterName) => {
- if (isChecked) {
- setUnitTypeFilters((prev) => [...prev, filterName]);
- } else {
- setUnitTypeFilters(
- unitTypeFilters.filter(
- (unitTypeFilter) => unitTypeFilter !== filterName
- )
- );
- }
- }}
- />
- Studio²
-
-
-
- {
- units.filter((unit) => unit.unitType === "Studio Squared")
- .length
- }
-
-
-
-
-
-
unitTypeFilter === "1 BR Squared"
- )}
- onChange={(isChecked, filterName) => {
- if (isChecked) {
- setUnitTypeFilters((prev) => [...prev, filterName]);
- } else {
- setUnitTypeFilters(
- unitTypeFilters.filter(
- (unitTypeFilter) => unitTypeFilter !== filterName
- )
- );
- }
- }}
- />
- 1 Bedroom²
-
-
-
- {
- units.filter((unit) => unit.unitType === "1 BR Squared")
- .length
- }
-
-
-
-
-
-
unitTypeFilter === "2 BR Squared"
- )}
- onChange={(isChecked, filterName) => {
- if (isChecked) {
- setUnitTypeFilters((prev) => [...prev, filterName]);
- } else {
- setUnitTypeFilters(
- unitTypeFilters.filter(
- (unitTypeFilter) => unitTypeFilter !== filterName
- )
- );
- }
- }}
- />
- 2 Bedroom²
-
-
-
- {
- units.filter((unit) => unit.unitType === "2 BR Squared")
- .length
- }
-
-
-
-
-
-
-
-
-
-
View
-
-
-
-
unitViewFilter === "BK/DT"
- )}
- onChange={(isChecked, filterName) => {
- if (isChecked) {
- setUnitViewFilters((prev) => [...prev, filterName]);
- } else {
- setUnitViewFilters(
- unitViewFilters.filter(
- (unitViewFilter) => unitViewFilter !== filterName
- )
- );
- }
- }}
- />
- Burj Khalifa / Downtown
-
-
-
- {
- units.filter((unit) => unit.unitView.includes("BK/DT"))
- .length
- }
-
-
-
-
-
-
unitViewFilter === "Business Bay"
- )}
- onChange={(isChecked, filterName) => {
- if (isChecked) {
- setUnitViewFilters((prev) => [...prev, filterName]);
- } else {
- setUnitViewFilters(
- unitViewFilters.filter(
- (unitViewFilter) => unitViewFilter !== filterName
- )
- );
- }
- }}
- />
- Business Bay
-
-
-
- {
- units.filter((unit) => unit.unitView === "Business Bay")
- .length
- }
-
-
-
-
-
-
unitViewFilter === "Amenities"
- )}
- onChange={(isChecked, filterName) => {
- if (isChecked) {
- setUnitViewFilters((prev) => [...prev, filterName]);
- } else {
- setUnitViewFilters(
- unitViewFilters.filter(
- (unitViewFilter) => unitViewFilter !== filterName
- )
- );
- }
- }}
- />
- Amenities
-
-
-
- {
- units.filter((unit) => unit.unitView.includes("Amenities"))
- .length
- }
-
-
-
-
-
-
unitViewFilter === "Canal"
- )}
- onChange={(isChecked, filterName) => {
- if (isChecked) {
- setUnitViewFilters((prev) => [...prev, filterName]);
- } else {
- setUnitViewFilters(
- unitViewFilters.filter(
- (unitViewFilter) => unitViewFilter !== filterName
- )
- );
- }
- }}
- />
- Canal
-
-
-
- {
- units.filter((unit) => unit.unitView.includes("Canal"))
- .length
- }
-
-
-
-
-
-
unitViewFilter === "Park"
- )}
- onChange={(isChecked, filterName) => {
- if (isChecked) {
- setUnitViewFilters((prev) => [...prev, filterName]);
- } else {
- setUnitViewFilters(
- unitViewFilters.filter(
- (unitViewFilter) => unitViewFilter !== filterName
- )
- );
- }
- }}
- />
- Park
-
-
-
- {
- units.filter((unit) => unit.unitView.includes("Park"))
- .length
- }
-
-
-
-
-
-
-
-
-
-
- Units {" "}
- {filteredUnits.length}
-
-
setIsSortPriceAsc((prev) => !prev)}
- >
- Sort by ascending price
- {/* descending */}
-
-
-
-
- {filteredUnits.map((unit) => (
-
-
-
-
{unit.projectName}
-
-
- {unit.unitNo[0] === "E" ? "East" : "West"} Wing
-
-
-
{unit.floor}
-
-
{unit.unitNo}
-
-
-
addOrRemoveFromFavorites(unit)}
- >
- {favoriteUnits.some(
- (favoriteUnit) => favoriteUnit.id === unit.id
- ) ? (
-
- ) : (
-
- )}
-
-
-
handleClickCard(unit)}
- >
-
-
-
handleClickCard(unit)}
- >
-
- {unit.unitName}, {unit.totalArea} Sqft
-
-
- {(unit.unitPrice &&
- `AED ${unit.unitPrice.toLocaleString()}`) ||
- "Unavailable"}
-
-
-
- ))}
-
-
-
-
- );
-}
-
-export default SearchPage2;
diff --git a/client/src/pages/TestPage.tsx b/client/src/pages/TestPage.tsx
deleted file mode 100644
index 169a56b..0000000
--- a/client/src/pages/TestPage.tsx
+++ /dev/null
@@ -1,5 +0,0 @@
-function TestPage() {
- return TestPage
;
-}
-
-export default TestPage;
diff --git a/client/src/pages/UnitTypesItemPage.tsx b/client/src/pages/UnitTypesItemPage.tsx
index 81e4f8a..84339c9 100644
--- a/client/src/pages/UnitTypesItemPage.tsx
+++ b/client/src/pages/UnitTypesItemPage.tsx
@@ -13,7 +13,7 @@ function UnitTypesItemPage() {
const [selectedUniTypePos, setSelectedUniTypePos] = useState("left");
return (
-