Merge pull request #1725 from automatisch/AUT-838

refactor: rewrite useSamlAuthProviders with RQ
This commit is contained in:
Ali BARIN
2024-03-15 15:28:01 +01:00
committed by GitHub
12 changed files with 52 additions and 48 deletions

View File

@@ -0,0 +1,18 @@
import { useQuery } from '@tanstack/react-query';
import api from 'helpers/api';
export default function useAdminSamlAuthProviders() {
const query = useQuery({
queryKey: ['adminSamlAuthProviders'],
queryFn: async ({ signal }) => {
const { data } = await api.get('/v1/admin/saml-auth-providers', {
signal,
});
return data;
},
});
return query;
}

View File

@@ -3,7 +3,7 @@ import { useMutation } from '@tanstack/react-query';
import api from 'helpers/api';
import React from 'react';
export default function useLazyApps({ appName } = {}, { onSuccess }) {
export default function useLazyApps({ appName } = {}, { onSuccess } = {}) {
const abortControllerRef = React.useRef(new AbortController());
React.useEffect(() => {

View File

@@ -1,9 +1,18 @@
import { useQuery } from '@apollo/client';
import { LIST_SAML_AUTH_PROVIDERS } from 'graphql/queries/list-saml-auth-providers.ee';
import { useQuery } from '@tanstack/react-query';
import api from 'helpers/api';
export default function useSamlAuthProviders() {
const { data, loading } = useQuery(LIST_SAML_AUTH_PROVIDERS);
return {
providers: data?.listSamlAuthProviders || [],
loading,
};
const query = useQuery({
queryKey: ['samlAuthProviders'],
queryFn: async ({ signal }) => {
const { data } = await api.get('/v1/saml-auth-providers', {
signal,
});
return data;
},
});
return query;
}