refactor: rewrite useSamlAuthProviders with RQ

This commit is contained in:
Rıdvan Akca
2024-03-14 15:13:17 +03:00
parent 3aa86eebf2
commit ab49535b6c
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;
}