Skip to content

Commit 0e70e3b

Browse files
committed
Labotel: Fix booking from room details
We were always opening the room details modal in book mode, but in the room list we don't have any booking data (date, time, etc).
1 parent 80b3da3 commit 0e70e3b

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

labotel/indico_labotel/client/js/components/LabRenderer.jsx

+7-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import PropTypes from 'prop-types';
99
import React from 'react';
10-
import {useDispatch} from 'react-redux';
10+
import {useDispatch, useSelector} from 'react-redux';
1111
import {Item} from 'semantic-ui-react';
1212

1313
import {actions as roomActions} from 'indico/modules/rb/common/rooms';
@@ -19,7 +19,12 @@ import './LabRenderer.module.scss';
1919
export default function LabItem({roomInstance, room}) {
2020
const {actions} = Slot.split(roomInstance.props.children);
2121
const dispatch = useDispatch();
22-
const openRoomDetails = () => dispatch(roomActions.openRoomDetailsBook(room.id));
22+
const pathname = useSelector(state => state.router.location.pathname);
23+
const isBooking = pathname === '/book';
24+
const openRoomDetails = () =>
25+
dispatch(
26+
isBooking ? roomActions.openRoomDetailsBook(room.id) : roomActions.openRoomDetails(room.id)
27+
);
2328
return (
2429
<Item key={room.id} styleName="lab-item">
2530
<Item.Image

0 commit comments

Comments
 (0)