From 507c5a946d53d0fb20f680f36aed9f5317dbfa4a Mon Sep 17 00:00:00 2001
From: paidge <paidge_cs@hotmail.com>
Date: Mon, 24 Jan 2022 18:50:28 +0100
Subject: [PATCH] improve badge danger

---
 components/badge/{CertifStatus.vue => Danger.vue} | 12 +++++-------
 components/certif/List.vue                        |  4 ++--
 components/member/List.vue                        |  6 ++++--
 graphql/queries.js                                |  2 +-
 pages/membres/_hash.vue                           |  2 +-
 5 files changed, 13 insertions(+), 13 deletions(-)
 rename components/badge/{CertifStatus.vue => Danger.vue} (69%)

diff --git a/components/badge/CertifStatus.vue b/components/badge/Danger.vue
similarity index 69%
rename from components/badge/CertifStatus.vue
rename to components/badge/Danger.vue
index b079d09..786e21d 100644
--- a/components/badge/CertifStatus.vue
+++ b/components/badge/Danger.vue
@@ -2,13 +2,13 @@
 	<span
 		class="danger font-weight-normal"
 		:class="classWarning"
-		:title="textWarning"
+		:title="title"
 		v-if="
 			$options.filters.dateStatus(limitDate) != 'success' &&
 			['MEMBER', 'MISSING'].includes(memberStatus)
 		"
 		>âš 
-		<span class="sr-only">{{ textWarning }}</span>
+		<span class="sr-only" v-if="title">{{ title }}</span>
 	</span>
 </template>
 
@@ -19,6 +19,9 @@ export default {
 			type: Number,
 			default: 0
 		},
+		title: {
+			type: String
+		},
 		memberStatus: String
 	},
 	computed: {
@@ -29,11 +32,6 @@ export default {
 				"text-warning":
 					this.$options.filters.dateStatus(this.limitDate) == "warning"
 			}
-		},
-		textWarning() {
-			return this.$options.filters.dateStatus(this.limitDate) == "danger"
-				? this.$i18n.t("statut.manquecertif")
-				: this.$i18n.t("statut.bientotmanquecertif")
 		}
 	}
 }
diff --git a/components/certif/List.vue b/components/certif/List.vue
index 16961d1..0d83217 100644
--- a/components/certif/List.vue
+++ b/components/certif/List.vue
@@ -18,7 +18,7 @@
 					<th scope="row" class="py-1">
 						<div>
 							{{ getNeighbor(certif).uid }}
-							<BadgeCertifStatus
+							<BadgeDanger
 								:limitDate="getNeighbor(certif).received_certifications.limit"
 								:memberStatus="getNeighbor(certif).status" />
 							<BadgeQuality
@@ -118,7 +118,7 @@
 						<div>
 							<span v-if="$isFavourite(getNeighbor(certif).uid)">★&nbsp;</span>
 							{{ getNeighbor(certif).uid }}
-							<BadgeCertifStatus
+							<BadgeDanger
 								:limitDate="getNeighbor(certif).received_certifications.limit"
 								:memberStatus="getNeighbor(certif).status" />
 							<BadgeQuality
diff --git a/components/member/List.vue b/components/member/List.vue
index a15fd48..c6137ee 100644
--- a/components/member/List.vue
+++ b/components/member/List.vue
@@ -19,8 +19,10 @@
 					@click="redirect(member.hash)">
 					<th scope="row">
 						<span v-if="$isFavourite(member.uid)">★&nbsp;</span>{{ member.uid }}
-						<BadgeCertifStatus
-							:limitDate="member.received_certifications.limit"
+						<BadgeDanger
+							:limitDate="
+								Math.min(member.received_certifications.limit, member.limitDate)
+							"
 							:memberStatus="member.status" />
 						<BadgeStatus :membre="member" />
 					</th>
diff --git a/graphql/queries.js b/graphql/queries.js
index 308b41f..3585f5b 100644
--- a/graphql/queries.js
+++ b/graphql/queries.js
@@ -107,7 +107,6 @@ export const SEARCH_MEMBER = gql`
 			isLeaving
 			sentry
 			membership_pending
-			limitDate
 			distanceE {
 				__typename
 				value {
@@ -150,6 +149,7 @@ export const SEARCH_MEMBER = gql`
 		uid
 		hash
 		status
+		limitDate
 		minDate
 		minDatePassed
 		quality {
diff --git a/pages/membres/_hash.vue b/pages/membres/_hash.vue
index 5fed055..cab4a09 100644
--- a/pages/membres/_hash.vue
+++ b/pages/membres/_hash.vue
@@ -32,7 +32,7 @@
 									"&nbsp;+&nbsp;" + nbCertifsPending("received")
 								}}</span
 								>)
-								<BadgeCertifStatus
+								<BadgeDanger
 									:limitDate="idFromHash.received_certifications.limit"
 									:memberStatus="idFromHash.status" />
 							</h3>
-- 
GitLab