text: import React from 'react';
  
  import {DEFAULT_USER_AUTH} from '../Consts';
  
  const useAuthHandler = (initialState) => {
      const [auth, setAuth] = React.useState(initialState);
  
      const setAuthStatus = (userAuth) => {
          window.localStorage.setItem('user', JSON.stringify(userAuth));
          setAuth(userAuth);
      };
  
      const setUnauthStatus = () => {
          window.localStorage.clear();
          setAuth(DEFAULT_USER_AUTH);
      };
  
      return {
          auth,
          setAuthStatus,
          setUnauthStatus,
      };
  };
  
  export default useAuthHandler;
  