Logout.vue 983 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <template>
  2. <div class="flex">
  3. <SmartItem
  4. svg="log-out"
  5. :label="$t('auth.logout')"
  6. @click.native="
  7. $emit('confirm-logout')
  8. confirmLogout = true
  9. "
  10. />
  11. <SmartConfirmModal
  12. :show="confirmLogout"
  13. :title="$t('confirm.logout')"
  14. @hide-modal="confirmLogout = false"
  15. @resolve="logout"
  16. />
  17. </div>
  18. </template>
  19. <script lang="ts">
  20. import { defineComponent } from "@nuxtjs/composition-api"
  21. import { signOutUser } from "~/helpers/fb/auth"
  22. export default defineComponent({
  23. data() {
  24. return {
  25. confirmLogout: false,
  26. }
  27. },
  28. methods: {
  29. async logout() {
  30. try {
  31. await signOutUser()
  32. this.$toast.success(this.$t("auth.logged_out").toString(), {
  33. icon: "vpn_key",
  34. })
  35. } catch (e) {
  36. console.error(e)
  37. this.$toast.error(this.$t("error.something_went_wrong").toString(), {
  38. icon: "error_outline",
  39. })
  40. }
  41. },
  42. },
  43. })
  44. </script>