<template>
  <div>
    <p class="pt-3 fs-17">
      <button class="button is-primary px-2 mx-2" @click="redirect()">
        <span class="icon-text fs-18">
          <span class="material-symbols-outlined">highlight_mouse_cursor</span>
          <span class="ml-2">Click</span>
        </span>
      </button>
      để đi tới trang chủ <a class="ml-2 fsb-17" @click="redirect()">{{ company.name }}</a>
    </p>
  </div>
</template>
<script>
import Bowser from 'bowser';
export default {
  data() {
    return {
      company: this.$companyInfo(),
    };
  },
  methods: {
    async redirect() {
      let data = this.$copy(this.$store.state.login);
      const browser = Bowser.getParser(window.navigator.userAgent);
      let obj = {
        browser: browser.getBrowserName(),
        browser_version: browser.getBrowserVersion(),
        platform: browser.getPlatform().type,
        os: browser.getOSName(),
        user: data.id,
        token: this.$id(),
      };
      let ele = this.$copy(data);
      ele.token = obj.token;
      await this.$insertapi('authtoken', obj);
      this.$redirectWeb(ele);
    },
  },
};
</script>
