Browse Source

add hCaptcha to contact form

Olivier Massot 1 year ago
parent
commit
7847f42c46
4 changed files with 309 additions and 352 deletions
  1. 5 1
      components/Contact/Form.vue
  2. 2 19
      nuxt.config.ts
  3. 2 1
      package.json
  4. 300 331
      yarn.lock

+ 5 - 1
components/Contact/Form.vue

@@ -172,6 +172,9 @@
           label="Captcha"
           label="Captcha"
         />
         />
 
 
+        <!-- @see https://github.com/hCaptcha/vue-hcaptcha -->
+        <vue-hcaptcha :sitekey="runtimeConfig.hCaptchaSiteKey" />
+
         <!-- Submit Button -->
         <!-- Submit Button -->
         <v-row>
         <v-row>
           <v-col cols="12">
           <v-col cols="12">
@@ -194,11 +197,12 @@
 </template>
 </template>
 
 
 <script setup lang="ts">
 <script setup lang="ts">
-import { ComputedRef } from "vue";
 import { ContactFormData } from "~/types/interface";
 import { ContactFormData } from "~/types/interface";
+import VueHcaptcha from '@hcaptcha/vue3-hcaptcha';
 
 
 const route = useRoute();
 const route = useRoute();
 const defaultRequestType = route.query.request;
 const defaultRequestType = route.query.request;
+const runtimeConfig = useRuntimeConfig()
 
 
 // --- Constants ---
 // --- Constants ---
 const requestTypes: Array<string> = [
 const requestTypes: Array<string> = [

+ 2 - 19
nuxt.config.ts

@@ -31,10 +31,12 @@ export default defineNuxtConfig({
     // Private config that is only available on the server
     // Private config that is only available on the server
     env: "",
     env: "",
     apiBaseUrl: "",
     apiBaseUrl: "",
+    hCaptchaSiteKey: "35360874-ebb1-4748-86e3-9b156d5bfc53",
     // Config within public will be also exposed to the client
     // Config within public will be also exposed to the client
     public: {
     public: {
       env: "",
       env: "",
       apiBaseUrl: "",
       apiBaseUrl: "",
+      hCaptchaSiteKey: "35360874-ebb1-4748-86e3-9b156d5bfc53",
     },
     },
   },
   },
   css: [
   css: [
@@ -137,25 +139,6 @@ export default defineNuxtConfig({
     ],
     ],
     defaultLocale: "fr",
     defaultLocale: "fr",
     detectBrowserLanguage: false,
     detectBrowserLanguage: false,
-    vueI18n: {
-      legacy: false,
-      datetimeFormats: {
-        "fr-FR": {
-          short: {
-            year: "numeric",
-            month: "numeric",
-            day: "numeric",
-          },
-          long: {
-            year: "numeric",
-            month: "numeric",
-            day: "numeric",
-            hour: "numeric",
-            minute: "numeric",
-          },
-        },
-      },
-    },
   } as NuxtI18nOptions,
   } as NuxtI18nOptions,
   build: {
   build: {
     transpile: transpile,
     transpile: transpile,

+ 2 - 1
package.json

@@ -21,6 +21,7 @@
     "@fortawesome/free-brands-svg-icons": "^6.4.0",
     "@fortawesome/free-brands-svg-icons": "^6.4.0",
     "@fortawesome/free-regular-svg-icons": "^6.4.0",
     "@fortawesome/free-regular-svg-icons": "^6.4.0",
     "@fortawesome/free-solid-svg-icons": "^6.4.0",
     "@fortawesome/free-solid-svg-icons": "^6.4.0",
+    "@hcaptcha/vue3-hcaptcha": "^1.3.0",
     "@mdi/font": "^7.2.96",
     "@mdi/font": "^7.2.96",
     "@nuxtjs/date-fns": "^1.5.0",
     "@nuxtjs/date-fns": "^1.5.0",
     "@nuxtjs/i18n": "^8.0.0-beta.9",
     "@nuxtjs/i18n": "^8.0.0-beta.9",
@@ -40,7 +41,7 @@
     "leaflet": "^1.9.3",
     "leaflet": "^1.9.3",
     "leaflet.markercluster": "^1.5.3",
     "leaflet.markercluster": "^1.5.3",
     "libphonenumber-js": "^1.9.38",
     "libphonenumber-js": "^1.9.38",
-    "nuxt": "^3.2.0",
+    "nuxt": "3.2.0",
     "nuxt-lodash": "^2.4.1",
     "nuxt-lodash": "^2.4.1",
     "ohmyfetch": "^0.4.21",
     "ohmyfetch": "^0.4.21",
     "pinia": "^2.0.33",
     "pinia": "^2.0.33",

File diff suppressed because it is too large
+ 300 - 331
yarn.lock


Some files were not shown because too many files changed in this diff