Amenties popup fix

This commit is contained in:
2025-07-22 11:40:56 +05:00
parent 5258107194
commit 94f77a0532
5 changed files with 58 additions and 40 deletions
+11 -17
View File
@@ -1,11 +1,11 @@
import { useEffect, useMemo, useState } from "react";
import { useMemo } from "react";
import { formattedUnitTypes } from "../data/formattedUnitTypes";
import { usePopupStore } from "../stores/usePopupStore";
import getAmentiesCount, { AmentiesCount } from "../utils/getAmentiesCount";
import { FloorsData } from "./FloorSelect";
import ArrowRightIcon from "./icons/ArrowRightIcon";
import HumanIcon from "./icons/HumanIcon";
import Button from "./ui/Button";
import { projects } from "../data/projects";
interface FloorPopupProps {
title: string;
@@ -14,28 +14,22 @@ interface FloorPopupProps {
onSelect: (floor: string) => void;
}
function getAmentiesCount(complexName: string, title: string) {
const amenties = projects.find(
(proj) => proj.slug === complexName
)?.amentiesFloors;
return amenties?.find((amenty) => amenty.title === title);
}
function FloorPopup({ title, complexName, data, onSelect }: FloorPopupProps) {
const { setPopup } = usePopupStore();
const initialState = useMemo(
const amentiesCount = useMemo(
() =>
Number.isNaN(+title.split(" ").at(-1)!)
Number.isNaN(+title.at(-1)!)
? getAmentiesCount(complexName, title)
: null,
[title, complexName]
);
const [amentiesCount, setAmentiesCount] = useState<AmentiesCount | null>(
initialState
);
useEffect(() => {
if (Number.isNaN(+title.split(" ").at(-1)!)) {
setAmentiesCount(getAmentiesCount(complexName, title));
} else {
setAmentiesCount(null);
}
return () => setAmentiesCount(null);
}, [complexName, title]);
return (
<div className="flex flex-col 2xl:gap-y-[0.556vw] gap-y-2">
+38
View File
@@ -525,6 +525,28 @@ export const projects: Project[] = [
tourAvailable: true,
},
],
amentiesFloors: [
{
title: "Rooftop",
total: 10,
},
{
title: "Sky Garden",
total: 15,
indoor: 3,
outdoor: 12,
},
{
title: "Podium Level",
total: 27,
indoor: 13,
outdoor: 14,
},
{
title: "Ground Level",
total: 7,
},
],
},
{
title: "Rove Home Dubai Marina",
@@ -1764,5 +1786,21 @@ export const projects: Project[] = [
],
},
],
amentiesFloors: [
{
title: "Rooftop",
total: 14,
},
{
title: "Podium Level",
total: 21,
indoor: 8,
outdoor: 13,
},
{
title: "Ground Level",
total: 14,
},
],
},
];
+1 -1
View File
@@ -162,7 +162,7 @@ function FloorsPage() {
</div>
</div>
<div
className="2xl:py-[1.667vw] 2xl:px-[1.111vw] max:2xl:p-4 bg-[#F3F3F2] 2xl:rounded-[0.833vw] rounded-lg relative 2xl:space-y-[2.222vw] space-y-8"
className="2xl:py-[1.667vw] 2xl:px-[1.111vw] max-2xl:p-4 bg-[#F3F3F2] 2xl:rounded-[0.833vw] rounded-lg relative 2xl:space-y-[2.222vw] space-y-8"
onMouseMove={(e) =>
!isMobile && setPosition({ x: e.clientX, y: e.clientY })
}
+8
View File
@@ -5,4 +5,12 @@ export default interface Project {
slug: string;
img: string;
types: UnitType[];
amentiesFloors: AmentiesFloor[];
}
export interface AmentiesFloor {
title: string;
total: number;
indoor?: number;
outdoor?: number;
}
-22
View File
@@ -1,22 +0,0 @@
export interface AmentiesCount {
total: number;
indoor?: number;
outdoor?: number;
}
export default function getAmentiesCount(
complexName: string,
floorTitle: string
):AmentiesCount | null {
const dict = new Map<string, AmentiesCount>([
["marasi-drive Rooftop", { total: 10 }],
["marasi-drive Sky Garden", { total: 15, indoor: 3, outdoor: 12 }],
["marasi-drive Podium Level", { total: 27, indoor: 13, outdoor: 14 }],
["marasi-drive Ground Level", { total: 7 }],
["dubai-marina Rooftop", { total: 14 }],
["dubai-marina Podium Level", { total: 21, indoor: 8, outdoor: 13 }],
["dubai-marina Ground Level", { total: 14 }],
]);
return dict.get(`${complexName} ${floorTitle}`) || null;
}