@@ -8,7 +8,7 @@ import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigge
88import useDirDetection from '@/hooks/use-dir-detection'
99import { cn } from '@/lib/utils'
1010import { debounce } from 'es-toolkit'
11- import { RefreshCw , SearchIcon , Filter , X , ArrowUpDown , User , Calendar , ChartPie , ChevronDown , Check } from 'lucide-react'
11+ import { RefreshCw , SearchIcon , Filter , X , ArrowUpDown , User , Calendar , ChartPie , ChevronDown , Check , Clock } from 'lucide-react'
1212import { useState , useRef , useEffect , useCallback } from 'react'
1313import { useTranslation } from 'react-i18next'
1414import { useGetUsers , UserStatus } from '@/service/api'
@@ -24,26 +24,35 @@ const sortSections = [
2424 icon : User ,
2525 label : 'username' ,
2626 items : [
27- { value : 'username' , label : 'sort.username.asc' } ,
2827 { value : '-username' , label : 'sort.username.desc' } ,
28+ { value : 'username' , label : 'sort.username.asc' } ,
2929 ] ,
3030 } ,
3131 {
3232 key : 'expire' ,
3333 icon : Calendar ,
3434 label : 'expireDate' ,
3535 items : [
36- { value : 'expire' , label : 'sort.expire.oldest' } ,
3736 { value : '-expire' , label : 'sort.expire.newest' } ,
37+ { value : 'expire' , label : 'sort.expire.oldest' } ,
3838 ] ,
3939 } ,
4040 {
4141 key : 'usage' ,
4242 icon : ChartPie ,
4343 label : 'dataUsage' ,
4444 items : [
45- { value : 'used_traffic' , label : 'sort.usage.low' } ,
4645 { value : '-used_traffic' , label : 'sort.usage.high' } ,
46+ { value : 'used_traffic' , label : 'sort.usage.low' } ,
47+ ] ,
48+ } ,
49+ {
50+ key : 'onlineAt' ,
51+ icon : Clock ,
52+ label : 'lastOnline' ,
53+ items : [
54+ { value : '-online_at' , label : 'sort.online.newest' } ,
55+ { value : 'online_at' , label : 'sort.online.oldest' } ,
4756 ] ,
4857 } ,
4958] as const
@@ -242,25 +251,24 @@ export const Filters = ({ filters, onFilterChange, refetch, advanceSearchOnOpen,
242251 { filters . sort && filters . sort !== '-created_at' && < div className = "absolute -right-1 -top-1 h-2 w-2 rounded-full bg-primary" /> }
243252 </ Button >
244253 </ DropdownMenuTrigger >
245- < DropdownMenuContent align = "end" className = "w-52 md:w-56 " >
254+ < DropdownMenuContent align = "end" className = "w-44 " >
246255 { sortSections . map ( ( section , sectionIndex ) => (
247256 < div key = { section . key } >
248257 { /* Section Label */ }
249- < DropdownMenuLabel className = "flex items-center gap-1.5 px-2 py-1.5 text-xs text-muted-foreground md:gap-2 md:px-3 md:py-2 " >
250- < section . icon className = "h-3 w-3 " />
251- < span className = "text-xs md:text-sm " > { t ( section . label ) } </ span >
258+ < DropdownMenuLabel className = "flex items-center gap-1 px-1.5 py-1 text-[10px] text-muted-foreground" >
259+ < section . icon className = "h-2.5 w-2.5 " />
260+ < span className = "text-[10px] " > { t ( section . label ) } </ span >
252261 </ DropdownMenuLabel >
253262
254263 { /* Section Items */ }
255264 { section . items . map ( item => (
256265 < DropdownMenuItem
257266 key = { item . value }
258267 onClick = { ( ) => handleSort && handleSort ( item . value , true ) }
259- className = { `whitespace-nowrap px-2 py-1.5 text-xs md:px-3 md:py-2 ${ filters . sort === item . value ? 'bg-accent' : '' } ` }
268+ className = { `whitespace-nowrap px-1.5 py-1 text-[11px] ${ filters . sort === item . value ? 'bg-accent' : '' } ` }
260269 >
261- < section . icon className = "mr-1.5 h-3 w-3 flex-shrink-0 md:mr-2 md:h-4 md:w-4" />
262270 < span className = "truncate" > { t ( item . label ) } </ span >
263- { filters . sort === item . value && < ChevronDown className = { `ml-auto h-3 w-3 flex-shrink-0 md:h-4 md:w-4 ${ item . value . startsWith ( '-' ) ? '' : 'rotate-180' } ` } /> }
271+ { filters . sort === item . value && < ChevronDown className = { `ml-auto h-2.5 w-2.5 flex-shrink-0 ${ item . value . startsWith ( '-' ) ? '' : 'rotate-180' } ` } /> }
264272 </ DropdownMenuItem >
265273 ) ) }
266274
@@ -298,20 +306,20 @@ export const Filters = ({ filters, onFilterChange, refetch, advanceSearchOnOpen,
298306 < ChevronDown className = "h-3 w-3" />
299307 </ Button >
300308 </ DropdownMenuTrigger >
301- < DropdownMenuContent align = "end" className = "w-52 md:w-56 " >
302- < DropdownMenuLabel className = "flex flex-col gap-0.5 px-2 py-1.5 text-xs text-muted-foreground md:px-3 md:py-2 " >
309+ < DropdownMenuContent align = "end" className = "w-44 " >
310+ < DropdownMenuLabel className = "flex flex-col gap-0.5 px-1.5 py-1 text-[10px] text-muted-foreground" >
303311 < span > { t ( 'autoRefresh.label' ) } </ span >
304- < span className = "text-[11px] md:text-xs " > { t ( 'autoRefresh.currentSelection' , { value : currentAutoRefreshDescription } ) } </ span >
312+ < span className = "text-[9px] " > { t ( 'autoRefresh.currentSelection' , { value : currentAutoRefreshDescription } ) } </ span >
305313 </ DropdownMenuLabel >
306314 < DropdownMenuSeparator />
307315 < DropdownMenuItem
308316 onSelect = { ( ) => void handleRefreshClick ( ) }
309317 disabled = { isRefreshing }
310- className = "flex items-center gap-2 px-2 py-1.5 text-xs md:px-3 md:py-2 "
318+ className = "flex items-center gap-1.5 px-1.5 py-1 text-[11px] "
311319 >
312- < RefreshCw className = { cn ( 'h-3 .5 w-3 .5 flex-shrink-0' , isRefreshing && 'animate-spin' ) } />
320+ < RefreshCw className = { cn ( 'h-2 .5 w-2 .5 flex-shrink-0' , isRefreshing && 'animate-spin' ) } />
313321 < span className = "truncate" > { t ( 'autoRefresh.refreshNow' ) } </ span >
314- { isRefreshing && < LoaderCircle className = "ml-auto h-3 .5 w-3 .5 animate-spin" /> }
322+ { isRefreshing && < LoaderCircle className = "ml-auto h-2 .5 w-2 .5 animate-spin" /> }
315323 </ DropdownMenuItem >
316324 < DropdownMenuSeparator />
317325 { autoRefreshOptions . map ( option => {
@@ -320,10 +328,10 @@ export const Filters = ({ filters, onFilterChange, refetch, advanceSearchOnOpen,
320328 < DropdownMenuItem
321329 key = { option . value }
322330 onSelect = { ( ) => handleAutoRefreshChange ( option . value ) }
323- className = { cn ( 'flex items-center gap-2 whitespace-nowrap px-2 py-1.5 text-xs md:px-3 md:py-2 ' , isActive && 'bg-accent' ) }
331+ className = { cn ( 'flex items-center gap-1.5 whitespace-nowrap px-1.5 py-1 text-[11px] ' , isActive && 'bg-accent' ) }
324332 >
325333 < span > { t ( option . labelKey ) } </ span >
326- { isActive && < Check className = "ml-auto h-3 w-3 flex-shrink-0" /> }
334+ { isActive && < Check className = "ml-auto h-2.5 w-2.5 flex-shrink-0" /> }
327335 </ DropdownMenuItem >
328336 )
329337 } ) }
0 commit comments