Logout.vue 1.0 KB

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