import { setUserIdentity, useQuery, useUserIdentity, } from "@saasquatch/component-boilerplate";
import { gql } from "graphql-request";
const GET_USER_DETAILS = gql `
  query getUserDetails {
    viewer {
      ... on User {
        id
        accountId
        email
      }
    }
  }
`;
export function useLogoutCurrentUser(props) {
  var _a, _b;
  const user = useUserIdentity();
  const { loading, data } = useQuery(GET_USER_DETAILS, {}, !user);
  const onSwitchClick = () => {
    setUserIdentity(undefined);
  };
  const filledInEmailText = (_a = props.userIdentificationText) === null || _a === void 0 ? void 0 : _a.replace("{email}", (_b = data === null || data === void 0 ? void 0 : data.viewer) === null || _b === void 0 ? void 0 : _b.email);
  return {
    loading,
    onSwitchClick,
    filledInEmailText,
    ...props,
  };
}
