import { FC } from "react";
import { useDispatch } from "react-redux";

import SearchableList from "components/SearchableList";
import RoomListEntry from "modules/room/RoomListEntry";
import { RoomSliceState, roomGetAll } from "modules/room/slice";

const SearchableRoomList = SearchableList(RoomListEntry);

const RoomList: FC<RoomSliceState> = ({ rooms }) => {
  const dispatch = useDispatch();
  const refresh = () => {
    dispatch(roomGetAll());
  };

  return <SearchableRoomList id="room-list" map={rooms} refresh={refresh} />;
};

export default RoomList;
