@@ -19,6 +19,8 @@ import LineBreakText from "~/components/layout/line-break-text";
19
19
import { List } from "~/components/list" ;
20
20
import { ListContentWrapper } from "~/components/list/content-wrapper" ;
21
21
import { Filters } from "~/components/list/filters" ;
22
+ import type { SortingDirection } from "~/components/list/filters/sort-by" ;
23
+ import { SortBy } from "~/components/list/filters/sort-by" ;
22
24
import { Badge } from "~/components/shared/badge" ;
23
25
import { Button } from "~/components/shared/button" ;
24
26
import { Td , Th } from "~/components/table" ;
@@ -80,6 +82,10 @@ export async function loader({ context, request }: LoaderFunctionArgs) {
80
82
const cookie = await updateCookieWithPerPage ( request , perPageParam ) ;
81
83
const { perPage } = cookie ;
82
84
85
+ const orderBy = searchParams . get ( "orderBy" ) ?? "from" ;
86
+ const orderDirection = ( searchParams . get ( "orderDirection" ) ??
87
+ "asc" ) as SortingDirection ;
88
+
83
89
/**
84
90
* For self service and base users, we need to get the teamMember to be able to filter by it as well.
85
91
* This is to handle a case when a booking was assigned when there wasn't a user attached to a team member but they were later on linked.
@@ -127,6 +133,8 @@ export async function loader({ context, request }: LoaderFunctionArgs) {
127
133
} ) ,
128
134
custodianTeamMemberIds : teamMemberIds ,
129
135
...selfServiceData ,
136
+ orderBy,
137
+ orderDirection,
130
138
} ) ,
131
139
132
140
// team members/custodian
@@ -222,6 +230,12 @@ export const shouldRevalidate: ShouldRevalidateFunction = ({
222
230
return defaultShouldRevalidate ;
223
231
} ;
224
232
233
+ const BOOKING_SORTING_OPTIONS = {
234
+ from : "From Date" ,
235
+ to : "To Date" ,
236
+ name : "Name" ,
237
+ } as const ;
238
+
225
239
export default function BookingsIndexPage ( {
226
240
className,
227
241
disableBulkActions = false ,
@@ -292,6 +306,13 @@ export default function BookingsIndexPage({
292
306
< Filters
293
307
slots = { {
294
308
"left-of-search" : < StatusFilter statusItems = { BookingStatus } /> ,
309
+ "right-of-search" : (
310
+ < SortBy
311
+ sortingOptions = { BOOKING_SORTING_OPTIONS }
312
+ defaultSortingBy = "from"
313
+ defaultSortingDirection = "asc"
314
+ />
315
+ ) ,
295
316
} }
296
317
>
297
318
< When
0 commit comments