<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;

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

      window.close();
    } else if (accessToken && window.opener) {
      window.opener.postMessage(
        {
          accessToken,
          refreshToken,
          user,
        },
        "https://shopdeli.mycafe24.com"
      );

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

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