From 80bfd3db0182b48b5c632aaf233f492f491cdf13 Mon Sep 17 00:00:00 2001
From: Thomas Citharel <tcit@tcit.fr>
Date: Mon, 1 Mar 2021 18:29:48 +0100
Subject: [PATCH] Fix terms with no settings

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
---
 js/src/components/Error.vue          | 4 ----
 js/src/i18n/en_US.json               | 3 ++-
 js/src/i18n/fr_FR.json               | 3 ++-
 js/src/views/About/AboutInstance.vue | 6 +++++-
 js/src/views/About/Privacy.vue       | 8 ++++----
 js/src/views/About/Terms.vue         | 8 ++++----
 6 files changed, 17 insertions(+), 15 deletions(-)

diff --git a/js/src/components/Error.vue b/js/src/components/Error.vue
index 3a0375860..30585a8aa 100644
--- a/js/src/components/Error.vue
+++ b/js/src/components/Error.vue
@@ -115,7 +115,6 @@
 <script lang="ts">
 import { CONTACT } from "@/graphql/config";
 import { Component, Prop, Vue } from "vue-property-decorator";
-import InstanceContactLink from "@/components/About/InstanceContactLink.vue";
 
 @Component({
   apollo: {
@@ -131,9 +130,6 @@ import InstanceContactLink from "@/components/About/InstanceContactLink.vue";
       titleTemplate: "%s | Mobilizon",
     };
   },
-  components: {
-    InstanceContactLink,
-  },
 })
 export default class ErrorComponent extends Vue {
   @Prop({ required: true, type: Error }) error!: Error;
diff --git a/js/src/i18n/en_US.json b/js/src/i18n/en_US.json
index 03d95ce82..6b7e5323a 100644
--- a/js/src/i18n/en_US.json
+++ b/js/src/i18n/en_US.json
@@ -955,5 +955,6 @@
   "The group's physical address was changed.": "The group's physical address was changed.",
   "The group's avatar was changed.": "The group's avatar was changed.",
   "The group's banner was changed.": "The group's banner was changed.",
-  "The group's short description was changed.": "The group's short description was changed."
+  "The group's short description was changed.": "The group's short description was changed.",
+  "No information": "No information"
 }
diff --git a/js/src/i18n/fr_FR.json b/js/src/i18n/fr_FR.json
index f6a75232a..ca59e76f1 100644
--- a/js/src/i18n/fr_FR.json
+++ b/js/src/i18n/fr_FR.json
@@ -1049,5 +1049,6 @@
   "{profile} updated the member {member}.": "{profile} a mis à jour le ou la membre {member}.",
   "{title} ({count} todos)": "{title} ({count} todos)",
   "{username} was invited to {group}": "{username} a été invité à {group}",
-  "© The OpenStreetMap Contributors": "© Les Contributeur⋅ices OpenStreetMap"
+  "© The OpenStreetMap Contributors": "© Les Contributeur⋅ices OpenStreetMap",
+  "No information": "Non renseigné"
 }
diff --git a/js/src/views/About/AboutInstance.vue b/js/src/views/About/AboutInstance.vue
index 9aa1d9d26..120b0dcfb 100644
--- a/js/src/views/About/AboutInstance.vue
+++ b/js/src/views/About/AboutInstance.vue
@@ -25,7 +25,11 @@
       </div>
       <div class="column contact">
         <h4>{{ $t("Contact") }}</h4>
-        <instance-contact-link :contact="config.contact" />
+        <instance-contact-link
+          v-if="config && config.contact"
+          :contact="config.contact"
+        />
+        <p v-else>{{ $t("No information") }}</p>
       </div>
     </section>
     <hr />
diff --git a/js/src/views/About/Privacy.vue b/js/src/views/About/Privacy.vue
index 80a36581d..ffb1791f3 100644
--- a/js/src/views/About/Privacy.vue
+++ b/js/src/views/About/Privacy.vue
@@ -1,7 +1,7 @@
 <template>
   <div class="container section">
     <h2 class="title">{{ $t("Privacy Policy") }}</h2>
-    <div class="content" v-html="config.privacy.bodyHtml" />
+    <div class="content" v-if="config" v-html="config.privacy.bodyHtml" />
   </div>
 </template>
 
@@ -37,14 +37,14 @@ export default class Privacy extends Vue {
 
   @Watch("config", { deep: true })
   watchConfig(config: IConfig): void {
-    if (config.privacy.type) {
+    if (config?.privacy?.type) {
       this.redirectToUrl();
     }
   }
 
   redirectToUrl(): void {
-    if (this.config.privacy.type === InstancePrivacyType.URL) {
-      window.location.replace(this.config.privacy.url);
+    if (this.config?.privacy?.type === InstancePrivacyType.URL) {
+      window.location.replace(this.config?.privacy?.url);
     }
   }
 }
diff --git a/js/src/views/About/Terms.vue b/js/src/views/About/Terms.vue
index 7d60e8f7e..5a165a785 100644
--- a/js/src/views/About/Terms.vue
+++ b/js/src/views/About/Terms.vue
@@ -1,7 +1,7 @@
 <template>
   <div class="container section">
     <h2 class="title">{{ $t("Terms") }}</h2>
-    <div class="content" v-html="config.terms.bodyHtml" />
+    <div class="content" v-if="config" v-html="config.terms.bodyHtml" />
   </div>
 </template>
 
@@ -37,14 +37,14 @@ export default class Terms extends Vue {
 
   @Watch("config", { deep: true })
   watchConfig(config: IConfig): void {
-    if (config.terms.type) {
+    if (config?.terms?.type) {
       this.redirectToUrl();
     }
   }
 
   redirectToUrl(): void {
-    if (this.config.terms.type === InstanceTermsType.URL) {
-      window.location.replace(this.config.terms.url);
+    if (this.config?.terms?.type === InstanceTermsType.URL) {
+      window.location.replace(this.config?.terms?.url);
     }
   }
 }