department-of-veterans-affairs/vets-website

View on GitHub
src/applications/virtual-agent/hooks/useChosenBot.js

Summary

Maintainability
A
0 mins
Test Coverage
import { useEffect } from 'react';

export default function useChosenBot(
  virtualAgentShowFloatingChatbot,
  setIsLoading,
  setChosenBot,
) {
  useEffect(
    () => {
      if (virtualAgentShowFloatingChatbot !== null) {
        setIsLoading(false);
        setChosenBot(virtualAgentShowFloatingChatbot ? 'default' : 'sticky');
      }
    },
    [virtualAgentShowFloatingChatbot],
  );
}