✨ refactor(ui): Improve usage log filter responsiveness and mobile UX
Refactor the usage log filter toolbar into a shared reusable component for common, drawing, and task logs. Optimize desktop filters with a responsive grid, move secondary filters into a mobile drawer, standardize filter typography, remove redundant filter icons, and add the missing i18n translations for the new drawer description.
This commit is contained in:
@@ -37,7 +37,11 @@ import { useIsAdmin } from '@/hooks/use-admin'
|
||||
import { useTableUrlState } from '@/hooks/use-table-url-state'
|
||||
import { TableCell, TableRow } from '@/components/ui/table'
|
||||
import { DataTablePage } from '@/components/data-table'
|
||||
import { DEFAULT_LOGS_DATA, LOG_TYPE_ENUM } from '../constants'
|
||||
import {
|
||||
DEFAULT_LOGS_DATA,
|
||||
LOG_TYPE_ALL_VALUE,
|
||||
LOG_TYPE_ENUM,
|
||||
} from '../constants'
|
||||
import { useColumnsByCategory } from '../lib/columns'
|
||||
import { fetchLogsByCategory } from '../lib/utils'
|
||||
import type { LogCategory } from '../types'
|
||||
@@ -51,6 +55,11 @@ const logTypeRowTint: Record<number, string> = {
|
||||
[LOG_TYPE_ENUM.REFUND]: 'bg-blue-50/30 dark:bg-blue-950/15',
|
||||
}
|
||||
|
||||
function deserializeLogTypeFilter(value: unknown): unknown[] {
|
||||
const values = Array.isArray(value) ? value : value ? [value] : []
|
||||
return values.filter((item) => String(item) !== LOG_TYPE_ALL_VALUE)
|
||||
}
|
||||
|
||||
interface UsageLogsTableProps {
|
||||
logCategory: LogCategory
|
||||
}
|
||||
@@ -73,7 +82,12 @@ export function UsageLogsTable({ logCategory }: UsageLogsTableProps) {
|
||||
pagination: { defaultPage: 1, defaultPageSize: isMobile ? 20 : 100 },
|
||||
globalFilter: { enabled: false },
|
||||
columnFilters: [
|
||||
{ columnId: 'created_at', searchKey: 'type', type: 'array' as const },
|
||||
{
|
||||
columnId: 'created_at',
|
||||
searchKey: 'type',
|
||||
type: 'array' as const,
|
||||
deserialize: deserializeLogTypeFilter,
|
||||
},
|
||||
{ columnId: 'model_name', searchKey: 'model', type: 'string' as const },
|
||||
{ columnId: 'token_name', searchKey: 'token', type: 'string' as const },
|
||||
{ columnId: 'group', searchKey: 'group', type: 'string' as const },
|
||||
|
||||
Reference in New Issue
Block a user