|
1 | 1 | import { api } from "@/lib/api"; |
| 2 | +import { useConsentStore } from "@/stores/consentStore"; |
2 | 3 | import { toast } from "sonner"; |
3 | 4 |
|
4 | 5 | function buildQueryParams( |
@@ -64,15 +65,23 @@ export async function fetchServers( |
64 | 65 | } |
65 | 66 | } |
66 | 67 |
|
67 | | -export async function updateServerStats(path: string, serverId: string) { |
| 68 | +export async function updateServerStats(path: string, serverId: string, clientName: string, serverName: string) { |
| 69 | + const { hasAgreedToTerms } = useConsentStore.getState(); |
| 70 | + const payload = { |
| 71 | + client_name: hasAgreedToTerms ? clientName : "", |
| 72 | + server_name: hasAgreedToTerms ? serverName : "", |
| 73 | + }; |
| 74 | + |
| 75 | + console.log("hasAgreedToTerms", hasAgreedToTerms, payload); |
| 76 | + |
68 | 77 | try { |
69 | | - const response = await api.post(`/servers/${serverId}${path}`); |
| 78 | + const response = await api.post(`/servers/${serverId}${path}`, payload); |
70 | 79 | console.log("Stats updated:", response.data); |
71 | 80 | } catch (error) { |
72 | 81 | console.error("Error updating server stats:", error); |
73 | 82 | } |
74 | 83 | } |
75 | 84 |
|
76 | | -export async function incrementDownloads(serverId: string) { |
77 | | - await updateServerStats("/download-count", serverId); |
| 85 | +export async function incrementDownloads(serverId: string, clientName: string, serverName: string) { |
| 86 | + await updateServerStats("/download-count", serverId, clientName, serverName); |
78 | 87 | } |
0 commit comments