Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Availability matrix doesn't update if there are no rooms available #656

Open
bfirsh opened this issue Nov 13, 2019 · 1 comment
Open

Availability matrix doesn't update if there are no rooms available #656

bfirsh opened this issue Nov 13, 2019 · 1 comment

Comments

@bfirsh
Copy link
Member

bfirsh commented Nov 13, 2019

Steps to reproduce:

There is error in console.

@est271
Copy link

est271 commented Nov 26, 2019

I found the source of this bug but making modifications to correct/avoid it will change the behavior of the “Room Api List” page that uses the Django REST framework.

It appears from the RoomApiList.filter_queryset() method inside the module “modernomad/core/views/booking.py” that it is implemented to send a rooms information to the Api page only if the room is fully available within the arrive and depart dates in the Daterangeselector.

In RoomIndexOrDetail.jsx the fetchRooms method assigns to this.state.rooms the information that is in the Room Api page. If there is at least 1 room available during those dates then the AvailabilityMatrix.jsx renders the information for that 1 room. But if none of the rooms are available then this.state.rooms is set to an empty list which then sets this.props.rooms to an empty list. What happens next is that line 38 of the AvailabilityMatrix.jsx file will attempt to index that empty list.

const dateColumn = this.props.rooms[0].availabilities.map((availability) => {

This results in the error into the console and no longer displays the availability matrix correctly until the page is reloaded.

est271/modernomad/pull/2/files

Edit:
@bfirsh after revisiting this comment I realize that instead of commenting out lines of code, the best course of action is to refactor the methods in class RoomApiList. Beforehand, this will require a discussion between members of this repo about how to handle the interactions with the API. Best of luck with this app and hopefully I pointed in the right direction to help fix this bug.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants