@@ -7,16 +7,9 @@ import {
77 HStack ,
88 Button ,
99 Card ,
10- Combobox ,
11- Portal ,
12- Span ,
13- Spinner ,
14- useFilter ,
15- useListCollection ,
1610 IconButton ,
1711 VStack ,
1812 Tabs ,
19- Skeleton ,
2013} from '@chakra-ui/react' ;
2114import { Download , TrendingUp , AlertCircle , RefreshCw } from 'lucide-react' ;
2215import { Page } from '@/components/layout/Page' ;
@@ -29,9 +22,9 @@ import type { BucketType } from '@/types/bucket';
2922import { AvailabilityChart } from '@/components/AvailabilityChart' ;
3023import { HistoryTable } from '@/components/HistoryTable' ;
3124import { HistoryService } from '@/api/services/history.service' ;
32- import { StatusService } from '@/api/services/status.service' ;
3325import { Tooltip } from '@/components/ui/tooltip' ;
3426import { AvailabilityStats } from '@/components/AvailabilityStats' ;
27+ import { EndpointSelect } from '@/components/common/EndpointSelect' ;
3528// import { EndpointCombobox } from '@/components/common/ComboboxSelect';
3629
3730export default function History ( ) {
@@ -41,7 +34,7 @@ export default function History() {
4134 const [ selectedEndpoint , setSelectedEndpoint ] = useState < string > (
4235 searchParams . get ( 'endpoint' ) || ''
4336 ) ;
44- const [ cleared , setCleared ] = useState ( false ) ;
37+ const [ selectedEndpointName , setSelectedEndpointName ] = useState < string > ( 'Unknown Endpoint' ) ;
4538 const [ dateRange , setDateRange ] = useState < DateRange > ( ( ) => {
4639 const defaultRange = HistoryService . getDefaultDateRange ( ) ;
4740 return {
@@ -52,45 +45,6 @@ export default function History() {
5245 const [ bucket , setBucket ] = useState < BucketType > ( '15m' ) ;
5346 const [ isExporting , setIsExporting ] = useState ( false ) ;
5447
55- // Live endpoints
56- const {
57- data : liveData ,
58- isLoading : isLiveDataLoading ,
59- error : liveDataError ,
60- } = useQuery ( {
61- queryKey : [ 'live-status' ] ,
62- queryFn : ( ) => StatusService . getLiveStatus ( { pageSize : 100 } ) ,
63- staleTime : 30000 ,
64- } ) ;
65-
66- // Filtering + collection for Combobox
67- // const { contains } = useFilter({ sensitivity: 'base' });
68- // const { collection, set, filter } = useListCollection<{
69- // label: string;
70- // value: string;
71- // }>({
72- // initialItems: [],
73- // itemToString: item => item.label,
74- // itemToValue: item => item.value,
75- // filter: contains,
76- // });
77-
78- // // Update collection when liveData changes
79- // useEffect(() => {
80- // if (liveData?.items) {
81- // const items = liveData.items.map((item: any) => ({
82- // label: `${item.endpoint.name} (${item.endpoint.host})`,
83- // value: item.endpoint.id,
84- // }));
85- // set(items);
86-
87- // // fallback only if not cleared manually
88- // if (!selectedEndpoint && items.length > 0 && !cleared) {
89- // setSelectedEndpoint(items[0].value);
90- // }
91- // }
92- // }, [liveData, set, selectedEndpoint, cleared]);
93-
9448 // Track page view
9549 useEffect ( ( ) => {
9650 analytics . trackPageView ( 'History' , {
@@ -154,10 +108,6 @@ export default function History() {
154108 }
155109 } ;
156110
157- const selectedEndpointName =
158- liveData ?. items ?. find ( item => item . endpoint . id === selectedEndpoint ) ?. endpoint ?. name ||
159- 'Unknown Endpoint' ;
160-
161111 return (
162112 < Page
163113 title = 'History'
@@ -170,22 +120,14 @@ export default function History() {
170120 < Text fontSize = 'sm' fontWeight = 'medium' >
171121 Endpoint
172122 </ Text >
173- < Skeleton loading = { isLiveDataLoading } w = 'md' >
174-
175- { /* <EndpointCombobox
176- items={liveData?.items.map((item: any) => ({
177- label: `${item.endpoint.name} (${item.endpoint.host})`,
178- value: item.endpoint.id,
179- })) || [] }
180- selectedValue={selectedEndpoint ? selectedEndpoint : ''}
181- onChange={setSelectedEndpoint}
182- isLoading={false}
183- error={undefined}
184- placeholder='Select endpoint...'
185- optionName='Endpoints'
186- defaultToFirst={true}
187- /> */ }
188- </ Skeleton >
123+ < EndpointSelect
124+ selectedValue = { selectedEndpoint }
125+ onChange = { setSelectedEndpoint }
126+ setName = { setSelectedEndpointName }
127+ defaultToFirst = { true }
128+ w = { 'xs' }
129+ size = 'xs'
130+ />
189131 </ VStack >
190132 < VStack align = 'start' gap = { 1 } >
191133 < Text fontSize = 'sm' fontWeight = 'medium' >
@@ -223,7 +165,7 @@ export default function History() {
223165 size = 'xs'
224166 colorPalette = 'blue'
225167 onClick = { ( ) => void handleExportCSV ( ) }
226- loading = { isExporting || isHistoryDataLoading || isLiveDataLoading }
168+ loading = { isExporting || isHistoryDataLoading }
227169 disabled = { ! historyData }
228170 >
229171 < Download size = { 16 } />
@@ -237,7 +179,7 @@ export default function History() {
237179 < AvailabilityStats
238180 data = { historyData }
239181 bucket = { bucket }
240- isLoading = { isHistoryDataLoading || isLiveDataLoading }
182+ isLoading = { isHistoryDataLoading }
241183 />
242184 </ PageSection >
243185 < Tabs . Root
@@ -270,7 +212,7 @@ export default function History() {
270212 < AvailabilityChart
271213 data = { historyData }
272214 bucket = { bucket }
273- isLoading = { isHistoryDataLoading || isLiveDataLoading }
215+ isLoading = { isHistoryDataLoading }
274216 />
275217 </ Card . Body >
276218 </ Card . Root >
@@ -293,7 +235,7 @@ export default function History() {
293235 data = { historyData }
294236 bucket = { bucket }
295237 pageSize = { 20 }
296- isLoading = { isHistoryDataLoading || isLiveDataLoading }
238+ isLoading = { isHistoryDataLoading }
297239 />
298240 </ Card . Body >
299241 </ Card . Root >
0 commit comments