refactor: rewrite parameters of RQ hooks
This commit is contained in:
@@ -2,7 +2,7 @@ import { useQuery } from '@tanstack/react-query';
|
||||
|
||||
import api from 'helpers/api';
|
||||
|
||||
export default function useActionSubsteps(appKey, actionKey) {
|
||||
export default function useActionSubsteps({ appKey, actionKey }) {
|
||||
const query = useQuery({
|
||||
queryKey: ['actionSubsteps', appKey, actionKey],
|
||||
queryFn: async ({ signal }) => {
|
||||
|
@@ -3,11 +3,15 @@ import { useQuery } from '@tanstack/react-query';
|
||||
import api from 'helpers/api';
|
||||
|
||||
export default function useApps(variables) {
|
||||
const trueOnlyVariables = Object.fromEntries(
|
||||
Object.entries(variables).filter(([_, value]) => value === true),
|
||||
);
|
||||
|
||||
const query = useQuery({
|
||||
queryKey: ['apps', variables],
|
||||
queryKey: ['apps', trueOnlyVariables],
|
||||
queryFn: async ({ signal }) => {
|
||||
const { data } = await api.get('/v1/apps', {
|
||||
params: variables,
|
||||
params: trueOnlyVariables,
|
||||
signal,
|
||||
});
|
||||
|
||||
|
@@ -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(() => {
|
||||
@@ -15,7 +15,7 @@ export default function useLazyApps({ appName, onSuccess }) {
|
||||
}, [appName]);
|
||||
|
||||
const query = useMutation({
|
||||
mutationFn: async ({ payload }) => {
|
||||
mutationFn: async () => {
|
||||
const { data } = await api.get('/v1/apps', {
|
||||
params: { name: appName },
|
||||
signal: abortControllerRef.current.signal,
|
||||
|
@@ -2,7 +2,7 @@ import { useQuery } from '@tanstack/react-query';
|
||||
|
||||
import api from 'helpers/api';
|
||||
|
||||
export default function useTriggerSubsteps(appKey, triggerKey) {
|
||||
export default function useTriggerSubsteps({ appKey, triggerKey }) {
|
||||
const query = useQuery({
|
||||
queryKey: ['triggerSubsteps', appKey, triggerKey],
|
||||
queryFn: async ({ signal }) => {
|
||||
|
Reference in New Issue
Block a user