mirror of
https://github.com/freedbygrace/ActiveDirectoryManager.git
synced 2026-08-09 02:11:57 +00:00
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:
@@ -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",
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user