import { useNetSocketStore } from "any-hooks/communication/useNetSocketStore";
import { useInjector, useRequest } from "vue-vulcan";
import { useAuthData } from "./useAuthData";

export function useLogOut() {
  const [, request] = useRequest<any>('/loginOut', { auto: false });
  const { setAuth } = useInjector(useAuthData);
  const { close } = useInjector(useNetSocketStore);

  const submitLogOut = (data: {login_id: string}) => {    
    return request(data).then( _ => {
      close();
      setAuth(null);      
    });
  }

  return { submitLogOut }
}
