// Copyright 2026 Arctel.net // SPDX-License-Identifier: Apache-2.0 "use client" import * as React from "react" import {useQuery} from "@tanstack/react-query" import {ChevronLeft, ChevronRight, History, RefreshCw, Search,} from "lucide-react" import {Button} from "@/components/ui/button" import {Input} from "@/components/ui/input" import {Badge} from "@/components/ui/badge" import {Table, TableBody, TableCell, TableHead, TableHeader, TableRow,} from "@/components/ui/table" import {Select, SelectContent, SelectItem, SelectTrigger, SelectValue,} from "@/components/ui/select" import {ErrorInline} from "@/components/layout/error" import {LoadingStateWithBorder} from "@/components/layout/loading" import {cn} from "@/lib/utils" import services from "@/lib/services" function getLevelBadgeVariant(level: string): "outline" | "secondary" | "destructive" | "default" { switch (level) { case "CRITICAL": return "destructive" case "IMPORTANT": return "default" default: return "outline" } } export function HistoriesTab() { const [historyPage, setHistoryPage] = React.useState(1) const [historySearch, setHistorySearch] = React.useState("") const [historyStatus, setHistoryStatus] = React.useState("all") const historiesQuery = useQuery({ queryKey: ["admin", "push-histories", historyPage, historySearch, historyStatus], queryFn: () => services.push.listHistories({ page: historyPage, page_size: 10, event_key: historySearch || undefined, status: historyStatus === "all" ? undefined : historyStatus, }), }) return (