File tree Expand file tree Collapse file tree 4 files changed +71
-11
lines changed
Expand file tree Collapse file tree 4 files changed +71
-11
lines changed Original file line number Diff line number Diff line change 1- import { Search } from "lucide-react " ;
1+ import { SearchBar } from "@/components/ui/SearchBar " ;
22
33type GuestSearchBarProps = {
44 value : string ;
@@ -7,15 +7,6 @@ type GuestSearchBarProps = {
77
88export function GuestSearchBar ( { value, onChange } : GuestSearchBarProps ) {
99 return (
10- < label className = "flex w-full items-center gap-[1vw] border border-black bg-white px-[1vw] py-[1vh]" >
11- < input
12- type = "text"
13- value = { value }
14- onChange = { ( event ) => onChange ( event . target . value ) }
15- placeholder = "Search Guests"
16- className = "w-full bg-transparent text-[1vw] text-black outline-none placeholder:text-black"
17- />
18- < Search className = "h-[2vh] w-[2vh] text-black" />
19- </ label >
10+ < SearchBar value = { value } onChange = { onChange } placeholder = "Search Guests" />
2011 ) ;
2112}
Original file line number Diff line number Diff line change 1+ import { SearchBar } from "../ui/SearchBar" ;
12import { FloorDropdown } from "./FloorDropdown" ;
23import { OrderByDropdown } from "./OrderByDropdown" ;
34import { RoomsFilterPopover } from "@/components/rooms/RoomsFilterPopover" ;
45
56type RoomsToolbarProps = {
7+ searchTerm : string ;
8+ onChangeSearchTerm : ( value : string ) => void ;
69 selectedFloors : Array < number > ;
710 onChangeSelectedFloors : ( floors : Array < number > ) => void ;
811 ascending : boolean ;
912 setAscending : ( ascending : boolean ) => void ;
1013} ;
1114
1215export function RoomsToolbar ( {
16+ searchTerm,
17+ onChangeSearchTerm,
1318 selectedFloors,
1419 onChangeSelectedFloors,
1520 ascending,
1621 setAscending,
1722} : RoomsToolbarProps ) {
1823 return (
1924 < div className = "flex items-center gap-3" >
25+ < SearchBar
26+ value = { searchTerm }
27+ onChange = { onChangeSearchTerm }
28+ placeholder = "Search for a room..."
29+ className = "w-full max-w-[16rem]"
30+ />
2031 < FloorDropdown
2132 selected = { selectedFloors }
2233 onChangeSelectedFloors = { onChangeSelectedFloors }
Original file line number Diff line number Diff line change 1+ import { Search } from "lucide-react" ;
2+ import type { InputHTMLAttributes , ReactNode } from "react" ;
3+ import { cn } from "@/lib/utils" ;
4+
5+ type SearchBarProps = Omit <
6+ InputHTMLAttributes < HTMLInputElement > ,
7+ "value" | "onChange"
8+ > & {
9+ value : string ;
10+ onChange : ( value : string ) => void ;
11+ className ?: string ;
12+ inputClassName ?: string ;
13+ iconClassName ?: string ;
14+ icon ?: ReactNode ;
15+ } ;
16+
17+ export function SearchBar ( {
18+ value,
19+ onChange,
20+ placeholder = "Search for a room..." ,
21+ className,
22+ inputClassName,
23+ iconClassName,
24+ icon,
25+ ...inputProps
26+ } : SearchBarProps ) {
27+ return (
28+ < label
29+ className = { cn (
30+ "flex w-full items-center justify-between rounded-[4px] border border-stroke-subtle bg-bg-primary px-3 py-2" ,
31+ className ,
32+ ) }
33+ >
34+ < input
35+ type = "text"
36+ value = { value }
37+ onChange = { ( event ) => onChange ( event . target . value ) }
38+ placeholder = { placeholder }
39+ className = { cn (
40+ "w-full bg-transparent text-sm leading-tight text-text-default outline-none placeholder:text-text-subtle" ,
41+ inputClassName ,
42+ ) }
43+ { ...inputProps }
44+ />
45+ < span
46+ className = { cn (
47+ "ml-2 flex shrink-0 items-center text-text-subtle" ,
48+ iconClassName ,
49+ ) }
50+ >
51+ { icon ?? < Search className = "size-4" strokeWidth = { 2 } /> }
52+ </ span >
53+ </ label >
54+ ) ;
55+ }
Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ export const Route = createFileRoute("/_protected/rooms/")({
1616} ) ;
1717
1818function RoomsPage ( ) {
19+ const [ searchTerm , setSearchTerm ] = useState ( "" ) ;
1920 const [ selectedFloors , setSelectedFloors ] = useState < Array < number > > ( [ ] ) ;
2021 const [ selectedRoom , setSelectedRoom ] =
2122 useState < RoomWithOptionalGuestBooking | null > ( null ) ;
@@ -60,6 +61,8 @@ function RoomsPage() {
6061 contentClassName = { "h-full" }
6162 >
6263 < RoomsToolbar
64+ searchTerm = { searchTerm }
65+ onChangeSearchTerm = { setSearchTerm }
6366 selectedFloors = { selectedFloors }
6467 onChangeSelectedFloors = { setSelectedFloors }
6568 ascending = { ascending }
You can’t perform that action at this time.
0 commit comments