<script setup>
  import { onMounted } from "vue";

  onMounted(() => {
    const q = new URLSearchParams(window.location.search);
    const accessToken = q.get("accessToken");
    const refreshToken = q.get("refreshToken");
    const user = q.get("user") ? JSON.parse(decodeURIComponent(q.get("user"))) : null;
    const targetOrigin = import.meta.env.VITE_APP_BASE_URL;

    // If joinType is 'influencer', you can handle it here if needed
    if (user.JOIN === "1") {
      window.opener.postMessage(
        {
          user,
        },
        targetOrigin
      );

      window.close();
    } else if (accessToken && window.opener) {
      window.opener.postMessage(
        {
          accessToken,
          refreshToken,
          user,
        },
        targetOrigin
      );

      window.close();
    }
  });
</script>

<template>
  <div>로그인 완료, 창을 닫습니다...</div>
</template>
