@snapdragonsnursery/react-components 1.19.9 → 1.20.0
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.
- package/package.json +1 -1
- package/src/ChildSearchModal.jsx +13 -9
package/package.json
CHANGED
package/src/ChildSearchModal.jsx
CHANGED
|
@@ -298,19 +298,23 @@ const ChildSearchModal = ({
|
|
|
298
298
|
// Fetch rooms for selected site
|
|
299
299
|
useEffect(() => {
|
|
300
300
|
const fetchRooms = async () => {
|
|
301
|
-
if (!advancedFilters.selectedSiteId
|
|
301
|
+
if (!advancedFilters.selectedSiteId) return;
|
|
302
302
|
|
|
303
303
|
try {
|
|
304
304
|
// Find the selected site and extract its rooms
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
305
|
+
if (sites && sites.length > 0) {
|
|
306
|
+
const selectedSite = sites.find(
|
|
307
|
+
(site) => site.site_id === parseInt(advancedFilters.selectedSiteId, 10)
|
|
308
|
+
);
|
|
309
|
+
|
|
310
|
+
if (selectedSite && selectedSite.rooms) {
|
|
311
|
+
setRooms(selectedSite.rooms);
|
|
312
|
+
return;
|
|
313
|
+
}
|
|
313
314
|
}
|
|
315
|
+
|
|
316
|
+
// If not available from sites, clear rooms
|
|
317
|
+
setRooms([]);
|
|
314
318
|
} catch (err) {
|
|
315
319
|
console.error("Error fetching rooms:", err);
|
|
316
320
|
setRooms([]);
|