From dc85394096eeedf76aa4e5fa40c38eb5644b9726 Mon Sep 17 00:00:00 2001
From: paidge <paidge_cs@hotmail.com>
Date: Mon, 24 Jan 2022 16:35:10 +0100
Subject: [PATCH] Add a star to favorites UID

---
 components/certif/List.vue |   1 +
 components/member/List.vue |   1 +
 nuxt.config.js             | 171 ++++++++++++++++++-------------------
 pages/previsions/index.vue |   6 ++
 plugins/functions.js       |  13 +++
 5 files changed, 105 insertions(+), 87 deletions(-)
 create mode 100644 plugins/functions.js

diff --git a/components/certif/List.vue b/components/certif/List.vue
index b072885..16961d1 100644
--- a/components/certif/List.vue
+++ b/components/certif/List.vue
@@ -116,6 +116,7 @@
 					">
 					<th scope="row" class="py-1">
 						<div>
+							<span v-if="$isFavourite(getNeighbor(certif).uid)">★&nbsp;</span>
 							{{ getNeighbor(certif).uid }}
 							<BadgeCertifStatus
 								:limitDate="getNeighbor(certif).received_certifications.limit"
diff --git a/components/member/List.vue b/components/member/List.vue
index 3e6814d..f4aa91e 100644
--- a/components/member/List.vue
+++ b/components/member/List.vue
@@ -15,6 +15,7 @@
 					:key="member.uid"
 					@click="redirect(member.hash)">
 					<th scope="row">
+						<span v-if="$isFavourite(member.uid)">★&nbsp;</span>
 						{{ member.uid }}
 						<BadgeCertifStatus
 							:limitDate="member.received_certifications.limit"
