From af9756e1e191647f6050730a8afe7850eb0399ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nuno=20G=C3=B3is?= Date: Wed, 6 Sep 2023 13:35:02 +0100 Subject: [PATCH] fix: prevent 404 on auth settings hook (#4619) Since `auth/{auth_type}/settings` is an Enterprise route, this prevents 404s when we try to use the hook to fetch auth settings in non-Enterprise instances by using the conditional `useEnterpriseSWR` hook. --- .../src/hooks/api/getters/useAuthSettings/useAuthSettings.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/frontend/src/hooks/api/getters/useAuthSettings/useAuthSettings.ts b/frontend/src/hooks/api/getters/useAuthSettings/useAuthSettings.ts index 685d5d0c4425..5633b810d272 100644 --- a/frontend/src/hooks/api/getters/useAuthSettings/useAuthSettings.ts +++ b/frontend/src/hooks/api/getters/useAuthSettings/useAuthSettings.ts @@ -1,7 +1,8 @@ -import useSWR, { mutate, SWRConfiguration } from 'swr'; +import { mutate, SWRConfiguration } from 'swr'; import { useState, useEffect } from 'react'; import { formatApiPath } from 'utils/formatPath'; import handleErrorResponses from '../httpErrorResponseHandler'; +import { useEnterpriseSWR } from '../useEnterpriseSWR/useEnterpriseSWR'; const useAuthSettings = (id: string, options: SWRConfiguration = {}) => { const fetcher = async () => { @@ -14,7 +15,7 @@ const useAuthSettings = (id: string, options: SWRConfiguration = {}) => { const KEY = `api/admin/auth/${id}/settings`; - const { data, error } = useSWR(KEY, fetcher, options); + const { data, error } = useEnterpriseSWR({}, KEY, fetcher, options); const [loading, setLoading] = useState(!error && !data); const refetch = () => {