44 <div class =" flex flex-col lg:flex-row justify-between items-start lg:items-center gap-4" >
55 <h2 class =" text-xl font-bold text-slate-900 " >Subscriber Directory</h2 >
66 <div class =" flex flex-col sm:flex-row gap-2 w-full lg:w-auto" >
7- <div class =" relative flex-1 sm:w-64" >
8- <BaseIcon name =" search" class =" absolute top-1/2 -translate-y-1/2 w-4 h-4 text-slate-400" />
9- <input
10- v-model =" searchQuery"
11- placeholder =" Search subscribers..."
12- class =" w-full pl-9 pr-4 py-2 text-sm border border-slate-200 rounded-lg bg-slate-50 focus:ring-2 focus:ring-blue-500 outline-none transition-all"
13- type =" text"
14- @input =" handleSearch"
7+ <div class =" flex gap-2 flex-1 sm:w-[400px]" >
8+ <div class =" relative flex-1" >
9+ <BaseIcon name =" search" class =" absolute top-1/2 -translate-y-1/2 w-4 h-4 text-slate-400" />
10+ <input
11+ v-model =" searchQuery"
12+ placeholder =" Search subscribers..."
13+ class =" w-full pl-9 pr-4 py-2 text-sm border border-slate-200 rounded-lg bg-slate-50 focus:ring-2 focus:ring-blue-500 outline-none transition-all"
14+ type =" text"
15+ @input =" handleSearch"
16+ >
17+ </div >
18+ <select
19+ v-model =" searchColumn"
20+ class =" px-3 py-2 text-sm border border-slate-200 rounded-lg bg-slate-50 focus:ring-2 focus:ring-blue-500 outline-none transition-all"
21+ @change =" handleSearch"
1522 >
23+ <option v-for =" col in searchColumns" :key =" col.id" :value =" col.id" >
24+ {{ col.label }}
25+ </option >
26+ </select >
1627 </div >
1728 <div class =" flex gap-2" >
1829 <button class =" flex-1 sm:flex-none p-2 border border-slate-200 rounded-lg hover:bg-slate-50 transition-colors flex justify-center items-center" >
@@ -76,8 +87,15 @@ const subscribers = ref(initialSubscribers)
7687const pagination = ref (initialPagination)
7788const currentFilter = ref (null )
7889const searchQuery = ref (' ' )
90+ const searchColumn = ref (' email' )
7991let searchTimeout = null
8092
93+ const searchColumns = [
94+ { id: ' email' , label: ' Email' },
95+ { id: ' foreignKey' , label: ' Foreign Key' },
96+ { id: ' uniqueId' , label: ' Unique ID' }
97+ ]
98+
8199const allowedFilters = subscriberFilters .map (f => f .id )
82100
83101const updateUrl = (afterId = null ) => {
@@ -92,7 +110,7 @@ const updateUrl = (afterId = null) => {
92110 }
93111
94112 if (searchQuery .value ) {
95- url .searchParams .set (' findColumn' , ' email ' )
113+ url .searchParams .set (' findColumn' , searchColumn . value )
96114 url .searchParams .set (' findValue' , searchQuery .value )
97115 } else {
98116 url .searchParams .delete (' findColumn' )
@@ -116,6 +134,10 @@ const getFilterFromUrl = () => {
116134 searchQuery .value = params .get (' findValue' )
117135 }
118136
137+ if (params .has (' findColumn' )) {
138+ searchColumn .value = params .get (' findColumn' )
139+ }
140+
119141 return foundFilter || ' all'
120142}
121143
@@ -135,7 +157,7 @@ const fetchSubscribers = async (afterId = null) => {
135157 }
136158
137159 if (searchQuery .value ) {
138- url .searchParams .set (' findColumn' , ' email ' )
160+ url .searchParams .set (' findColumn' , searchColumn . value )
139161 url .searchParams .set (' findValue' , searchQuery .value )
140162 }
141163
0 commit comments