refactor(editor): Migrate SignoutView.vue to composition API (#10720)

This commit is contained in:
Ricardo Espinoza 2024-09-10 10:23:57 -04:00 committed by GitHub
parent 297b668f32
commit d9473a5f9d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1,33 +1,27 @@
<script lang="ts"> <script setup lang="ts">
import { VIEWS } from '@/constants'; import { VIEWS } from '@/constants';
import { mapStores } from 'pinia';
import { useUsersStore } from '@/stores/users.store'; import { useUsersStore } from '@/stores/users.store';
import { defineComponent } from 'vue';
import { useToast } from '@/composables/useToast'; import { useToast } from '@/composables/useToast';
import { useRouter } from 'vue-router';
import { useI18n } from '@/composables/useI18n';
import { onMounted } from 'vue';
export default defineComponent({ const usersStore = useUsersStore();
name: 'SignoutView', const toast = useToast();
setup() { const router = useRouter();
return { const i18n = useI18n();
...useToast(),
}; const logout = async () => {
},
computed: {
...mapStores(useUsersStore),
},
mounted() {
void this.logout();
},
methods: {
async logout() {
try { try {
await this.usersStore.logout(); await usersStore.logout();
window.location.href = this.$router.resolve({ name: VIEWS.SIGNIN }).href; window.location.href = router.resolve({ name: VIEWS.SIGNIN }).href;
} catch (e) { } catch (e) {
this.showError(e, this.$locale.baseText('auth.signout.error')); toast.showError(e, i18n.baseText('auth.signout.error'));
} }
}, };
},
onMounted(() => {
void logout();
}); });
</script> </script>