diff --git a/src/app/actions/trackingActions.ts b/src/app/actions/trackingActions.ts
index 7bf5735..e18bc2a 100644
--- a/src/app/actions/trackingActions.ts
+++ b/src/app/actions/trackingActions.ts
@@ -185,7 +185,43 @@ export async function fetchHistoryView(page: number, size: number) {
headers: {
'Content-Type': 'application/json'
}
- });
+ });
+
+ if (response.ok) {
+ const parsed = await response.json();
+
+ if (parsed.message_code === 0) {
+ return parsed.message_body;
+ } else {
+ return null;
+ }
+
+ } else {
+ throw new Error(`${response.status}`);
+ }
+ } catch (error) {
+ return null;
+ }
+}
+
+export async function fetchTrackingStats() {
+ const token = await getSessionData('token');
+
+ try {
+ const response = await fetch(`${API_BASE_URL}/api/v1/data`, {
+ method: 'POST',
+ body: JSON.stringify({
+ version: 1,
+ msg_id: 30028,
+ message_body: {
+ token: token,
+ action: 'view_stats'
+ }
+ }),
+ headers: {
+ 'Content-Type': 'application/json'
+ }
+ });
if (response.ok) {
const parsed = await response.json();
diff --git a/src/app/hooks/react-query/useTrackingStats.ts b/src/app/hooks/react-query/useTrackingStats.ts
new file mode 100644
index 0000000..e2d140a
--- /dev/null
+++ b/src/app/hooks/react-query/useTrackingStats.ts
@@ -0,0 +1,29 @@
+import { useQuery } from '@tanstack/react-query';
+import { fetchTrackingStats } from '@/app/actions/trackingActions';
+
+export interface useTrackingStats {
+ totalViews: number,
+ uniqueIps: number,
+ uniqueUsers: number,
+ documentsCount: number,
+ uniqueCountryCount: number,
+ uniqueCityCount: number,
+ firstViewDate: string,
+ lastViewDate: string
+}
+
+export const useTrackingStats = () => {
+ return useQuery({
+ queryKey: ['trackingStats'],
+ queryFn: () => {
+ return fetchTrackingStats()
+ },
+ select: (data: useTrackingStats | null) => {
+ if (!data) {
+ return null
+ }
+ return data;
+ },
+ retry: false
+ });
+};
\ No newline at end of file
diff --git a/src/app/ui/icons/icons.tsx b/src/app/ui/icons/icons.tsx
index 10f3113..22d619c 100644
--- a/src/app/ui/icons/icons.tsx
+++ b/src/app/ui/icons/icons.tsx
@@ -282,4 +282,12 @@ export function IconGlobe() {