From 52675483918827b342cde8abcdeb18d1b077bb63 Mon Sep 17 00:00:00 2001 From: paidge <paidge_cs@hotmail.com> Date: Sun, 30 Jan 2022 01:19:54 +0100 Subject: [PATCH] add nbPendingCertif on CertifList + correct a duplicated computed property on membre.vue --- components/badge/Dispo.vue | 18 +++++++++++--- components/certif/List.vue | 2 ++ graphql/queries.js | 4 +++ pages/membre.vue | 50 ++++++++++++++++++-------------------- 4 files changed, 45 insertions(+), 29 deletions(-) diff --git a/components/badge/Dispo.vue b/components/badge/Dispo.vue index 82581a6..8fd52a2 100644 --- a/components/badge/Dispo.vue +++ b/components/badge/Dispo.vue @@ -9,9 +9,11 @@ {{ isDispo ? $t("membre.dispo") - : $t("membre.nodispo") + - " > " + - $d(new Date(dateDispo * 1000), "short") + : "â± " + + nbPendingCertifs + + " ( " + + $d(new Date(dateDispo * 1000), "short") + + ")" }} </span> </small> @@ -26,6 +28,16 @@ export default { }, dateDispo: { type: Number + }, + certifs: { + type: Array + } + }, + computed: { + nbPendingCertifs() { + return this.certifs.filter((el) => { + return el.pending == true + }).length } } } diff --git a/components/certif/List.vue b/components/certif/List.vue index 3d29bd8..42c01ac 100644 --- a/components/certif/List.vue +++ b/components/certif/List.vue @@ -30,6 +30,7 @@ <BadgeDispo :isDispo="certif.minDatePassed" :dateDispo="certif.minDate" + :certifs="certif.sent_certifications" v-if="certif.status == 'MEMBER'" /> </div> </th> @@ -90,6 +91,7 @@ <BadgeDispo :isDispo="certif.minDatePassed" :dateDispo="certif.minDate" + :certifs="certif.sent_certifications" v-if="certif.status == 'MEMBER'" /> </div> </th> diff --git a/graphql/queries.js b/graphql/queries.js index 41b4f1c..23b1895 100644 --- a/graphql/queries.js +++ b/graphql/queries.js @@ -164,6 +164,10 @@ export const SEARCH_MEMBER = gql` __typename limit } + sent_certifications { + __typename + pending + } } ` diff --git a/pages/membre.vue b/pages/membre.vue index 5ac2cfa..9fcab21 100644 --- a/pages/membre.vue +++ b/pages/membre.vue @@ -85,32 +85,6 @@ export default { error: null } }, - computed: { - nbCertifsSent() { - return this.idFromHash.sent_certifications.filter((el) => { - return el.pending == false - }).length - }, - nbCertifsReceived() { - return this.idFromHash.received_certifications.certifications.filter( - (el) => { - return el.pending == false - } - ).length - }, - nbCertifsPendingSent() { - return this.idFromHash.sent_certifications.filter((el) => { - return el.pending == true - }).length - }, - nbCertifsPendingReceived() { - return this.idFromHash.received_certifications.certifications.filter( - (el) => { - return el.pending == true - } - ).length - } - }, apollo: { idFromHash: { query: SEARCH_MEMBER, @@ -138,6 +112,30 @@ export default { this.idFromHash.received_certifications.limit ) == "warning" } + }, + nbCertifsSent() { + return this.idFromHash.sent_certifications.filter((el) => { + return el.pending == false + }).length + }, + nbCertifsReceived() { + return this.idFromHash.received_certifications.certifications.filter( + (el) => { + return el.pending == false + } + ).length + }, + nbCertifsPendingSent() { + return this.idFromHash.sent_certifications.filter((el) => { + return el.pending == true + }).length + }, + nbCertifsPendingReceived() { + return this.idFromHash.received_certifications.certifications.filter( + (el) => { + return el.pending == false + } + ).length } }, mounted() { -- GitLab