import { setUserIdentity } from "@saasquatch/component-boilerplate";
import { useEffect } from "@saasquatch/universal-hooks";
import { h } from "@stencil/core";
import { ShareLinkView } from "./sqm-share-link-view";
import { useShareLink } from "./useShareLink";
import { createHookStory } from "../sqm-stencilbook/HookStoryAddon";
export default {
  title: "Hooks / useShareLink",
};
function setupGraphQL() {
  const id = "zach.harrison@referralsaasquatch.com";
  const accountId = id;
  const programId = "klip-referral-program";
  //@ts-ignore
  window.widgetIdent = {
    tenantAlias: "test_a74miwdpofztj",
    appDomain: "https://staging.referralsaasquatch.com",
    programId,
  };
  useEffect(() => {
    setUserIdentity({
      accountId,
      id,
      jwt: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyIjp7ImlkIjoiemFjaC5oYXJyaXNvbkByZWZlcnJhbHNhYXNxdWF0Y2guY29tIiwiYWNjb3VudElkIjoiemFjaC5oYXJyaXNvbkByZWZlcnJhbHNhYXNxdWF0Y2guY29tIn19.Wi8Vd5r64g5n8VNhiY-v5cqFcLwGxPG3Wi3dVSfkFZI",
    });
    return () => {
      window.widgetIdent = undefined;
      setUserIdentity(undefined);
    };
  }, []);
}
export const BareBonesView = createHookStory(() => {
  setupGraphQL();
  const res = useShareLink({
    programId: "klip-referral-program",
    tooltiplifespan: 0,
    tooltiptext: "",
  });
  return (h("div", null,
    "Sharelink:",
    " ",
    h("code", { style: { borderStyle: "solid", borderWidth: "1px", padding: "2px" } }, res.copyTextViewProps.copyString)));
});
export const RegularView = createHookStory(() => {
  setupGraphQL();
  return (h(ShareLinkView, Object.assign({}, useShareLink({
    programId: "klip-referral-program",
    tooltiptext: "Copied to clipboard",
    tooltiplifespan: 1000,
  }))));
});
export const FastTooltip = createHookStory(() => {
  setupGraphQL();
  return (h(ShareLinkView, Object.assign({}, useShareLink({
    programId: "klip-referral-program",
    tooltiptext: "Copied to clipboard",
    tooltiplifespan: 500,
  }))));
});
export const CustomizeUrlEnabled = createHookStory(() => {
  setupGraphQL();
  return (h(ShareLinkView, Object.assign({}, useShareLink({
    programId: "klip-referral-program",
    tooltiptext: "Copied to clipboard",
    tooltiplifespan: 1000,
    allowCustomization: true,
  }))));
});
