Skip to content

Commit

Permalink
Merge branch 'ref/318/query-composables' into ref/318/query-composabl…
Browse files Browse the repository at this point in the history
…es-list-orgs
  • Loading branch information
maximilianoertel committed Sep 3, 2024
2 parents f110e2d + dad1510 commit 55ae287
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
3 changes: 1 addition & 2 deletions src/composables/queries/useDistrictsQuery.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ const useDistrictsQuery = (queryOptions = undefined) => {

return useQuery({
queryKey: [DISTRICTS_QUERY_KEY],
queryFn: () =>
orgFetcher(FIRESTORE_COLLECTIONS.DISTRICTS, undefined, isSuperAdmin, administrationOrgs, ['name', 'id', 'tags']),
queryFn: () => orgFetcher(FIRESTORE_COLLECTIONS.DISTRICTS, undefined, isSuperAdmin, administrationOrgs),
enabled: isQueryEnabled,
...queryOptions,
});
Expand Down
2 changes: 1 addition & 1 deletion src/helpers/query/orgs.js
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ export const orgFetcher = async (
selectedDistrict,
isSuperAdmin,
adminOrgs,
select = ['name', 'id', 'currentActivationCode'],
select = ['name', 'id', 'tags', 'currentActivationCode'],
) => {
if (isSuperAdmin.value) {
const axiosInstance = getAxiosInstance();
Expand Down
11 changes: 11 additions & 0 deletions src/helpers/query/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,17 @@ export const getAxiosInstance = (db = 'admin', unauthenticated = false) => {
if (unauthenticated) {
delete axiosOptions.headers;
}

// Throw error when the Axios baseUrl is not set.
// This is a temporary solution to ensure the Axios base URL is set before making requests. This is a workaround that
// is required because the initialization logic seems to contain a race condition that causes TanStack to make
// requests before the base URL is set. Throwing an error ensures that TanStack identifies the request as invalid and
// retries it after the base URL is set.
// @TODO: Remove once initialization logic issue is identified and fixed.
if (!axiosOptions.baseURL) {
throw new Error('Base URL is not set.');
}

return axios.create(axiosOptions);
};

Expand Down

0 comments on commit 55ae287

Please sign in to comment.