@@ -27,7 +27,7 @@ const useChartData = () => {
2727 throw new Error ( 'No authentication token found' ) ;
2828 }
2929
30- const response = await fetch ( `${ config . baseURL } /api/relaycount ` , {
30+ const response = await fetch ( `${ config . baseURL } /api/relay/count ` , {
3131 method : 'GET' ,
3232 headers : {
3333 'Content-Type' : 'application/json' ,
@@ -71,89 +71,3 @@ const useChartData = () => {
7171} ;
7272
7373export default useChartData ;
74-
75-
76- // import { useState, useEffect } from 'react';
77- // import { useTranslation } from 'react-i18next';
78- // import { useDispatch } from 'react-redux';
79- // import config from '@app/config/config';
80- // import { readToken, deleteToken, deleteUser } from '@app/services/localStorage.service';
81- // import { setUser } from '@app/store/slices/userSlice';
82- // import { message } from 'antd';
83-
84- // interface ChartDataItem {
85- // value: number;
86- // name: string;
87- // }
88-
89- // const useChartData = () => {
90- // const [chartData, setChartData] = useState<ChartDataItem[] | null>(null);
91- // const [isLoading, setIsLoading] = useState<boolean>(true);
92- // const { t } = useTranslation();
93- // const dispatch = useDispatch();
94-
95- // const handleLogout = () => {
96- // deleteToken();
97- // deleteUser();
98- // dispatch(setUser(null));
99- // console.log('Token deleted, user logged out');
100- // message.info('You have been logged out. Please login again.');
101- // };
102-
103- // useEffect(() => {
104- // console.log('Component mounted, starting data fetch...');
105- // const fetchData = async () => {
106- // console.log('Preparing to fetch data...');
107- // setIsLoading(true);
108- // try {
109- // const token = readToken();
110- // if (!token) {
111- // throw new Error('No authentication token found');
112- // }
113- // console.log('Sending request to server...');
114- // const response = await fetch(`${config.baseURL}/api/relaycount`, {
115- // method: 'GET',
116- // headers: {
117- // 'Content-Type': 'application/json',
118- // 'Authorization': `Bearer ${token}`,
119- // },
120- // });
121- // if (!response.ok) {
122- // if (response.status === 401) {
123- // handleLogout();
124- // throw new Error('Authentication failed. You have been logged out.');
125- // }
126- // throw new Error(`Network response was not ok (status: ${response.status})`);
127- // }
128- // const data = await response.json();
129- // console.log('Response Data:', data);
130- // // Process the data into chartDataItems using translated names
131- // const newChartData: ChartDataItem[] = [
132- // { value: data.kinds, name: t('categories.kinds') },
133- // { value: data.photos, name: t('categories.photos') },
134- // { value: data.videos, name: t('categories.videos') },
135- // { value: data.audio, name: t('categories.audio') },
136- // { value: data.misc, name: t('categories.misc') },
137- // ];
138- // setChartData(newChartData);
139- // } catch (error) {
140- // console.error('Error:', error);
141- // message.error(error instanceof Error ? error.message : 'An error occurred');
142- // setChartData(null);
143- // } finally {
144- // console.log('Fetching process complete.');
145- // setIsLoading(false);
146- // }
147- // };
148-
149- // fetchData();
150-
151- // return () => {
152- // console.log('Cleanup called; Component unmounting...');
153- // };
154- // }, [t, dispatch]);
155-
156- // return { chartData, isLoading };
157- // };
158-
159- // export default useChartData;
0 commit comments