Fix error when workflows aren't enabled (#11388)
Fix Uncaught Error: Workflow is not enabled. If you want to use it, please enable it in the lab. <img width="505" alt="erroractionmenu" src="https://github.com/user-attachments/assets/66e60219-20fb-4b00-90e4-d6bd640be774" /> This error was due to using the hook `useWorkflowWithCurrentVersion` outside of a workflow object. Adding a skip parameter wasn't enough because the `useFindOneRecord` uses `useObjectMetadataItem` which throws if workflows aren't enabled.
This commit is contained in:
@ -9,7 +9,6 @@ import { isDefined } from 'twenty-shared/utils';
|
||||
|
||||
export const useWorkflowWithCurrentVersion = (
|
||||
workflowId: string | undefined,
|
||||
skip = false,
|
||||
): WorkflowWithCurrentVersion | undefined => {
|
||||
const { record: workflow } = useFindOneRecord<Workflow>({
|
||||
objectNameSingular: CoreObjectNameSingular.Workflow,
|
||||
@ -21,7 +20,7 @@ export const useWorkflowWithCurrentVersion = (
|
||||
lastPublishedVersionId: true,
|
||||
versions: true,
|
||||
},
|
||||
skip: !isDefined(workflowId) || skip,
|
||||
skip: !isDefined(workflowId),
|
||||
});
|
||||
|
||||
return useMemo(() => {
|
||||
|
||||
Reference in New Issue
Block a user