Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 2 additions & 11 deletions clients/web/src/components/guests/GuestSearchBar.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Search } from "lucide-react";
import { SearchBar } from "@/components/ui/SearchBar";

type GuestSearchBarProps = {
value: string;
Expand All @@ -7,15 +7,6 @@ type GuestSearchBarProps = {

export function GuestSearchBar({ value, onChange }: GuestSearchBarProps) {
return (
<label className="flex w-full items-center gap-[1vw] border border-black bg-white px-[1vw] py-[1vh]">
<input
type="text"
value={value}
onChange={(event) => onChange(event.target.value)}
placeholder="Search Guests"
className="w-full bg-transparent text-[1vw] text-black outline-none placeholder:text-black"
/>
<Search className="h-[2vh] w-[2vh] text-black" />
</label>
<SearchBar value={value} onChange={onChange} placeholder="Search Guests" />
);
}
11 changes: 11 additions & 0 deletions clients/web/src/components/rooms/RoomsToolbar.tsx
Original file line number Diff line number Diff line change
@@ -1,22 +1,33 @@
import { SearchBar } from "../ui/SearchBar";
import { FloorDropdown } from "./FloorDropdown";
import { OrderByDropdown } from "./OrderByDropdown";
import { RoomsFilterPopover } from "@/components/rooms/RoomsFilterPopover";

type RoomsToolbarProps = {
searchTerm: string;
onChangeSearchTerm: (value: string) => void;
selectedFloors: Array<number>;
onChangeSelectedFloors: (floors: Array<number>) => void;
ascending: boolean;
setAscending: (ascending: boolean) => void;
};

export function RoomsToolbar({
searchTerm,
onChangeSearchTerm,
selectedFloors,
onChangeSelectedFloors,
ascending,
setAscending,
}: RoomsToolbarProps) {
return (
<div className="flex items-center gap-3">
<SearchBar
value={searchTerm}
onChange={onChangeSearchTerm}
placeholder="Search for a room..."
className="w-full max-w-[16rem]"
/>
<FloorDropdown
selected={selectedFloors}
onChangeSelectedFloors={onChangeSelectedFloors}
Expand Down
55 changes: 55 additions & 0 deletions clients/web/src/components/ui/SearchBar.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import { Search } from "lucide-react";
import type { InputHTMLAttributes, ReactNode } from "react";
import { cn } from "@/lib/utils";

type SearchBarProps = Omit<
InputHTMLAttributes<HTMLInputElement>,
"value" | "onChange"
> & {
value: string;
onChange: (value: string) => void;
className?: string;
inputClassName?: string;
iconClassName?: string;
icon?: ReactNode;
};

export function SearchBar({
value,
onChange,
placeholder = "Search for a room...",
className,
inputClassName,
iconClassName,
icon,
...inputProps
}: SearchBarProps) {
return (
<label
className={cn(
"flex w-full items-center justify-between rounded-[4px] border border-stroke-subtle bg-bg-primary px-3 py-2",
className,
)}
>
<input
type="text"
value={value}
onChange={(event) => onChange(event.target.value)}
placeholder={placeholder}
className={cn(
"w-full bg-transparent text-sm leading-tight text-text-default outline-none placeholder:text-text-subtle",
inputClassName,
)}
{...inputProps}
/>
<span
className={cn(
"ml-2 flex shrink-0 items-center text-text-subtle",
iconClassName,
)}
>
{icon ?? <Search className="size-4" strokeWidth={2} />}
</span>
</label>
);
}
3 changes: 3 additions & 0 deletions clients/web/src/routes/_protected/rooms.index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export const Route = createFileRoute("/_protected/rooms/")({
});

function RoomsPage() {
const [searchTerm, setSearchTerm] = useState("");
const [selectedFloors, setSelectedFloors] = useState<Array<number>>([]);
const [selectedRoom, setSelectedRoom] =
useState<RoomWithOptionalGuestBooking | null>(null);
Expand Down Expand Up @@ -60,6 +61,8 @@ function RoomsPage() {
contentClassName={"h-full"}
>
<RoomsToolbar
searchTerm={searchTerm}
onChangeSearchTerm={setSearchTerm}
selectedFloors={selectedFloors}
onChangeSelectedFloors={setSelectedFloors}
ascending={ascending}
Expand Down
Loading