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 | 1x 1x 1x 62x 62x 3x 1x 2x 3x 3x 62x 62x 62x 62x 434x 434x 434x 434x 434x 434x 434x 434x 62x 62x 62x 62x 62x 62x 62x 62x 62x 62x 62x 96x 96x 96x 62x 62x 62x 62x 62x 62x 62x 62x 62x 62x 62x 62x 62x 62x 62x 62x 62x 62x 62x 62x 62x 62x | import type { TaskFilters as Filters, TaskStatus } from "../api/types";
import { TASK_STATUSES } from "../api/types";
import { taskStatusLabel } from "../lib/status";
export interface TaskFiltersProps {
value: Filters;
types: string[];
onChange: (next: Filters) => void;
}
export function TaskFilters({ value, types, onChange }: TaskFiltersProps) {
const selected = value.statuses ?? [];
function toggleStatus(status: TaskStatus) {
const next = selected.includes(status)
? selected.filter((item) => item !== status)
: [...selected, status];
onChange({ ...value, statuses: next });
}
return (
<div className="filters">
<div className="filters__row" role="group" aria-label="Статусы">
{TASK_STATUSES.map((status) => (
<button
key={status}
type="button"
className={selected.includes(status) ? "chip chip--active" : "chip"}
aria-pressed={selected.includes(status)}
onClick={() => toggleStatus(status)}
>
{taskStatusLabel(status)}
</button>
))}
</div>
<div className="filters__row">
<label className="field">
<span>Тип</span>
<select
aria-label="Тип задачи"
value={value.type ?? ""}
onChange={(event) => onChange({ ...value, type: event.target.value || undefined })}
>
<option value="">Все типы</option>
{types.map((type) => (
<option key={type} value={type}>
{type}
</option>
))}
</select>
</label>
<label className="field field--wide">
<span>Поиск</span>
<input
type="search"
aria-label="Поиск по задачам"
placeholder="ID, тип, робот, ошибка"
value={value.query ?? ""}
onChange={(event) => onChange({ ...value, query: event.target.value })}
/>
</label>
<button
type="button"
className="button button--ghost"
onClick={() => onChange({ statuses: [], type: undefined, robotId: undefined, query: "" })}
>
Сбросить
</button>
</div>
</div>
);
}
|