nestiq-component-library 1.1.169 → 1.1.170
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -14,6 +14,11 @@ import FloorPlanPopup from "../FloorPlanPopup/FloorPlanPopup";
|
|
|
14
14
|
interface PopupProps {
|
|
15
15
|
pictureUrls: { title: string; url: string }[];
|
|
16
16
|
floorPlanUrl: string;
|
|
17
|
+
property: {
|
|
18
|
+
selectedFloorPlan?: string;
|
|
19
|
+
pictures: { contentUrl: string; pictureType: { id: number } }[];
|
|
20
|
+
};
|
|
21
|
+
baseUrl: string;
|
|
17
22
|
}
|
|
18
23
|
export default function PropertyImageList(prop: PopupProps) {
|
|
19
24
|
const [currentImageIndex, setCurrentImageIndex] = useState(0);
|
|
@@ -26,29 +31,45 @@ export default function PropertyImageList(prop: PopupProps) {
|
|
|
26
31
|
|
|
27
32
|
setCurrentImageIndex((prevIndex) => {
|
|
28
33
|
let newIndex;
|
|
34
|
+
|
|
29
35
|
if (direction === "left") {
|
|
30
36
|
newIndex =
|
|
31
37
|
(prevIndex - 1 + prop.pictureUrls.length) % prop.pictureUrls.length;
|
|
32
|
-
} else
|
|
38
|
+
} else {
|
|
33
39
|
newIndex = (prevIndex + 1) % prop.pictureUrls.length;
|
|
34
40
|
}
|
|
41
|
+
|
|
42
|
+
if (imageListRef.current) {
|
|
43
|
+
imageListRef.current.scrollTo({
|
|
44
|
+
left: newIndex * 150,
|
|
45
|
+
behavior: "smooth",
|
|
46
|
+
});
|
|
47
|
+
}
|
|
35
48
|
return newIndex || 0;
|
|
36
49
|
});
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
const floorPlanImages =
|
|
53
|
+
prop.property.pictures
|
|
54
|
+
?.filter((p) => p.pictureType?.id === 1)
|
|
55
|
+
.map((p, index) => ({
|
|
56
|
+
url: prop.baseUrl + p.contentUrl,
|
|
57
|
+
title: `Floor Plan ${index + 1}`,
|
|
58
|
+
})) || [];
|
|
37
59
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
60
|
+
if (prop.property.selectedFloorPlan) {
|
|
61
|
+
floorPlanImages.push({
|
|
62
|
+
url: prop.property.selectedFloorPlan,
|
|
63
|
+
title: "Selected Floor Plan",
|
|
41
64
|
});
|
|
42
|
-
}
|
|
65
|
+
}
|
|
43
66
|
|
|
44
67
|
const toggleAllPhotos = () => {
|
|
45
68
|
setIsImagePopupOpen(!isImagePopupOpen);
|
|
46
69
|
};
|
|
47
70
|
|
|
48
71
|
const floorPlanClickHandler = () => {
|
|
49
|
-
|
|
50
|
-
setIsFloorPlanPopupOpen(true);
|
|
51
|
-
}
|
|
72
|
+
setIsFloorPlanPopupOpen(true);
|
|
52
73
|
};
|
|
53
74
|
|
|
54
75
|
const floorPlanPopupCloseHandler = () => {
|
|
@@ -208,9 +229,9 @@ export default function PropertyImageList(prop: PopupProps) {
|
|
|
208
229
|
|
|
209
230
|
{/* Popup for floor plan */}
|
|
210
231
|
{isFloorPlanPopupOpen && (
|
|
211
|
-
<
|
|
212
|
-
|
|
213
|
-
|
|
232
|
+
<ImageListPopup
|
|
233
|
+
pictureUrls={floorPlanImages}
|
|
234
|
+
onClose={() => setIsFloorPlanPopupOpen(false)}
|
|
214
235
|
/>
|
|
215
236
|
)}
|
|
216
237
|
</div>
|