File tree Expand file tree Collapse file tree 2 files changed +8
-5
lines changed
Expand file tree Collapse file tree 2 files changed +8
-5
lines changed Original file line number Diff line number Diff line change @@ -47,13 +47,16 @@ export async function GET(request: NextRequest) {
4747 }
4848
4949 if ( search ) {
50+ // Search only indexed fields for performance
5051 filter . $or = [
5152 { request_id : { $regex : search , $options : 'i' } } ,
52- { 'recipient.email' : { $regex : search , $options : 'i' } } ,
53- { 'recipient.phone' : { $regex : search , $options : 'i' } } ,
54- { 'recipient.user_id' : { $regex : search , $options : 'i' } } ,
55- { client_id : { $regex : search , $options : 'i' } }
53+ { client_id : { $regex : search , $options : 'i' } } ,
54+ { client_name : { $regex : search , $options : 'i' } }
5655 ] ;
56+ // Also search by notification ID if it looks like a valid ObjectId
57+ if ( / ^ [ a - f 0 - 9 ] { 24 } $ / i. test ( search ) ) {
58+ filter . $or . push ( { _id : search } as any ) ;
59+ }
5760 }
5861
5962 if ( from || to ) {
Original file line number Diff line number Diff line change @@ -116,7 +116,7 @@ export default function EventsPage() {
116116 < PageToolbar className = "flex-col sm:flex-row gap-3" >
117117 < PageToolbarSection className = "w-full sm:w-auto sm:flex-1 sm:max-w-md" >
118118 < Input
119- placeholder = "Search by request ID, recipient ..."
119+ placeholder = "Search by notification ID, request ID, client ID/name ..."
120120 value = { searchInput }
121121 onChange = { ( e ) => setSearchInput ( e . target . value ) }
122122 onKeyDown = { handleKeyDown }
You can’t perform that action at this time.
0 commit comments