Skip to content

Commit 7cd38b9

Browse files
committed
add BokkingSearchBar
1 parent 584f849 commit 7cd38b9

File tree

8 files changed

+185
-10
lines changed

8 files changed

+185
-10
lines changed

src/App.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@ import { NotificationContainer } from "./contexts/notificationContext/Notificati
77

88

99

10+
11+
1012
function App() {
13+
1114
const router = createBrowserRouter(routes)
1215
const [queryClient] = useState(
1316
() =>
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
import {
2+
styled,
3+
alpha,
4+
SvgIcon,
5+
debounce,
6+
} from "@mui/material"
7+
import { SvgIconProps } from "@mui/material/SvgIcon"
8+
import { BookingDt } from "./BookingType"
9+
import { CustomInputBase } from "@/shared/ui/Inputs/CustomInputBase/CustomInputBase"
10+
11+
const Search = styled("div")(({ theme }) => ({
12+
display: "flex",
13+
alignItems: "center",
14+
borderRadius: "24px",
15+
backgroundColor: alpha(theme.palette.common.white, 1),
16+
border: "2px solid #D0CFCF",
17+
padding: "0 3px",
18+
marginTop: "-5px",
19+
width: "461px",
20+
}))
21+
22+
const SearchIconWrapper = styled("div")(({ theme }) => ({
23+
padding: theme.spacing(0, 1),
24+
height: "100%",
25+
pointerEvents: "none",
26+
display: "flex",
27+
alignItems: "center",
28+
justifyContent: "center",
29+
}))
30+
31+
32+
const SearchIcon = (props: SvgIconProps) => (
33+
<SvgIcon {...props}>
34+
<svg
35+
width="16"
36+
height="16"
37+
viewBox="0 0 16 16"
38+
style={{ width: 16, height: 16 }}
39+
fill="none"
40+
xmlns="http://www.w3.org/2000/svg"
41+
>
42+
<g clipPath="url(#clip0_4136_1067)">
43+
<path
44+
d="M7.33333 13.6667C10.8311 13.6667 13.6667 10.8311 13.6667 7.33333C13.6667 3.83553 10.8311 1 7.33333 1C3.83553 1 1 3.83553 1 7.33333C1 10.8311 3.83553 13.6667 7.33333 13.6667Z"
45+
stroke="#181A1A"
46+
strokeWidth="1.5"
47+
strokeLinecap="round"
48+
strokeLinejoin="round"
49+
/>
50+
<path
51+
d="M14.3333 14.3333L13 13"
52+
stroke="#181A1A"
53+
strokeWidth="1.5"
54+
strokeLinecap="round"
55+
strokeLinejoin="round"
56+
/>
57+
</g>
58+
<defs>
59+
<clipPath id="clip0_4136_1067">
60+
<rect width="16" height="16" fill="white" />
61+
</clipPath>
62+
</defs>
63+
</svg>
64+
</SvgIcon>
65+
)
66+
67+
type BookingProps = {
68+
placeholder?: string
69+
completeOptions?: BookingDt[]
70+
isLoading?: boolean
71+
search: string
72+
onSearchChange: (Booking: string) => void
73+
}
74+
75+
export const BookingSearchBar: React.FC<BookingProps> = props => {
76+
const {
77+
search,
78+
onSearchChange,
79+
} = props
80+
81+
const handleDebounceInputChange = debounce((_, value) => {
82+
onSearchChange(value)
83+
}, 100)
84+
85+
return (
86+
<Search >
87+
<SearchIconWrapper>
88+
<SearchIcon width={"16px"} height={"16px"} />
89+
</SearchIconWrapper>
90+
<CustomInputBase className='border-none h-10'
91+
placeholder="Введите ФИО, телефон или кличку питомца"
92+
onChange={event => handleDebounceInputChange('', event.target.value)}
93+
value={search}
94+
/>
95+
</Search>
96+
)
97+
}
98+
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { FC } from "react";
2+
import { BookingDt } from "./BookingType";
3+
4+
interface BookingSearchItemProps {
5+
Booking: BookingDt;
6+
}
7+
8+
export const BookingSearchItem: FC<BookingSearchItemProps> = ({ Booking }) => {
9+
return (
10+
<div key={Booking.id} className='p-4 border-indigo-600 mb-1'>
11+
Кличка: {Booking.PetDt.name}, Хозяин: {Booking.PetDt.ownerShortDt.firstName} {Booking.PetDt.ownerShortDt.lastName}, номер телефона: {Booking.PetDt.ownerShortDt.phoneNumber}
12+
</div>
13+
);
14+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { FC } from "react";
2+
import { BookingDt } from "./BookingType";
3+
import { BookingSearchItem } from "./BookingSearchBarItem";
4+
5+
interface BookingSearchListProps {
6+
Bookings: BookingDt[];
7+
}
8+
9+
export const BookingSearchList: FC<BookingSearchListProps> = ({ Bookings }) => {
10+
return (
11+
<div>
12+
{Bookings.map(Booking =>
13+
<BookingSearchItem Booking={Booking} />
14+
)}
15+
</div>
16+
);
17+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
2+
export interface OwnerShortDt {
3+
firstName: string;
4+
lastName: string;
5+
phoneNumber: string;
6+
}
7+
8+
export interface PetDt {
9+
name: string;
10+
birthDate?: string;
11+
breed?: string;
12+
color?: string;
13+
sex?: string;
14+
ownerShortDt: OwnerShortDt;
15+
}
16+
17+
export interface BookingDt {
18+
id: number;
19+
PetDt: PetDt;
20+
}
21+
22+
23+

src/modules/Booking/components/gridHeader/GridHeader.tsx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@ import { Stack } from "@mui/material"
22
import { EBookingView } from "../../model/types/BookingGridTypes"
33
import { HEADER_TABS } from "../../model/utils"
44
import { Tab } from "@/shared/ui/Tab"
5-
import { SearchComponent } from "@/shared/ui/SearchComponent"
65
import { useMemo } from "react"
7-
import { BookingDto } from "@/generated/bookings"
6+
import { BookingSearchBar } from "../BookingSearch/BookingSearchBar"
87

98
type TProps = {
109
onChangeTab: (tab: EBookingView) => void
@@ -37,11 +36,10 @@ export const GridHeader = ({
3736
{tabs}
3837
</Stack>
3938
<Stack>
40-
<SearchComponent<BookingDto>
41-
completeOptions={[]}
39+
<BookingSearchBar
4240
onSearchChange={onQueueChange}
4341
search={queue}
44-
optionName="price"
42+
placeholder="Введите ФИО, телефон или кличку питомца"
4543
/>
4644
</Stack>
4745
</Stack>

src/modules/Booking/pages/BookingGridPage/BookingGridPage.tsx

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,33 @@ import { useGetAllRooms } from "@/modules/Rooms/api/queries"
1919
import { EPageMode } from "@/modules/Rooms/pages/RoomsPage"
2020
import { BookingCell } from "../../components/BookingCell/BookingCell"
2121
import { CircularProgress } from "@mui/material"
22+
import { BookingDt } from "../../components/BookingSearch/BookingType"
23+
import { BookingSearchList } from "../../components/BookingSearch/BookingSearchBarList"
24+
25+
26+
const Bookings: BookingDt[] = [
27+
{ id: 1, PetDt: { name: 'Барсик', ownerShortDt: { firstName: "Иван", lastName: "Иванов", phoneNumber: "+7 (900) 123-45-67" } } },
28+
{ id: 2, PetDt: { name: 'Кеша', ownerShortDt: { firstName: "Петр", lastName: "Ильич", phoneNumber: "+7 (900) 123-45-67" } } },
29+
{ id: 3, PetDt: { name: 'Лелик', ownerShortDt: { firstName: "Федр", lastName: "Александрович", phoneNumber: "+7 (900) 123-45-67" } } },
30+
]
2231

2332
export const BookingGridPage: FC = () => {
33+
const [queue, setQueue] = useState<string>("")
34+
const searchBookingsFilter = Bookings?.filter(Booking => {
35+
return Booking.PetDt.name.toLowerCase().includes(queue.toLowerCase())
36+
})
37+
const handleSearchChange = (inputStr: string) => {
38+
setQueue(inputStr)
39+
}
40+
41+
42+
43+
44+
2445
const [activeTabHeader, setActiveTabHeader] = useState<TTabForHeader>(
2546
HEADER_TABS[0]
2647
)
27-
const [queue, setQueue] = useState<string>("")
48+
2849

2950
const handleTabChange = useCallback((tab: EBookingView) => {
3051
const selected = HEADER_TABS.find(el => el.value === tab)
@@ -70,7 +91,7 @@ export const BookingGridPage: FC = () => {
7091
<div className="py-4 px-6">
7192
<GridHeader
7293
onChangeTab={handleTabChange}
73-
onQueueChange={setQueue}
94+
onQueueChange={handleSearchChange}
7495
queue={queue}
7596
selectedTab={activeTabHeader.value}
7697
/>
@@ -154,8 +175,8 @@ export const BookingGridPage: FC = () => {
154175
index <= bookingInfo.endIndex
155176
const color =
156177
mapBookingStatusToColor[
157-
bookingInfo.booking.status ??
158-
BookingDtoStatus.STATUS_INITIAL
178+
bookingInfo.booking.status ??
179+
BookingDtoStatus.STATUS_INITIAL
159180
]
160181
const clientName = getFullName(
161182
bookingInfo.booking?.pets?.[0]?.ownerShortDto
@@ -191,6 +212,7 @@ export const BookingGridPage: FC = () => {
191212
</table>
192213
</div>
193214
</div>
215+
{queue && <BookingSearchList Bookings={searchBookingsFilter} />}
194216
</div>
195217
)
196218
}

src/modules/Employee/components/EmployeePageBody.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ export const EmployeePageBody: React.FC<TProps> = props => {
7474
</TableCell>
7575
</TableRow>
7676
) : (
77-
(employees || []).map(employee => (
77+
(employees || [])?.map(employee => (
7878
<EmployeeRowItem
7979
key={employee.id}
8080
employee={employee}

0 commit comments

Comments
 (0)