Skip to content
Snippets Groups Projects
futures_sorties.vue 2.47 KiB
Newer Older
<template>
	<main class="container">
Pierre-Jean CHANCELLIER's avatar
Pierre-Jean CHANCELLIER committed
		<h2 class="text-center my-5 font-weight-light">{{ $t("futureexits") }}</h2>
		<div class="form-check form-switch mb-4 d-flex justify-content-center">
			<input
				type="checkbox"
				id="favoris"
				class="form-check-input me-2"
				role="switch"
				v-model="favoris"
				@change="save()" />
			<label for="favoris" class="form-check-label">{{
				$t("favoris.use")
			}}</label>
Benoît Besnard's avatar
Benoît Besnard committed
		</div>
		<NavigationLoader :isLoading="$apollo.loading" />
		<transition name="fade">
			<Alerte type="danger" :error="error" />
		</transition>
		<transition name="fade">
			<div class="row" v-if="!$apollo.loading">
Pierre-Jean CHANCELLIER's avatar
Pierre-Jean CHANCELLIER committed
				<div class="col-lg-6 mb-5" v-if="memEnds">
					<h2 class="h4 text-danger text-center">
						{{ $t("statut.renew") }}
					</h2>
					<MemberList
Pierre-Jean CHANCELLIER's avatar
Pierre-Jean CHANCELLIER committed
						defaultSort="date_membership"
						:members="memEnds"
						type="adhesion" />
				</div>
Pierre-Jean CHANCELLIER's avatar
Pierre-Jean CHANCELLIER committed
				<div class="col-lg-6 mb-5" v-if="certEnds">
					<h2 class="h4 text-danger text-center">
						{{ $t("statut.bientotmanquecertif") }}
					</h2>
					<MemberList
Pierre-Jean CHANCELLIER's avatar
Pierre-Jean CHANCELLIER committed
						defaultSort="date_certs"
						:members="certEnds"
						type="certif" />
				</div>
			</div>
		</transition>
	</main>
</template>

<script>
import { NEXT_EXITS } from "@/graphql/queries.js"
import { NEXT_LOOSE_CERTS } from "@/graphql/queries.js"
	data() {
Benoît Besnard's avatar
Benoît Besnard committed
		return {
			breadcrumb: [
				{
					text: this.$t("accueil"),
					to: "/"
					text: this.$t("previsions.title"),
					to: "/previsions"
					text: this.$t("futureexits"),
Benoît Besnard's avatar
Benoît Besnard committed
					active: true
				}
			],
			error: null,
			favoris: false,
			period: 1317600
		getParams() {
			if (this.favoris) {
				return localStorage.favourites
					? { group: this.$favourites.list, period: this.period }
					: { group: "wotwizard-nobody", period: this.period }
			return { period: this.period }
Benoît Besnard's avatar
Benoît Besnard committed
	},
Pierre-Jean CHANCELLIER's avatar
Pierre-Jean CHANCELLIER committed
	methods: {
		save() {
			localStorage.exitsFiltered = this.favoris
		}
	},
Benoît Besnard's avatar
Benoît Besnard committed
	apollo: {
Benoît Besnard's avatar
Benoît Besnard committed
			query: NEXT_EXITS,
				return this.getParams
			},
			error(err) {
				this.error = err.message
			}
		},
		certEnds: {
			query: NEXT_LOOSE_CERTS,
			variables() {
				return this.getParams
			error(err) {
				this.error = err.message
			}
Benoît Besnard's avatar
Benoît Besnard committed
		}
	},
	nuxtI18n: {
		paths: {
			fr: "/previsions/futures_sorties",
			en: "/forecasts/future_exits",
			es: "/pronosticos/futuras_salidas"
	mounted() {
		$nuxt.$emit("changeRoute", this.breadcrumb)
Pierre-Jean CHANCELLIER's avatar
Pierre-Jean CHANCELLIER committed
		this.favoris = localStorage.exitsFiltered == "true"