Skip to content

Commit d67e648

Browse files
Merge pull request #9 from QuickBlox/feature/provider-search-appointments
Implemented search appointments in provider app
2 parents a420fd5 + 70a2760 commit d67e648

File tree

6 files changed

+100
-18
lines changed

6 files changed

+100
-18
lines changed

packages/provider/src/icons/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,4 @@ export { default as ClientsSvg } from './clients.svg'
3030
export { default as InfoSvg } from './info.svg'
3131
export { default as TrashSvg } from './trash.svg'
3232
export { default as UpdateSvg } from './update.svg'
33+
export { default as SearchSvg } from './search.svg'
Lines changed: 11 additions & 0 deletions
Loading

packages/provider/src/modules/Appointments/index.tsx

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import FlatList from '../../components/FlatList'
66
import AppointmentListItem from './ListItem'
77
import useComponent, { AppointmentsProps } from './useComponent'
88
import './styles.css'
9+
import { SearchSvg } from '../../icons'
910

1011
function hasUnreadMessage(
1112
appointment: QBAppointment,
@@ -22,17 +23,20 @@ function hasUnreadMessage(
2223
export default function Appointments(props: AppointmentsProps) {
2324
const { isOpenMenu, selected } = props
2425
const {
25-
data: { isOffline },
26+
data: { isOffline, search, appointmentsList },
2627
store: {
2728
callAppointmentId,
2829
callDuration,
2930
dialogs,
3031
users,
3132
usersLoading,
32-
appointmentActiveList,
3333
appointmentLoading,
3434
},
35-
handlers: { onRemoveClick, handleSelect, loadMoreAppointments },
35+
handlers: {
36+
onRemoveClick,
37+
handleSelect,
38+
handleChangeSearch,
39+
},
3640
} = useComponent(props)
3741
const { t } = useTranslation()
3842

@@ -61,13 +65,22 @@ export default function Appointments(props: AppointmentsProps) {
6165
<aside className={cn('appointments-container', { open: isOpenMenu })}>
6266
<Tabs value="queue">
6367
<Tabs.Tab name="queue" title={t('WaitingRoom')} disabled={isOffline}>
64-
<FlatList
65-
data={appointmentActiveList}
66-
refreshing={appointmentLoading}
67-
renderItem={renderListItem}
68-
onEndReachedThreshold={0.8}
69-
onEndReached={loadMoreAppointments}
70-
/>
68+
<div className="appointment-search">
69+
<SearchSvg className="icon" />
70+
<input
71+
onChange={handleChangeSearch}
72+
placeholder={t('Search')}
73+
type="search"
74+
value={search}
75+
/>
76+
</div>
77+
<div className="appointments">
78+
<FlatList
79+
data={appointmentsList}
80+
refreshing={appointmentLoading}
81+
renderItem={renderListItem}
82+
/>
83+
</div>
7184
</Tabs.Tab>
7285
</Tabs>
7386
</aside>

packages/provider/src/modules/Appointments/styles.css

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,48 @@
224224
width: 20px;
225225
}
226226

227+
.appointments-container .appointment-search {
228+
display: flex;
229+
background-color: var(--AppointmentsSearch-backgroundColor);
230+
justify-content: space-between;
231+
align-items: center;
232+
border-radius: 4px;
233+
border: 1px solid var(--AppointmentsSearch-borderColor);;
234+
box-sizing: border-box;
235+
height: 45px;
236+
margin: 12px;
237+
padding-right: 10px;
238+
}
239+
240+
.appointments-container .appointment-search input {
241+
width: 100%;
242+
border: none;
243+
outline: none;
244+
font-size: var(--font-size-xl);
245+
line-height: 22px;
246+
}
247+
248+
.appointments-container .appointment-search input::placeholder {
249+
color: var(--AppointmentsSearchPlaceholder-color);
250+
}
251+
252+
.appointments-container .appointment-search .icon {
253+
fill: var(--AppointmentsSearchIcon-fill);
254+
margin: 10px;
255+
height: 15px;
256+
width: 15px;
257+
}
258+
259+
.appointments-container .appointments {
260+
border-top: 1px solid var(--AppointmentsList-borderColor);
261+
overflow: hidden;
262+
height: 100%;
263+
}
264+
265+
.appointments-container .appointments .list {
266+
height: 100%;
267+
}
268+
227269
@media screen and (max-width: 768px) {
228270
.appointments-container {
229271
border-radius: 0;

packages/provider/src/modules/Appointments/useComponent.ts

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { useEffect } from 'react'
1+
import { ChangeEvent, useEffect, useMemo, useState } from 'react'
22
import { useSelector } from 'react-redux'
33

44
import {
@@ -71,6 +71,11 @@ export default createUseComponent((props: AppointmentsProps) => {
7171
sendSystemMessage,
7272
})
7373
const isOffline = useIsOffLine()
74+
const [search, setSearch] = useState('')
75+
76+
const handleChangeSearch = ({
77+
target: { value },
78+
}: ChangeEvent<HTMLInputElement>) => setSearch(value)
7479

7580
const {
7681
connected,
@@ -85,6 +90,10 @@ export default createUseComponent((props: AppointmentsProps) => {
8590
appointmentEntries,
8691
} = store
8792

93+
const appointmentsList = search ? appointmentActiveList.filter(
94+
({ client_id }) => users[client_id]?.full_name.toLowerCase().includes(search.toLowerCase())
95+
) : appointmentActiveList
96+
8897
const handleSelect = (item: QBAppointment) => {
8998
if (isOpenMenu) toggleMenu()
9099

@@ -139,11 +148,6 @@ export default createUseComponent((props: AppointmentsProps) => {
139148
}
140149
}
141150

142-
const loadMoreAppointments = () => {
143-
if (appointmentLoading || !appointmentHasMore) return
144-
handleGetAppointments(appointmentSkip + PER_PAGE)
145-
}
146-
147151
useEffect(() => {
148152
if (selected && appointmentActiveList && !isOffline) {
149153
const selectedAppointment = appointmentEntries[selected]
@@ -163,6 +167,12 @@ export default createUseComponent((props: AppointmentsProps) => {
163167
}
164168
}, [ready && connected])
165169

170+
useEffect(() => {
171+
if (!appointmentLoading && appointmentHasMore) {
172+
handleGetAppointments(appointmentSkip + PER_PAGE)
173+
}
174+
}, [appointmentLoading, appointmentHasMore, appointmentSkip])
175+
166176
useEffect(() => {
167177
const handleSiteFocus = () => {
168178
handleGetAppointments(appointmentSkip)
@@ -196,11 +206,11 @@ export default createUseComponent((props: AppointmentsProps) => {
196206
return {
197207
store,
198208
actions,
199-
data: { isOffline },
209+
data: { isOffline, search, appointmentsList },
200210
handlers: {
201211
onRemoveClick,
202212
handleSelect,
203-
loadMoreAppointments,
213+
handleChangeSearch,
204214
},
205215
}
206216
})

packages/provider/src/variables.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,11 @@
202202
--AppointmentsItemChatUnreadDot-borderColor: var(--blue-1);
203203
--AppointmentsItemOnCallDots-color: var(--grey-13);
204204
--AppointmentsItemOnCallDots-color--selected: var(--grey-1);
205+
--AppointmentsSearch-backgroundColor: var(--grey-1);
206+
--AppointmentsSearch-borderColor: var(--blue-3);
207+
--AppointmentsSearchPlaceholder-color: var(--blue-3);
208+
--AppointmentsSearchIcon-fill: var(--blue-3);
209+
--AppointmentsList-borderColor: var(--blue-3);
205210

206211
--CallControlBtn-backgroundColor: var(--grey-1);
207212
--CallControlBtn-color: var(--grey-1);

0 commit comments

Comments
 (0)