Changeset 0c6b92a for imaps-frontend/src/components/FilterBar
Legend:
- Unmodified
- Added
- Removed
-
imaps-frontend/src/components/FilterBar/FilterBar.jsx
rd565449 r0c6b92a 1 import React from "react";1 import React, { useState, useEffect, useCallback } from "react"; 2 2 import styles from "./FilterBar.module.css"; 3 3 4 function FilterBar() { 5 const filterLocation = (category) => { 6 console.log(`Filter locations by: ${category}`); 7 // filtering logic 8 }; 4 export default function FilterBar({roomTypes,map}) { 5 const [selectedCategory, setSelectedCategory] = useState("all"); 6 7 8 9 const filterLocation = useCallback((category) => { 10 map.setFilter(category) 11 setSelectedCategory(category); 12 },[]) 9 13 10 14 return ( 11 15 <div className={styles.wrapper}> 12 16 <div className={styles.scrollableContainer}> 13 <button className={styles.buttonValue} onClick={() => filterLocation("all")}> 17 <button 18 className={`${styles.buttonValue} ${selectedCategory === "all" ? styles.active : ""}`} 19 onClick={() => filterLocation("all")} 20 > 14 21 All 15 22 </button> 16 <button className={styles.buttonValue} onClick={() => filterLocation("Classrooms")}> 17 Classrooms 18 </button> 19 <button className={styles.buttonValue} onClick={() => filterLocation("Administrative")}> 20 Administrative 21 </button> 22 <button className={styles.buttonValue} onClick={() => filterLocation("Labs")}> 23 Labs 24 </button> 25 <button className={styles.buttonValue} onClick={() => filterLocation("Restrooms")}> 26 Restrooms 27 </button> 28 <button className={styles.buttonValue} onClick={() => filterLocation("Cafeteria")}> 29 Cafeteria 30 </button> 23 24 {roomTypes?.map((roomType, index) => ( 25 <button 26 key={index} 27 className={`${styles.buttonValue} ${selectedCategory === roomType.name ? styles.active : ""}`} 28 onClick={() => filterLocation(roomType.name)} 29 > 30 {roomType.name} 31 </button> 32 ))} 31 33 </div> 32 34 </div> … … 34 36 } 35 37 36 export default FilterBar;
Note:
See TracChangeset
for help on using the changeset viewer.