2020-02-13 15:48:12 +01:00
|
|
|
<template>
|
2022-07-12 10:55:28 +02:00
|
|
|
<section class="container mx-auto">
|
2020-11-30 10:24:11 +01:00
|
|
|
<h1 class="title" v-if="loading">
|
2022-07-12 10:55:28 +02:00
|
|
|
{{ t("Your email is being changed") }}
|
2020-11-30 10:24:11 +01:00
|
|
|
</h1>
|
2020-02-13 15:48:12 +01:00
|
|
|
<div v-else>
|
|
|
|
<div v-if="failed">
|
2022-07-12 10:55:28 +02:00
|
|
|
<o-notification
|
|
|
|
:title="t('Error while changing email')"
|
|
|
|
variant="danger"
|
|
|
|
>
|
2020-02-18 08:57:00 +01:00
|
|
|
{{
|
2022-07-12 10:55:28 +02:00
|
|
|
t(
|
2020-02-18 08:57:00 +01:00
|
|
|
"Either the email has already been changed, either the validation token is incorrect."
|
|
|
|
)
|
|
|
|
}}
|
2022-07-12 10:55:28 +02:00
|
|
|
</o-notification>
|
2020-02-13 15:48:12 +01:00
|
|
|
</div>
|
2022-07-12 10:55:28 +02:00
|
|
|
<h1 class="title" v-else>{{ t("Your email has been changed") }}</h1>
|
2020-02-13 15:48:12 +01:00
|
|
|
</div>
|
|
|
|
</section>
|
|
|
|
</template>
|
|
|
|
|
2022-07-12 10:55:28 +02:00
|
|
|
<script lang="ts" setup>
|
|
|
|
import { useMutation } from "@vue/apollo-composable";
|
|
|
|
import { ref, onBeforeMount } from "vue";
|
|
|
|
import { useI18n } from "vue-i18n";
|
|
|
|
import { useRouter } from "vue-router";
|
2020-02-18 08:57:00 +01:00
|
|
|
import { VALIDATE_EMAIL } from "../../graphql/user";
|
|
|
|
import RouteName from "../../router/name";
|
2020-02-13 15:48:12 +01:00
|
|
|
|
2022-07-12 10:55:28 +02:00
|
|
|
// metaInfo() {
|
|
|
|
// return {
|
|
|
|
// title: this.t("Validating email") as string,
|
|
|
|
// };
|
|
|
|
// },
|
|
|
|
const props = defineProps<{
|
|
|
|
token: string;
|
|
|
|
}>();
|
2020-02-13 15:48:12 +01:00
|
|
|
|
2022-07-12 10:55:28 +02:00
|
|
|
const loading = ref(true);
|
|
|
|
const failed = ref(false);
|
|
|
|
const router = useRouter();
|
|
|
|
const { t } = useI18n({ useScope: "global" });
|
2020-02-18 08:57:00 +01:00
|
|
|
|
2022-07-12 10:55:28 +02:00
|
|
|
onBeforeMount(() => validateEmail({ token: props.token }));
|
2020-02-13 15:48:12 +01:00
|
|
|
|
2022-07-12 10:55:28 +02:00
|
|
|
const { mutate: validateEmail, onDone, onError } = useMutation(VALIDATE_EMAIL);
|
2020-02-13 15:48:12 +01:00
|
|
|
|
2022-07-12 10:55:28 +02:00
|
|
|
onDone(async () => {
|
|
|
|
loading.value = false;
|
|
|
|
await router.push({ name: RouteName.HOME });
|
|
|
|
});
|
|
|
|
onError((err) => {
|
|
|
|
loading.value = false;
|
|
|
|
console.error(err);
|
|
|
|
failed.value = true;
|
|
|
|
});
|
2020-02-13 15:48:12 +01:00
|
|
|
</script>
|