From 0d78b873d7f503440e2388680af070fb4530f287 Mon Sep 17 00:00:00 2001
From: Hugo Trentesaux <hugo@trentesaux.fr>
Date: Wed, 15 Dec 2021 19:19:19 +0100
Subject: [PATCH] add user query

---
 pages/appolo.vue     |  5 ++--
 pages/hash/:hash.vue | 54 ++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 57 insertions(+), 2 deletions(-)
 create mode 100644 pages/hash/:hash.vue

diff --git a/pages/appolo.vue b/pages/appolo.vue
index 9534389..cd778e4 100644
--- a/pages/appolo.vue
+++ b/pages/appolo.vue
@@ -32,7 +32,7 @@
                 'table-warning' : member.status == 'MISSING',
             }">
               <th scope="row">{{ member.uid }}</th>
-              <td class="d-none d-xl-table-cell">{{ member.pubkey }}</td>
+              <td class="d-none d-xl-table-cell"><a :href="'hash/' + member.hash">{{ member.pubkey }}</a></td>
               <td class="d-none d-sm-table-cell">{{ member.status }}</td>
             </tr>
           </tbody>
@@ -63,7 +63,7 @@ export default {
       ],
       // Requête graphQL
       query: gql`{version}`,
-      param: '4Fge'
+      param: '4Fge',
     }
   },
   // Fonctions locales
@@ -78,6 +78,7 @@ export default {
             pubkey
             uid
             status
+            hash
           }
         }
       } `,
diff --git a/pages/hash/:hash.vue b/pages/hash/:hash.vue
new file mode 100644
index 0000000..7ba50ad
--- /dev/null
+++ b/pages/hash/:hash.vue
@@ -0,0 +1,54 @@
+<template>
+  <main class="content">
+    <h2 class="display-2 text-center mb-5">{{ idFromHash.uid }}</h2>
+    <div class="row">
+      <ul>
+        <li>{{ idFromHash.uid }}</li>
+        <li>{{ idFromHash.pubkey }}</li>
+        <li>{{ idFromHash.status }}</li>
+      </ul>
+    </div>
+  </main>
+</template>
+
+
+<script>
+import gql from "graphql-tag";
+
+export default {
+  data() {
+    // Variables locales
+    return {};
+  },
+  // Fonctions locales
+  methods: {},
+  apollo: {
+    idFromHash: {
+      query: gql`
+        query Search($hash: Hash!) {
+          idFromHash(hash: $hash) {
+            pubkey
+            uid
+            status
+            hash
+          }
+        }
+      `,
+      variables() {
+        return { hash: this.$route.params.hash };
+      },
+      skip() {
+        return false;
+      },
+    },
+  },
+  mounted() {
+    // Mise à jour du fil d'ariane au chargement
+    $nuxt.$emit("changeRoute", this.breadcrumb);
+  },
+};
+</script>
+
+<style lang="sass" scoped>
+// CSS Lié au composant
+</style>
\ No newline at end of file
-- 
GitLab