2019-12-20 13:04:34 +01:00
|
|
|
<template>
|
2020-09-30 10:39:46 +02:00
|
|
|
<section class="section container">
|
2020-02-18 08:57:00 +01:00
|
|
|
<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>
|
2020-09-30 10:39:46 +02:00
|
|
|
<div v-else>
|
|
|
|
<h1 class="title">{{ $t("Your participation has been validated") }}</h1>
|
|
|
|
<form @submit.prevent="askToSaveParticipation">
|
|
|
|
<b-field>
|
|
|
|
<b-checkbox v-model="saveParticipation">
|
|
|
|
<b>{{ $t("Remember my participation in this browser") }}</b>
|
|
|
|
<p>
|
|
|
|
{{
|
|
|
|
$t(
|
|
|
|
"Will allow to display and manage your participation status on the event page when using this device. Uncheck if you're using a public device."
|
|
|
|
)
|
|
|
|
}}
|
|
|
|
</p>
|
|
|
|
</b-checkbox>
|
|
|
|
</b-field>
|
|
|
|
<b-button native-type="submit" type="is-primary">{{ $t("Visit event page") }}</b-button>
|
|
|
|
</form>
|
|
|
|
</div>
|
2020-02-18 08:57:00 +01:00
|
|
|
</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";
|
2020-09-29 09:53:48 +02:00
|
|
|
import { SnackbarProgrammatic as Snackbar } from "buefy";
|
2020-02-18 08:57:00 +01:00
|
|
|
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;
|
|
|
|
|
2020-09-30 10:39:46 +02:00
|
|
|
participation!: IParticipant;
|
|
|
|
|
|
|
|
saveParticipation = true;
|
|
|
|
|
2020-09-29 09:53:48 +02:00
|
|
|
async created(): Promise<void> {
|
2019-12-20 13:04:34 +01:00
|
|
|
await this.validateAction();
|
|
|
|
}
|
|
|
|
|
2020-09-29 09:53:48 +02:00
|
|
|
async validateAction(): Promise<void> {
|
2019-12-20 13:04:34 +01:00
|
|
|
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;
|
2020-09-30 10:39:46 +02:00
|
|
|
this.participation = participation;
|
2019-12-20 13:04:34 +01:00
|
|
|
}
|
|
|
|
} catch (err) {
|
|
|
|
console.error(err);
|
2020-09-29 09:53:48 +02:00
|
|
|
|
|
|
|
Snackbar.open({ message: err.message, type: "is-danger", position: "is-bottom" });
|
2019-12-20 13:04:34 +01:00
|
|
|
this.failed = true;
|
|
|
|
} finally {
|
|
|
|
this.loading = false;
|
|
|
|
}
|
|
|
|
}
|
2020-09-30 10:39:46 +02:00
|
|
|
|
|
|
|
askToSaveParticipation(): void {
|
|
|
|
if (this.saveParticipation) {
|
|
|
|
this.saveParticipationInBrowser();
|
|
|
|
}
|
|
|
|
this.forwardToEventPage();
|
|
|
|
}
|
|
|
|
|
|
|
|
async saveParticipationInBrowser(): Promise<void> {
|
|
|
|
await confirmLocalAnonymousParticipation(this.participation.event.uuid);
|
|
|
|
}
|
|
|
|
|
|
|
|
async forwardToEventPage(): Promise<void> {
|
|
|
|
await this.$router.replace({
|
|
|
|
name: RouteName.EVENT,
|
|
|
|
params: { uuid: this.participation.event.uuid },
|
|
|
|
});
|
|
|
|
}
|
2019-12-20 13:04:34 +01:00
|
|
|
}
|
|
|
|
</script>
|