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