Improve AD site and subnet data display by adding query parameter handling and error states.

Replit-Commit-Author: Agent
Replit-Commit-Session-Id: 705f2157-ef97-4fbd-89e4-8c7f2ecaea90
Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/7ed01c5f-a82d-405a-b728-b2e3d127c60c/b062fde2-2444-45a7-806d-d418b9a80952.jpg
This commit is contained in:
alphaeusmote
2025-04-09 23:47:29 +00:00
parent eb609dc2d5
commit 7b0c00b647
2 changed files with 56 additions and 6 deletions
+22 -1
View File
@@ -29,7 +29,28 @@ export const getQueryFn: <T>(options: {
}) => QueryFunction<T> =
({ on401: unauthorizedBehavior }) =>
async ({ queryKey }) => {
const res = await fetch(queryKey[0] as string, {
let url = queryKey[0] as string;
// Handle query parameters if they exist in the second element of queryKey
if (queryKey.length > 1 && typeof queryKey[1] === 'object') {
const params = new URLSearchParams();
const queryParams = queryKey[1] as Record<string, any>;
Object.entries(queryParams).forEach(([key, value]) => {
if (value !== undefined && value !== null) {
params.append(key, value.toString());
}
});
const queryString = params.toString();
if (queryString) {
url = `${url}${url.includes('?') ? '&' : '?'}${queryString}`;
}
}
console.log('Fetching URL:', url);
const res = await fetch(url, {
credentials: "include",
});