Logout.vue 1.2 KB

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