hooks.ts 598 B

1234567891011121314151617
  1. import { useCallback } from 'react'
  2. import { useStore as usePluginDependenciesStore } from './store'
  3. import { useMutationCheckDependencies } from '@/service/use-plugins'
  4. export const usePluginDependencies = () => {
  5. const { mutateAsync } = useMutationCheckDependencies()
  6. const handleCheckPluginDependencies = useCallback(async (appId: string) => {
  7. const { leaked_dependencies } = await mutateAsync(appId)
  8. const { setDependencies } = usePluginDependenciesStore.getState()
  9. setDependencies(leaked_dependencies)
  10. }, [mutateAsync])
  11. return {
  12. handleCheckPluginDependencies,
  13. }
  14. }