refactor: rewrite create-app-auth-client mutation as REST endpoint
This commit is contained in:
@@ -2,17 +2,17 @@ import { useQuery } from '@tanstack/react-query';
|
||||
|
||||
import api from 'helpers/api';
|
||||
|
||||
export default function useAdminAppAuthClient(id) {
|
||||
export default function useAdminAppAuthClient(appKey, id) {
|
||||
const query = useQuery({
|
||||
queryKey: ['admin', 'appAuthClients', id],
|
||||
queryKey: ['admin', 'apps', appKey, 'authClients', id],
|
||||
queryFn: async ({ signal }) => {
|
||||
const { data } = await api.get(`/v1/admin/app-auth-clients/${id}`, {
|
||||
const { data } = await api.get(`/v1/admin/apps/${appKey}/auth-clients/${id}`, {
|
||||
signal,
|
||||
});
|
||||
|
||||
return data;
|
||||
},
|
||||
enabled: !!id,
|
||||
enabled: !!appKey && !!id,
|
||||
});
|
||||
|
||||
return query;
|
||||
|
@@ -1,9 +1,9 @@
|
||||
import { useQuery } from '@tanstack/react-query';
|
||||
import api from 'helpers/api';
|
||||
|
||||
export default function useAdminAppAuthClient(appKey) {
|
||||
export default function useAdminAppAuthClients(appKey) {
|
||||
const query = useQuery({
|
||||
queryKey: ['admin', 'apps', appKey, 'auth-clients'],
|
||||
queryKey: ['admin', 'apps', appKey, 'authClients'],
|
||||
queryFn: async ({ signal }) => {
|
||||
const { data } = await api.get(`/v1/admin/apps/${appKey}/auth-clients`, {
|
||||
signal,
|
||||
|
21
packages/web/src/hooks/useAdminCreateAppAuthClient.ee.js
Normal file
21
packages/web/src/hooks/useAdminCreateAppAuthClient.ee.js
Normal file
@@ -0,0 +1,21 @@
|
||||
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
||||
import api from 'helpers/api';
|
||||
|
||||
export default function useAdminCreateAppAuthClient(appKey) {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
const query = useMutation({
|
||||
mutationFn: async (payload) => {
|
||||
const { data } = await api.post(`/v1/admin/apps/${appKey}/auth-clients`, payload);
|
||||
|
||||
return data;
|
||||
},
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: ['admin', 'apps', appKey, 'authClients'],
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
return query;
|
||||
}
|
Reference in New Issue
Block a user