1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-01-25 00:07:47 +01:00

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.
This commit is contained in:
Nuno Góis 2023-09-06 13:35:02 +01:00 committed by GitHub
parent 34d595b5a6
commit af9756e1e1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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 = () => {