Browse Source

contactForm: ajout des notifications react-toastify

Lou 3 years ago
parent
commit
0a92e75198
4 changed files with 33 additions and 4 deletions
  1. 1
    0
      gatsby-config.js
  2. 4
    3
      src/components/contactForm/index.jsx
  3. 13
    0
      src/components/layout/index.jsx
  4. 15
    1
      yarn.lock

+ 1
- 0
gatsby-config.js View File

@@ -12,6 +12,7 @@ module.exports = {
12 12
 	plugins: [
13 13
 		"gatsby-plugin-sass",
14 14
 		"gatsby-transformer-remark",
15
+		"gatsby-plugin-react-helmet",
15 16
 		{
16 17
 			resolve: "gatsby-source-filesystem",
17 18
 			options: {

+ 4
- 3
src/components/contactForm/index.jsx View File

@@ -1,10 +1,11 @@
1 1
 import emailjs from "emailjs-com";
2 2
 import React, { useState } from "react";
3
+import { toast } from "react-toastify";
4
+import "react-toastify/dist/ReactToastify.css";
3 5
 
4 6
 import "./index.scss";
5 7
 import ProfilePic from "../../images/profile.svg";
6 8
 import AtSymbole from "../../images/atSymbole.svg";
7
-// import { toast } from "react-toastify";
8 9
 
9 10
 const ContactForm = () => {
10 11
 	const [name, setName] = useState("");
@@ -39,10 +40,10 @@ const ContactForm = () => {
39 40
 			)
40 41
 			.then(
41 42
 				() => {
42
-					alert("Message envoyé");
43
+					toast("Message envoyé");
43 44
 				},
44 45
 				() => {
45
-					alert(
46
+					toast.error(
46 47
 						"Votre message n'a pas pu être envoyé. Merci de nous contacter directement par mail."
47 48
 					);
48 49
 				}

+ 13
- 0
src/components/layout/index.jsx View File

@@ -1,14 +1,27 @@
1 1
 import React from "react";
2 2
 import PropTypes from "prop-types";
3
+import { ToastContainer, toast } from "react-toastify";
3 4
 
4 5
 import Header from "../header";
5 6
 import Footer from "../footer";
6 7
 
8
+toast.configure();
9
+
7 10
 const Layout = ({ children }) => {
8 11
 	return (
9 12
 		<>
10 13
 			<Header />
11 14
 			<main>{children}</main>
15
+			<ToastContainer
16
+				position="bottom-center"
17
+				autoClose={3000}
18
+				newestOnTop
19
+				hideProgressBar
20
+				closeOnClick
21
+				pauseOnFocusLoss={false}
22
+				draggable
23
+				pauseOnHover
24
+			/>
12 25
 			<Footer />
13 26
 		</>
14 27
 	);

+ 15
- 1
yarn.lock View File

@@ -999,7 +999,7 @@
999 999
     core-js-pure "^3.16.0"
1000 1000
     regenerator-runtime "^0.13.4"
1001 1001
 
1002
-"@babel/runtime@^7.10.0", "@babel/runtime@^7.10.2", "@babel/runtime@^7.11.2", "@babel/runtime@^7.14.6", "@babel/runtime@^7.7.2", "@babel/runtime@^7.8.4", "@babel/runtime@^7.9.2":
1002
+"@babel/runtime@^7.10.0", "@babel/runtime@^7.10.2", "@babel/runtime@^7.11.2", "@babel/runtime@^7.14.6", "@babel/runtime@^7.14.8", "@babel/runtime@^7.7.2", "@babel/runtime@^7.8.4", "@babel/runtime@^7.9.2":
1003 1003
   version "7.15.3"
1004 1004
   resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.15.3.tgz#2e1c2880ca118e5b2f9988322bd8a7656a32502b"
1005 1005
   integrity sha512-OvwMLqNXkCXSz1kSm58sEsNuhqOx/fKpnUnKnFB5v8uDda5bLNEHNgKPvhDN6IU0LDcnHQ90LlJ0Q6jnyBSIBA==
@@ -4916,6 +4916,13 @@ gatsby-page-utils@^1.11.0:
4916 4916
     lodash "^4.17.21"
4917 4917
     micromatch "^4.0.2"
4918 4918
 
4919
+gatsby-plugin-layout@^2.12.0:
4920
+  version "2.12.0"
4921
+  resolved "https://registry.yarnpkg.com/gatsby-plugin-layout/-/gatsby-plugin-layout-2.12.0.tgz#8564e6b012287f0108fbfadf4e269a581a570a08"
4922
+  integrity sha512-zBj7JTrAC6ro5GJPA2WxFEc+VMa6P62SnbKsj1fOUo8oVgNSV3I2oX9UMGv+S58nquW0NX/pNjIU8wR4IRwYmw==
4923
+  dependencies:
4924
+    "@babel/runtime" "^7.14.8"
4925
+
4919 4926
 gatsby-plugin-manifest@^3.11.0:
4920 4927
   version "3.11.0"
4921 4928
   resolved "https://registry.yarnpkg.com/gatsby-plugin-manifest/-/gatsby-plugin-manifest-3.11.0.tgz#9dfc08f3573636edb7eba904291da9ca482524f4"
@@ -4942,6 +4949,13 @@ gatsby-plugin-page-creator@^3.11.0:
4942 4949
     globby "^11.0.3"
4943 4950
     lodash "^4.17.21"
4944 4951
 
4952
+gatsby-plugin-react-helmet@^4.12.0:
4953
+  version "4.12.0"
4954
+  resolved "https://registry.yarnpkg.com/gatsby-plugin-react-helmet/-/gatsby-plugin-react-helmet-4.12.0.tgz#85272d332497cf51ef399b48f06b1d4c81f3e42a"
4955
+  integrity sha512-vjVy+tEWGWgyTP7QnJEK2P++ctQ+mWBYGu92fSeHoEFhkxp7G0/v8E92YAPu0cKHEp7cwo4kEXo5++cWqj3QDQ==
4956
+  dependencies:
4957
+    "@babel/runtime" "^7.14.8"
4958
+
4945 4959
 gatsby-plugin-sass@^4.11.0:
4946 4960
   version "4.11.0"
4947 4961
   resolved "https://registry.yarnpkg.com/gatsby-plugin-sass/-/gatsby-plugin-sass-4.11.0.tgz#a17b952d29364727250e7ea7e97c03249c547121"

Loading…
Cancel
Save