Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 86x 86x 86x 86x 86x 86x 86x 86x 5x 5x 5x 5x 86x 86x 86x 1x 86x 86x 86x 86x 86x 86x 86x 86x 86x 86x 86x 86x 86x 86x 86x 86x 86x 86x 86x 86x 86x 86x 86x 86x 86x 86x 86x 86x 86x 86x 86x 147x 86x 86x 86x 86x 86x 86x 86x 86x 86x 86x 86x 86x 86x 86x 86x 147x 147x 147x 86x 86x 86x 86x 86x 86x 86x 86x 86x 86x 86x 86x 86x 86x 86x 86x 86x 86x 86x 86x 86x 86x 86x 86x 86x 86x 86x 86x 6x 6x 6x 6x 6x 6x 6x 6x 6x 86x 86x 86x 86x 86x 1x 1x | 'use client';
import React from 'react';
import { Button, Input } from '@/components/ui';
import { Icon } from '@/components/ui/icons';
/**
* Filter state for error dashboard
*/
export interface ErrorFilters {
category?: string;
level?: string;
search?: string;
startDate?: string;
endDate?: string;
}
export interface ErrorFilterPanelProps {
/** Current filter values */
filters: ErrorFilters;
/** Callback when filters change */
onFiltersChange: (filters: ErrorFilters) => void;
/** Available categories for dropdown */
categories: string[];
/** Available levels for dropdown */
levels: string[];
/** Loading state */
loading?: boolean;
}
/**
* ErrorFilterPanel Component
*
* Provides filtering controls for the error dashboard including
* category, level, date range, and text search.
*/
export function ErrorFilterPanel({
filters,
onFiltersChange,
categories,
levels,
loading = false,
}: ErrorFilterPanelProps) {
const handleChange = (key: keyof ErrorFilters, value: string) => {
onFiltersChange({
...filters,
[key]: value || undefined,
});
};
const handleClear = () => {
onFiltersChange({});
};
const hasFilters = Object.values(filters).some(v => v !== undefined && v !== '');
return (
<div className="bg-white dark:bg-gray-800 rounded-lg shadow p-4 mb-6">
<div className="flex flex-wrap gap-4 items-end">
{/* Search Input */}
<div className="flex-1 min-w-[200px]">
<Input
type="text"
placeholder="Search errors..."
value={filters.search || ''}
onChange={(e) => handleChange('search', e.target.value)}
leftIcon={<Icon name="search" size={18} />}
size="sm"
disabled={loading}
/>
</div>
{/* Category Filter */}
<div className="w-40">
<Input
as="select"
value={filters.category || ''}
onChange={(e) => handleChange('category', e.target.value)}
size="sm"
disabled={loading}
>
<option value="">All Categories</option>
{categories.map(cat => (
<option key={cat} value={cat}>{cat}</option>
))}
</Input>
</div>
{/* Level Filter */}
<div className="w-32">
<Input
as="select"
value={filters.level || ''}
onChange={(e) => handleChange('level', e.target.value)}
size="sm"
disabled={loading}
>
<option value="">All Levels</option>
{levels.map(level => (
<option key={level} value={level}>
{level.charAt(0).toUpperCase() + level.slice(1)}
</option>
))}
</Input>
</div>
{/* Start Date */}
<div className="w-40">
<Input
type="date"
value={filters.startDate || ''}
onChange={(e) => handleChange('startDate', e.target.value)}
size="sm"
disabled={loading}
/>
</div>
{/* End Date */}
<div className="w-40">
<Input
type="date"
value={filters.endDate || ''}
onChange={(e) => handleChange('endDate', e.target.value)}
size="sm"
disabled={loading}
/>
</div>
{/* Clear Filters */}
{hasFilters && (
<Button
variant="ghost"
size="sm"
onClick={handleClear}
disabled={loading}
>
<Icon name="x" size={16} className="mr-1" />
Clear
</Button>
)}
</div>
</div>
);
}
export default ErrorFilterPanel;
|