1- import { useCallback , useState } from 'react'
1+ import { useCallback , useRef , useState } from 'react'
22import { createLogger } from '@/lib/logs/console/logger'
33import { useNotificationStore } from '@/stores/notifications'
44
@@ -30,10 +30,11 @@ interface UseExportServiceProps {
3030 */
3131export function useExportService ( { getWorkflowId, onSuccess } : UseExportServiceProps ) {
3232 const [ isExporting , setIsExporting ] = useState ( false )
33+ const isExportingRef = useRef ( false )
3334 const addNotification = useNotificationStore ( ( state ) => state . addNotification )
3435
3536 const handleExportService = useCallback ( async ( ) => {
36- if ( isExporting ) {
37+ if ( isExportingRef . current ) {
3738 return
3839 }
3940
@@ -43,6 +44,7 @@ export function useExportService({ getWorkflowId, onSuccess }: UseExportServiceP
4344 return
4445 }
4546
47+ isExportingRef . current = true
4648 setIsExporting ( true )
4749 try {
4850 logger . info ( 'Starting service export' , { workflowId } )
@@ -96,9 +98,10 @@ export function useExportService({ getWorkflowId, onSuccess }: UseExportServiceP
9698 logger . error ( 'Error exporting service:' , { error, workflowId } )
9799 throw error
98100 } finally {
101+ isExportingRef . current = false
99102 setIsExporting ( false )
100103 }
101- } , [ addNotification , getWorkflowId , isExporting , onSuccess ] )
104+ } , [ addNotification , getWorkflowId , onSuccess ] )
102105
103106 return {
104107 isExporting,
0 commit comments