diff --git a/nuxt.config.js b/nuxt.config.js
index 1f08452..4e615b3 100644
--- a/nuxt.config.js
+++ b/nuxt.config.js
@@ -1,102 +1,99 @@
-import i18n from './i18n'
-import webpack from 'webpack'
+import i18n from "./i18n"
+import webpack from "webpack"
 
 export default {
-  // Disable server-side rendering: https://go.nuxtjs.dev/ssr-mode
-  ssr: false,
+	// Disable server-side rendering: https://go.nuxtjs.dev/ssr-mode
+	ssr: false,
 
-  // Target: https://go.nuxtjs.dev/config-target
-  target: 'static',
+	// Target: https://go.nuxtjs.dev/config-target
+	target: "static",
 
-  // Global page headers: https://go.nuxtjs.dev/config-head
-  head: {
-    title: 'wotwizard-ui',
-    meta: [
-      { charset: 'utf-8' },
-      { name: 'viewport', content: 'width=device-width, initial-scale=1' },
-      { hid: 'description', name: 'description', content: '' },
-      { name: 'format-detection', content: 'telephone=no' }
-    ],
-    link: [
-      { rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }
-    ]
-  },
+	// Global page headers: https://go.nuxtjs.dev/config-head
+	head: {
+		title: "wotwizard-ui",
+		meta: [
+			{ charset: "utf-8" },
+			{ name: "viewport", content: "width=device-width, initial-scale=1" },
+			{ hid: "description", name: "description", content: "" },
+			{ name: "format-detection", content: "telephone=no" }
+		],
+		link: [{ rel: "icon", type: "image/x-icon", href: "/favicon.ico" }]
+	},
 
-  // Global CSS: https://go.nuxtjs.dev/config-css
-  css: [
-    '@/assets/css/style.scss'
-  ],
+	// Global CSS: https://go.nuxtjs.dev/config-css
+	css: ["@/assets/css/style.scss"],
 
-  // Plugins to run before rendering page: https://go.nuxtjs.dev/config-plugins
-  plugins: [
-    '~plugins/filters.js',
-    '~plugins/bootstrap.js'
-  ],
+	// Plugins to run before rendering page: https://go.nuxtjs.dev/config-plugins
+	plugins: [
+		"~plugins/functions.js",
+		"~plugins/filters.js",
+		"~plugins/bootstrap.js"
+	],
 
-  // Auto import components: https://go.nuxtjs.dev/config-components
-  components: true,
+	// Auto import components: https://go.nuxtjs.dev/config-components
+	components: true,
 
-  // Modules for dev and build (recommended): https://go.nuxtjs.dev/config-modules
-  buildModules: [
-    // https://go.nuxtjs.dev/pwa
-    '@nuxtjs/pwa'
-  ],
+	// Modules for dev and build (recommended): https://go.nuxtjs.dev/config-modules
+	buildModules: [
+		// https://go.nuxtjs.dev/pwa
+		"@nuxtjs/pwa"
+	],
 
-  // Modules: https://go.nuxtjs.dev/config-modules
-  modules: [
-    // https://github.com/nuxt-community/apollo-module
-    '@nuxtjs/apollo',
-    // https://i18n.nuxtjs.org
-    '@nuxtjs/i18n'
-  ],
+	// Modules: https://go.nuxtjs.dev/config-modules
+	modules: [
+		// https://github.com/nuxt-community/apollo-module
+		"@nuxtjs/apollo",
+		// https://i18n.nuxtjs.org
+		"@nuxtjs/i18n"
+	],
 
-  i18n: {
-    defaultLocale: 'fr',
-    locales: [
-      {
-        code: 'en',
-        name: 'English'
-      },
-      {
-        code: 'fr',
-        name: 'Français'
-      },
-      {
-        code: 'es',
-        name: 'Español'
-      }
-    ],
-    detectBrowserLanguage: {
-      alwaysRedirect: true
-    },
-    vueI18n: i18n
-  },
+	i18n: {
+		defaultLocale: "fr",
+		locales: [
+			{
+				code: "en",
+				name: "English"
+			},
+			{
+				code: "fr",
+				name: "Français"
+			},
+			{
+				code: "es",
+				name: "Español"
+			}
+		],
+		detectBrowserLanguage: {
+			alwaysRedirect: true
+		},
+		vueI18n: i18n
+	},
 
-  // PWA module configuration: https://go.nuxtjs.dev/pwa
-  pwa: {
-    manifest: {
-      lang: 'fr'
-    }
-  },
+	// PWA module configuration: https://go.nuxtjs.dev/pwa
+	pwa: {
+		manifest: {
+			lang: "fr"
+		}
+	},
 
-  apollo: {
-    clientConfigs: {
-      default: '~/graphql/clients/coindufeu'
-      //you can setup multiple clients with arbitrary names
-      //, myotherclient : '~/graphql/clients/otherclient'
-    },
-  },
+	apollo: {
+		clientConfigs: {
+			default: "~/graphql/clients/coindufeu"
+			//you can setup multiple clients with arbitrary names
+			//, myotherclient : '~/graphql/clients/otherclient'
+		}
+	},
 
-  router: {
-    linkExactActiveClass: 'active'
-  },
+	router: {
+		linkExactActiveClass: "active"
+	},
 
-  // Build Configuration: https://go.nuxtjs.dev/config-build
-  build: {
-    plugins: [
-      new webpack.ProvidePlugin({
-        $: "jquery"
-      })
-    ],
-  }
+	// Build Configuration: https://go.nuxtjs.dev/config-build
+	build: {
+		plugins: [
+			new webpack.ProvidePlugin({
+				$: "jquery"
+			})
+		]
+	}
 }
diff --git a/pages/previsions/index.vue b/pages/previsions/index.vue
index 1d1046e..61f362a 100644
--- a/pages/previsions/index.vue
+++ b/pages/previsions/index.vue
@@ -60,6 +60,9 @@
 												)
 											">
 											<th scope="row">
+												<span v-if="$isFavourite(forecast.member.uid)"
+													>★&nbsp;</span
+												>
 												{{ forecast.member.uid }}
 												<BadgeStatus :membre="forecast.member" />
 											</th>
@@ -114,6 +117,9 @@
 														v-for="member in forecast.forecasts"
 														:key="member.member.uid">
 														<div class="mr-3">
+															<span v-if="$isFavourite(member.member.uid)"
+																>★&nbsp;</span
+															>
 															{{ member.member.uid }}
 															<BadgeStatus :membre="member.member" />
 														</div>
diff --git a/plugins/functions.js b/plugins/functions.js
new file mode 100644
index 0000000..0c5efde
--- /dev/null
+++ b/plugins/functions.js
@@ -0,0 +1,13 @@
+export default (context, inject) => {
+	const isFavourite = (uid) => {
+		if (!localStorage.favourites) {
+			return false
+		} else if (JSON.parse(localStorage.favourites).includes(uid)) {
+			return true
+		}
+		return false
+	}
+	inject("isFavourite", isFavourite)
+	// For Nuxt <= 2.12, also add 👇
+	// context.$hello = hello
+}
-- 
GitLab