import { coreState } from "@corejam/core-components";
import { Component, h, Host, State } from "@stencil/core";
import gql from "graphql-tag";
import { verifyEmailGQL } from "../../../shared/graphql/Mutations";
import { STATUS } from "../../../shared/types/User";
export class VerifyComponent {
  constructor() {
    this.verifyState = false;
  }
  async componentDidLoad() {
    const params = new URLSearchParams(location.search);
    const request = await coreState.client.mutate({
      mutation: gql(verifyEmailGQL),
      variables: {
        email: params.get("email"),
        token: params.get("token"),
      },
    });
    if (request.data.userVerify.status === STATUS.VERIFIED) {
      this.verifyState = true;
    }
  }
  render() {
    return (h(Host, null,
      h("corejam-box", { flex: true }, this.verifyState ? (h("corejam-box", { mx: "auto", flex: true, my: 50 },
        h("corejam-base-link", { href: "/" },
          h("corejam-type", null, "Click here to continue")),
        h("corejam-modal", { message: "Verified", type: "success" }))) : ("waiting"))));
  }
  static get is() { return "auth-verify"; }
  static get states() { return {
    "verifyState": {}
  }; }
}
