refactor(SamlConfiguration): rewrite mutations with REST API endpoints
This commit is contained in:
21
packages/web/src/hooks/useAdminCreateSamlAuthProvider.js
Normal file
21
packages/web/src/hooks/useAdminCreateSamlAuthProvider.js
Normal file
@@ -0,0 +1,21 @@
|
||||
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
||||
import api from 'helpers/api';
|
||||
|
||||
export default function useAdminCreateSamlAuthProvider() {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
const query = useMutation({
|
||||
mutationFn: async (payload) => {
|
||||
const { data } = await api.post(`/v1/admin/saml-auth-providers`, payload);
|
||||
|
||||
return data;
|
||||
},
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: ['admin', 'samlAuthProviders'],
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
return query;
|
||||
}
|
24
packages/web/src/hooks/useAdminUpdateSamlAuthProvider.js
Normal file
24
packages/web/src/hooks/useAdminUpdateSamlAuthProvider.js
Normal file
@@ -0,0 +1,24 @@
|
||||
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
||||
import api from 'helpers/api';
|
||||
|
||||
export default function useAdminUpdateSamlAuthProvider(samlAuthProviderId) {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
const query = useMutation({
|
||||
mutationFn: async (payload) => {
|
||||
const { data } = await api.patch(
|
||||
`/v1/admin/saml-auth-providers/${samlAuthProviderId}`,
|
||||
payload,
|
||||
);
|
||||
|
||||
return data;
|
||||
},
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: ['admin', 'samlAuthProviders'],
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
return query;
|
||||
}
|
Reference in New Issue
Block a user