All files / apps/host/src/screens/Profile/hooks useSettingsLogout.ts

90% Statements 9/10
100% Branches 2/2
100% Functions 2/2
90% Lines 9/10

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25        3x 17x 17x 17x   17x 1x   1x 1x           17x          
import { useCallback, useState } from 'react';
 
import { useGoogleLogin } from '@/hooks/useGoogleLogin';
 
export const useSettingsLogout = () => {
  const { logout, loading } = useGoogleLogin();
  const [isLoggingOut, setIsLoggingOut] = useState(false);
  const isLogoutProcessing = loading || isLoggingOut;
 
  const handleLogout = useCallback(async () => {
    setIsLoggingOut(true);
 
    try {
      await logout();
    } catch {
      setIsLoggingOut(false);
    }
  }, [logout]);
 
  return {
    isLogoutProcessing,
    handleLogout,
  };
};