Pārlūkot izejas kodu

plug structures pages on ap2i

Olivier Massot 3 gadi atpakaļ
vecāks
revīzija
815ed0caee
9 mainītis faili ar 52 papildinājumiem un 65 dzēšanām
  1. 2 2
      .env.ci
  2. 2 2
      .env.local
  3. 2 2
      .env.preprod
  4. 2 2
      .env.prod
  5. 10 10
      pages/structures/_id.vue
  6. 4 4
      pages/structures/index.vue
  7. 6 16
      services/data/StructuresProvider.ts
  8. 0 18
      todo.md
  9. 24 9
      types/interfaces.d.ts

+ 2 - 2
.env.ci

@@ -2,5 +2,5 @@
 NODE_ENV=production
 DEBUG=1
 
-SSR_API_BASE_URL = https://api.preprod.opentalent.fr
-CLIENT_API_BASE_URL = https://api.preprod.opentalent.fr
+SSR_API_BASE_URL=https://ap2i.preprod.opentalent.fr
+CLIENT_API_BASE_URL=https://ap2i.preprod.opentalent.fr

+ 2 - 2
.env.local

@@ -2,5 +2,5 @@
 NODE_ENV=dev
 DEBUG=1
 
-SSR_API_BASE_URL = http://nginx
-CLIENT_API_BASE_URL = https://local.api.opentalent.fr
+SSR_API_BASE_URL=http://nginx_new
+CLIENT_API_BASE_URL=https://local.ap2i.opentalent.fr

+ 2 - 2
.env.preprod

@@ -2,5 +2,5 @@
 NODE_ENV=production
 DEBUG=1
 
-SSR_API_BASE_URL = https://api.preprod.opentalent.fr
-CLIENT_API_BASE_URL = https://api.preprod.opentalent.fr
+SSR_API_BASE_URL=https://ap2i.preprod.opentalent.fr
+CLIENT_API_BASE_URL=https://ap2i.preprod.opentalent.fr

+ 2 - 2
.env.prod

@@ -3,5 +3,5 @@
 NODE_ENV=production
 DEBUG=0
 
-SSR_API_BASE_URL = https://api.opentalent.fr
-CLIENT_API_BASE_URL = https://api.opentalent.fr
+SSR_API_BASE_URL=https://ap2i.opentalent.fr
+CLIENT_API_BASE_URL=https://ap2i.opentalent.fr

+ 10 - 10
pages/structures/_id.vue

@@ -152,9 +152,9 @@
                 <font-awesome-icon class="icon" :icon="['fas', 'phone-alt']" />
               </td>
               <td class="phone">
-                <div v-if="structure.telphone || structure.mobilPhone">
-                  <a v-if="showTel" :href="'tel:' + (structure.telphone || structure.mobilPhone)" class="neutral">
-                    {{ formatPhoneNumber(structure.telphone || structure.mobilPhone) }}
+                <div v-if="structure.phone || structure.mobilePhone">
+                  <a v-if="showTel" :href="'tel:' + (structure.phone || structure.mobilePhone)" class="neutral">
+                    {{ formatPhoneNumber(structure.phone || structure.mobilePhone) }}
                   </a>
                   <v-btn v-else small @click="showTel = 1">
                     {{ $t('show_tel') }}
@@ -193,15 +193,15 @@
               </td>
               <td class="network">
                 <NuxtLink
-                  v-if="parent && (structure.n1Id !== parent)"
+                  v-if="parent && (structure.parentId !== parent)"
                   class="neutral"
-                  :to="{path: '/structures/' + structure.n1Id, query: { parent: parent, view: view, theme: theme }}"
+                  :to="{path: '/structures/' + structure.parentId, query: { parent: parent, view: view, theme: theme }}"
                   nuxt
                 >
-                  {{ structure.n1Name }}
+                  {{ structure.parentName }}
                 </NuxtLink>
                 <div v-else>
-                  {{ structure.n1Name }}
+                  {{ structure.partName }}
                 </div>
               </td>
             </tr>
@@ -209,14 +209,14 @@
         </v-col>
       </v-row>
 
-      <v-row v-if="structure.latitude && structure.longitude">
+      <v-row v-if="structure.mapAddress.latitude && structure.mapAddress.longitude">
         <v-col cols="12">
           <v-responsive width="100%" height="450px">
             <no-ssr>
               <l-map
                 id="map"
                 :zoom="13"
-                :center="[structure.latitude, structure.longitude]"
+                :center="[structure.mapAddress.latitude, structure.mapAddress.longitude]"
                 :options="{ scrollWheelZoom: false, zoomSnap: 0.25 }"
               >
                 <l-tile-layer
@@ -225,7 +225,7 @@
                 />
                 <l-marker
                   :key="structure.id"
-                  :lat-lng="[structure.latitude, structure.longitude]"
+                  :lat-lng="[structure.mapAddress.latitude, structure.mapAddress.longitude]"
                 >
                   <l-popup>
                     <b>{{ structure.name }}</b><br>

+ 4 - 4
pages/structures/index.vue

@@ -237,15 +237,15 @@
                             </td>
                             <td>
                               <NuxtLink
-                                v-if="structure.n1Id !== parent"
+                                v-if="structure.parentId !== parent"
                                 class="neutral"
-                                :to="{path: '/structures/' + structure.n1Id, query: { parent: parent, view: view, theme: theme }}"
+                                :to="{path: '/structures/' + structure.parentId, query: { parent: parent, view: view, theme: theme }}"
                                 nuxt
                               >
