Files
twenty/packages/twenty-front/src/modules/workflow/hooks/useDeleteWorkflowVersionStep.ts
T
Félix Malfait 464a480043 Continue ESLINT9 Migration (#13795)
Might already fix #13793
2025-08-10 23:25:58 +02:00

40 lines
1.3 KiB
TypeScript

import { useApolloCoreClient } from '@/object-metadata/hooks/useApolloCoreClient';
import { DELETE_WORKFLOW_VERSION_STEP } from '@/workflow/graphql/mutations/deleteWorkflowVersionStep';
import { useUpdateWorkflowVersionCache } from '@/workflow/workflow-steps/hooks/useUpdateWorkflowVersionCache';
import { useMutation } from '@apollo/client';
import {
type DeleteWorkflowVersionStepInput,
type DeleteWorkflowVersionStepMutation,
type DeleteWorkflowVersionStepMutationVariables,
} from '~/generated-metadata/graphql';
export const useDeleteWorkflowVersionStep = () => {
const apolloCoreClient = useApolloCoreClient();
const { updateWorkflowVersionCache } = useUpdateWorkflowVersionCache();
const [mutate] = useMutation<
DeleteWorkflowVersionStepMutation,
DeleteWorkflowVersionStepMutationVariables
>(DELETE_WORKFLOW_VERSION_STEP, {
client: apolloCoreClient,
});
const deleteWorkflowVersionStep = async (
input: DeleteWorkflowVersionStepInput,
) => {
const result = await mutate({ variables: { input } });
const workflowVersionStepChanges = result?.data?.deleteWorkflowVersionStep;
updateWorkflowVersionCache({
workflowVersionStepChanges,
workflowVersionId: input.workflowVersionId,
});
return workflowVersionStepChanges;
};
return { deleteWorkflowVersionStep };
};