<script setup lang="ts">
import { onMounted } from 'vue'
import { useRoute } from 'vue-router'

const route = useRoute()

function setCookie(name: string, value: any, days: number) {
  let expires = ''
  if (days) {
    const date = new Date()
    date.setTime(date.getTime() + days * 24 * 60 * 55 * 1000)
    expires = '; expires=' + date.toUTCString()
  }
  document.cookie = name + '=' + (value || '') + expires + '; path=/'
}

onMounted(async () => {
  console.log('query', route.query.token)
  console.log('accessToken', route.query.accessToken)

  setCookie('BMAHRIS_KEYCLOAK_IDENTITY', route.query.token, 1)
  setCookie('BMAHRIS_KEYCLOAK_REFRESH', route.query.accessToken, 1)

  window.location.href = '/'
})
</script>

<template>
  <div></div>
</template>
