Merge pull request #1732 from automatisch/AUT-842

refactor: rewrite useSamlAuthProvider with RQ
This commit is contained in:
Ali BARIN
2024-03-15 13:59:22 +01:00
committed by GitHub
7 changed files with 31 additions and 59 deletions

View File

@@ -1,12 +1,22 @@
import { useQuery } from '@apollo/client';
import { GET_SAML_AUTH_PROVIDER } from 'graphql/queries/get-saml-auth-provider';
export default function useSamlAuthProvider() {
const { data, loading, refetch } = useQuery(GET_SAML_AUTH_PROVIDER, {
context: { autoSnackbar: false },
import { useQuery } from '@tanstack/react-query';
import api from 'helpers/api';
export default function useSamlAuthProvider({ samlAuthProviderId }) {
const query = useQuery({
queryKey: ['samlAuthProvider', samlAuthProviderId],
queryFn: async ({ signal }) => {
const { data } = await api.get(
`/v1/admin/saml-auth-providers/${samlAuthProviderId}`,
{
signal,
},
);
return data;
},
enabled: !!samlAuthProviderId,
});
return {
provider: data?.getSamlAuthProvider,
loading,
refetch,
};
return query;
}