-                                {{ structure.n1Name }}
+                                {{ structure.parentName }}
                               </NuxtLink>
                               <div v-else>
-                                {{ structure.n1Name }}
+                                {{ structure.parentName }}
                               </div>
                             </td>
                           </tr>

+ 6 - 16
services/data/StructuresProvider.ts

@@ -2,14 +2,6 @@ import BaseProvider from '~/services/data/BaseProvider'
 
 class StructuresProvider extends BaseProvider {
   protected normalize (s: any) : Structure {
-    s.n1Id = s.n1Id ? parseInt(s.n1Id) : null
-    s.n2Id = s.n2Id ? parseInt(s.n2Id) : null
-    s.n3Id = s.n3Id ? parseInt(s.n3Id) : null
-    s.n4Id = s.n4Id ? parseInt(s.n4Id) : null
-    s.n5Id = s.n5Id ? parseInt(s.n5Id) : null
-    s.practices = s.practices ? s.practices.split(',') : []
-    s.addresses = ((s.addresses && s.addresses !== '{}') ? JSON.parse('[' + s.addresses + ']') : []) as Array<Address>
-
     // Define the on-map address according to the chosen priorities
     s.mapAddress = s.addresses.find((a: Address) => { return a.type === 'ADDRESS_PRACTICE' }) ||
                    s.addresses.find((a: Address) => { return a.type === 'ADDRESS_HEAD_OFFICE' }) ||
@@ -20,25 +12,23 @@ class StructuresProvider extends BaseProvider {
                       s.addresses.find((a: Address) => { return a.type === 'ADDRESS_HEAD_OFFICE' }) ||
                       null
 
-    s.latitude = s.latitude ? parseFloat(s.latitude) : null
-    s.longitude = s.longitude ? parseFloat(s.longitude) : null
-    s.parents = s.parents ? s.parents.split(',').map((i: string) => Number(i)) : []
-    s.articles = (s.articles && s.articles !== '{}') ? JSON.parse('[' + s.articles + ']').reverse() : []
-    s.articles.sort((a: Article, b: Article) => { return a.date > b.date ? -1 : 1 })
+    if (s.hasOwnProperty('articles') && s.articles) {
+      s.articles.sort((a: Article, b: Article) => { return a.date > b.date ? -1 : 1 })
+    }
     return s
   }
 
   async getAll (parentId: number): Promise<Array<Structure>> {
     return await this.get(
-      `/api/public/federation_structures/all?parent-id=${parentId}`
+      `/api/public/federation_structures?parents=${parentId}`
     ).then((res) => {
-      return res.map((s: any) => { return this.normalize(s) })
+      return res["hydra:member"].map((s: any) => { return this.normalize(s) })
     })
   }
 
   async getById (organizationId: number): Promise<Structure> {
     return await this.get(
-      `/api/public/federation_structures/get?organization-id=${organizationId}`
+      `/api/public/federation_structures/${organizationId}`
     ).then((s) => {
       return this.normalize(s)
     })

+ 0 - 18
todo.md

@@ -1,18 +0,0 @@
-## fixes
-
-## en plus
-
-? (PO nécesaire) ajouter un bouton sur la page détails des fédés: 'voir tous les adhérents'
-* remplacer la liste déroulante 'Distance' par un slider
-* documenter
-* faire un script pour identifier les geoloc foireuses, en utilisant l'api adresse, et en listant les structures dont la loc enregistrée est à plus de 5km de l'adresse
-
-## cypress
-
-* adapter aux nouveaux paramètres de requête attendus
-* améliorer les perfs, peut-être en faisant un yarn build lors de la phase d'install
-* tester la carte leaflet en:
-  * vérifiant que des coordonnées sont visibles
-  * permettant de zoomer sur un emplacement
-* fournir une base de fixtures permettant de tester plus précisément les choses
-* intercepter la requête à api.gouv.fr

+ 24 - 9
types/interfaces.d.ts

@@ -24,25 +24,21 @@ interface Structure {
   readonly id: number,
   name: string,
   logoId: string | null,
-  principalType: string | null,
+  type: string | null,
   website: string | null,
   mapAddress: Address | null,
   postalAddress: Address | null,
   addresses: Array<Address>,
-  telphone: string | null,
-  mobilPhone: string | null,
+  phone: string | null,
+  mobilePhone: string | null,
   email: string | null,
   facebook: string | null,
   twitter: string | null,
   instagram: string | null,
   youtube: string | null,
   practices: Array<string>,
-  n1Id: number | null,
-  n1Name: string | null,
-  n2Id: number | null,
-  n3Id: number | null,
-  n4Id: number | null,
-  n5Id: number | null,
+  parentId: number | null,
+  parentName: string | null,
   parents: Array<number>,
   description: string | null,
   imageId: string | null,
@@ -62,3 +58,22 @@ interface UiSearchAddressItem {
   value: Coordinates,
   disabled?: boolean
 }
+
+interface PublicEvent {
+  uuid: string,
+  organizationId: number,
+  name: string,
+  description: string,
+  url: string,
+  datetimeStart: Date,
+  datetimeEnd: Date,
+  address: Address | null,
+  roomName: string,
+  roomDescription: string,
+  roomCapacity: string,
+  roomFloorSize: string,
+  imageId: number,
+  categories: Array<string>,
+  origin: string,
+  entityId: number
+}