Skip to content

Commit

Permalink
fix: prevent 404 on auth settings hook (#4619)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
nunogois authored Sep 6, 2023
1 parent 34d595b commit af9756e
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -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 () => {
Expand All @@ -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 = () => {
Expand Down

0 comments on commit af9756e

Please sign in to comment.