This pull request adds a feature to show the availability information of rooms on the map view of the Rogue THI app. It implements a new function getRoomAvailability to query the backend API for the occupancy status of rooms. It updates the RoomMap.jsx component to fetch and display the availability data on the room popups. It also adds a new localization key rooms.map.roomAvailabilityUnknown for both German and English languages. It removes some unnecessary console log statements and adds some commented-out code for debugging purposes.
To show rooms on the map with easeWe added getRoomAvailabilityBut we left some debug codeThat should not be in prod modeSo please remove the console logs, pretty please
Defined a new async function getRoomAvailability in rooms-utils.js that fetches the free time slots for a given list of rooms and an optional date (link)
Imported getRoomAvailability in RoomMap.jsx and declared a new state variable roomAvailabilityList using the useState hook (link, link)
Invoked loadRoomAvailability in the useEffect hook in RoomMap.jsx, passing the filtered variable as an argument. This function calls getRoomAvailability and updates the roomAvailabilityList state variable with the data from the backend API (link, link)
Modified the renderRoom function in RoomMap.jsx to display the availability information of the room in the popup using the t function and the rooms.map.freeFromUntil key from the rooms.json files. The roomAvailabilityList state variable is accessed using the entry.properties.Raum key, which is the room name. The from and until properties of the availability object are formatted as hours and minutes. If the availability object is undefined or null, the text 'Error' is displayed instead (link)
https://github.com/neuland-ingolstadt/neuland.app/issues/142
🤖 Generated by Copilot at d13f16a
Summary
🐛🌐🌍
This pull request adds a feature to show the availability information of rooms on the map view of the Rogue THI app. It implements a new function
getRoomAvailability
to query the backend API for the occupancy status of rooms. It updates theRoomMap.jsx
component to fetch and display the availability data on the room popups. It also adds a new localization keyrooms.map.roomAvailabilityUnknown
for both German and English languages. It removes some unnecessary console log statements and adds some commented-out code for debugging purposes.Walkthrough
getRoomAvailability
inrooms-utils.js
that fetches the free time slots for a given list of rooms and an optional date (link)getRoomAvailability
inRoomMap.jsx
and declared a new state variableroomAvailabilityList
using theuseState
hook (link, link)loadRoomAvailability
in theuseEffect
hook inRoomMap.jsx
, passing thefiltered
variable as an argument. This function callsgetRoomAvailability
and updates theroomAvailabilityList
state variable with the data from the backend API (link, link)renderRoom
function inRoomMap.jsx
to display the availability information of the room in the popup using thet
function and therooms.map.freeFromUntil
key from therooms.json
files. TheroomAvailabilityList
state variable is accessed using theentry.properties.Raum
key, which is the room name. Thefrom
anduntil
properties of the availability object are formatted as hours and minutes. If the availability object is undefined or null, the text 'Error' is displayed instead (link)