2019-12-20 13:04:34 +01:00
|
|
|
<template>
|
2020-02-18 08:57:00 +01:00
|
|
|
<section class="container">
|
|
|
|
<h1 class="title" v-if="loading">{{ $t("Your participation is being validated") }}</h1>
|
|
|
|
<div v-else>
|
|
|
|
<div v-if="failed">
|
|
|
|
<b-message :title="$t('Error while validating participation')" type="is-danger">
|
|
|
|
{{
|
|
|
|
$t(
|
|
|
|
"Either the participation has already been validated, either the validation token is incorrect."
|
|
|
|
)
|
|
|
|
}}
|
|
|
|
</b-message>
|
|
|
|
</div>
|
|
|
|
<h1 class="title" v-else>{{ $t("Your participation has been validated") }}</h1>
|
|
|
|
</div>
|
|
|
|
</section>
|
2019-12-20 13:04:34 +01:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
2020-02-18 08:57:00 +01:00
|
|
|
import { Component, Prop, Vue } from "vue-property-decorator";
|
|
|
|
import RouteName from "../../router/name";
|
|
|
|
import { IParticipant } from "../../types/event.model";
|
|
|
|
import { CONFIRM_PARTICIPATION } from "../../graphql/event";
|
|
|
|
import { confirmLocalAnonymousParticipation } from "../../services/AnonymousParticipationStorage";
|
2019-12-20 13:04:34 +01:00
|
|
|
|
|
|
|
@Component
|
|
|
|
export default class ConfirmParticipation extends Vue {
|
|
|
|
@Prop({ type: String, required: true }) token!: string;
|
|
|
|
|
|
|
|
loading = true;
|
2020-02-18 08:57:00 +01:00
|
|
|
|
2019-12-20 13:04:34 +01:00
|
|
|
failed = false;
|
|
|
|
|
|
|
|
async created() {
|
|
|
|
await this.validateAction();
|
|
|
|
}
|
|
|
|
|
|
|
|
async validateAction() {
|
|
|
|
try {
|
2020-02-18 08:57:00 +01:00
|
|
|
const { data } = await this.$apollo.mutate<{
|
|
|
|
confirmParticipation: IParticipant;
|
|
|
|
}>({
|
2019-12-20 13:04:34 +01:00
|
|
|
mutation: CONFIRM_PARTICIPATION,
|
|
|
|
variables: {
|
|
|
|
token: this.token,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
if (data) {
|
|
|
|
const { confirmParticipation: participation } = data;
|
|
|
|
await confirmLocalAnonymousParticipation(participation.event.uuid);
|
2020-02-18 08:57:00 +01:00
|
|
|
await this.$router.replace({
|
|
|
|
name: RouteName.EVENT,
|
|
|
|
params: { uuid: data.confirmParticipation.event.uuid },
|
|
|
|
});
|
2019-12-20 13:04:34 +01:00
|
|
|
}
|
|
|
|
} catch (err) {
|
|
|
|
console.error(err);
|
|
|
|
this.failed = true;
|
|
|
|
} finally {
|
|
|
|
this.loading = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|