Browse Source

le formulaire de contact est fonctionnel

Lou 3 years ago
parent
commit
f3fd070b19

+ 2
- 1
.gitignore View File

@@ -1,4 +1,5 @@
1 1
 node_modules/
2 2
 .cache/
3 3
 public
4
-.vscode
4
+.vscode
5
+.env.*

+ 4
- 0
gatsby-config.js View File

@@ -1,3 +1,7 @@
1
+require("dotenv").config({
2
+	path: `.env.${process.env.NODE_ENV}`
3
+});
4
+
1 5
 module.exports = {
2 6
 	siteMetadata: {
3 7
 		siteUrl: `https://www.yourdomain.tld`,

+ 2
- 0
package.json View File

@@ -15,12 +15,14 @@
15 15
 		"clean": "gatsby clean"
16 16
 	},
17 17
 	"dependencies": {
18
+		"emailjs-com": "^3.2.0",
18 19
 		"gatsby": "^3.11.1",
19 20
 		"gatsby-plugin-sass": "^4.11.0",
20 21
 		"gatsby-source-filesystem": "^3.11.0",
21 22
 		"gatsby-transformer-remark": "^4.8.0",
22 23
 		"react": "^17.0.1",
23 24
 		"react-dom": "^17.0.1",
25
+		"react-toastify": "^7.0.4",
24 26
 		"sass": "^1.37.5"
25 27
 	},
26 28
 	"devDependencies": {

+ 66
- 5
src/components/contactForm/index.jsx View File

@@ -1,27 +1,88 @@
1
-import React from "react";
1
+import emailjs from "emailjs-com";
2
+import React, { useState } from "react";
2 3
 import "./index.scss";
3 4
 
4 5
 const ContactForm = () => {
6
+	const [name, setName] = useState("");
7
+	const [email, setEmail] = useState("");
8
+	const [message, setMessage] = useState("");
9
+
10
+	const handleNameChange = (e) => {
11
+		setName(e.target.value);
12
+	};
13
+
14
+	const handleEmailChange = (e) => {
15
+		setEmail(e.target.value);
16
+	};
17
+
18
+	const handleMessageChange = (e) => {
19
+		setMessage(e.target.value);
20
+	};
21
+
22
+	const sendEmail = (data) => {
23
+		emailjs
24
+			.send(
25
+				process.env.SERVICE_ID,
26
+				process.env.TEMPLATE_ID,
27
+				data,
28
+				process.env.USER_ID
29
+			)
30
+			.then(
31
+				(result) => {
32
+					return true;
33
+				},
34
+				(error) => {
35
+					return false;
36
+				}
37
+			);
38
+	};
39
+
40
+	const handleSubmit = (e) => {
41
+		e.preventDefault();
42
+
43
+		const data = {
44
+			from_name: name,
45
+			from_email: email,
46
+			from_message: message
47
+		};
48
+
49
+		if (sendEmail) e.target.reset();
50
+	};
51
+
5 52
 	return (
6 53
 		<div id="contact">
7
-			<form id="contact-form" action="">
54
+			<form id="contact-form" action="" onSubmit={handleSubmit}>
8 55
 				<div className="form-group">
9 56
 					<label className="form-label" htmlFor="name">
10 57
 						Nom
11 58
 					</label>
12
-					<input type="text" placeholder="Nom" className="form-input" />
59
+					<input
60
+						type="text"
61
+						placeholder="Nom"
62
+						className="form-input"
63
+						onChange={handleNameChange}
64
+					/>
13 65
 				</div>
14 66
 				<div className="form-group">
15 67
 					<label className="form-label" htmlFor="email">
16 68
 						Adresse email
17 69
 					</label>
18
-					<input type="email" placeholder="Email" className="form-input" />
70
+					<input
71
+						type="email"
72
+						placeholder="Email"
73
+						className="form-input"
74
+						onChange={handleEmailChange}
75
+					/>
19 76
 				</div>
20 77
 				<div className="form-group">
21 78
 					<label className="form-label" htmlFor="message">
22 79
 						Message
23 80
 					</label>
24
-					<textarea placeholder="Message" className="form-textarea"></textarea>
81
+					<textarea
82
+						placeholder="Message"
83
+						className="form-textarea"
84
+						onChange={handleMessageChange}
85
+					/>
25 86
 				</div>
26 87
 				<button type="submit" className="form-submit-btn">
27 88
 					Envoyer

+ 19
- 5
src/components/contactForm/index.scss View File

@@ -1,9 +1,19 @@
1 1
 #contact {
2
-	width: 30%;
3
-	padding: 10px;
4 2
 	border-radius: 10px;
5 3
 	background-color: #fff;
6 4
 	margin: 0 auto;
5
+	padding: 10px;
6
+	width: 300px;
7
+
8
+	#contact-form {
9
+		width: 100%;
10
+	}
11
+
12
+	#contact-form > * {
13
+		display: flex;
14
+		flex-direction: column;
15
+		align-items: center;
16
+	}
7 17
 }
8 18
 
9 19
 .form-group {
@@ -13,14 +23,14 @@
13 23
 	.form-input,
14 24
 	.form-textarea {
15 25
 		display: block;
16
-		line-height: 2em;
26
+		line-height: 2rem;
17 27
 		margin: 0;
18 28
 		padding-left: 10px;
19 29
 		width: 100%;
20
-		font-size: 500;
30
+		font-size: 1rem;
21 31
 		border: 1px solid #111;
22 32
 		background-color: #f4f4f4;
23
-		border-radius: 5px;
33
+		border-radius: 0.5rem;
24 34
 		-webkit-box-sizing: border-box;
25 35
 		-moz-box-sizing: border-box;
26 36
 		box-sizing: border-box;
@@ -35,4 +45,8 @@
35 45
 			font-weight: 400;
36 46
 		}
37 47
 	}
48
+
49
+	.form-textarea {
50
+		height: 8rem;
51
+	}
38 52
 }

+ 3
- 0
src/images/arrobase.svg View File

@@ -0,0 +1,3 @@
1
+<svg width="1689" height="1689" viewBox="0 0 1689 1689" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+<path d="M1070.86 1027.25L1065.39 1019.48L1059.1 1026.6C1007.26 1085.29 932.426 1123 848.342 1123C692.649 1123 565.956 996.304 565.956 840.611C565.956 684.918 692.649 558.226 848.342 558.226C912.07 558.226 970.33 580.271 1017.75 616.163L1029.77 625.267V610.183V608.703C1029.77 580.799 1052.35 558.226 1080.25 558.226C1108.15 558.226 1130.73 580.799 1130.73 608.703V898.589C1130.73 966.652 1186.12 1022.04 1254.18 1022.04C1322.25 1022.04 1377.64 966.652 1377.64 898.589C1377.64 702.843 1312.82 555.892 1213.9 457.866C1115.05 359.908 982.645 311.317 848.342 311.317C556.467 311.317 319.047 548.736 319.047 840.611C319.047 1132.49 556.467 1369.91 848.342 1369.91C965.933 1369.91 1077.21 1332.23 1170.07 1260.9C1183.74 1250.47 1197.41 1248.07 1209.42 1250.44C1221.62 1252.84 1232.69 1260.29 1240.52 1270.54C1248.35 1280.79 1252.64 1293.44 1251.79 1305.84C1250.95 1318.05 1245.11 1330.58 1231.61 1340.94C1120.88 1425.94 988.411 1470.86 848.342 1470.86C500.829 1470.86 218.093 1188.12 218.093 840.611C218.093 493.099 500.829 210.363 848.342 210.363C1006.73 210.363 1164.24 268.767 1282.13 383.807C1399.94 498.766 1478.59 670.697 1478.59 898.589C1478.59 1022.35 1377.94 1123 1254.18 1123C1178.4 1123 1111.53 1085.02 1070.86 1027.25ZM844.475 7.5C382.226 7.5 7.5 382.226 7.5 844.475C7.5 1306.72 382.226 1681.45 844.475 1681.45C1306.72 1681.45 1681.45 1306.72 1681.45 844.475C1681.45 382.226 1306.72 7.5 844.475 7.5ZM848.342 659.18C748.29 659.18 666.91 740.56 666.91 840.611C666.91 940.663 748.29 1022.04 848.342 1022.04C948.393 1022.04 1029.77 940.663 1029.77 840.611C1029.77 740.56 948.393 659.18 848.342 659.18Z" fill="#B2B2B2" stroke="#B2B2B2" stroke-width="15"/>
3
+</svg>

+ 5
- 0
src/images/profile.svg View File

@@ -0,0 +1,5 @@
1
+<svg width="1767" height="1767" viewBox="0 0 1767 1767" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+<path d="M611.394 545.306C611.394 395.019 733.233 273.147 883.5 273.147C1033.85 273.147 1155.69 395.024 1155.69 545.306C1155.69 695.626 1033.86 817.466 883.5 817.466C733.23 817.466 611.394 695.632 611.394 545.306Z" fill="#B3B3B3"/>
3
+<path d="M431.551 1299.3C431.551 1146.85 554.871 1024.65 707.75 1024.65H1059.33C1212.18 1024.65 1335.05 1146.78 1335.05 1299.3C1335.05 1328.18 1322.43 1355.57 1300.45 1374.29L1300.44 1374.31L1300.42 1374.32C1188.08 1470.26 1042.4 1528.16 883.299 1528.16C724.238 1528.16 578.602 1470.26 466.206 1374.35L466.201 1374.35C444.229 1355.6 431.551 1328.11 431.551 1299.3Z" fill="#B3B3B3"/>
4
+<path fill-rule="evenodd" clip-rule="evenodd" d="M0 883.5C0 853.003 1.54534 822.867 4.56198 793.166C47.5387 370.027 389.137 35.1696 815.225 2.59944C837.757 0.877029 860.526 0 883.5 0L883.545 1.90735e-06C1371.49 0.0241432 1767 395.561 1767 883.5C1767 913.997 1765.46 944.133 1762.44 973.834C1721.09 1381.07 1403.19 1706.53 999.474 1759.46C961.522 1764.43 922.811 1767 883.5 1767C761.517 1767 645.307 1742.28 539.607 1697.57C460.332 1664.04 386.969 1619.27 321.517 1565.25C125.16 1403.21 0 1157.97 0 883.5ZM883.5 213.147C700.083 213.147 551.394 361.895 551.394 545.306C551.394 728.761 700.085 877.466 883.5 877.466C1066.99 877.466 1215.69 728.766 1215.69 545.306C1215.69 361.889 1066.99 213.147 883.5 213.147ZM707.75 964.653C522.128 964.653 371.551 1113.32 371.551 1299.3C371.551 1345.69 391.935 1389.86 427.259 1419.99C550.08 1524.8 709.399 1588.16 883.299 1588.16C1057.24 1588.16 1216.6 1524.8 1339.39 1419.94C1374.77 1389.79 1395.05 1345.69 1395.05 1299.3C1395.05 1113.38 1245.06 964.653 1059.33 964.653H707.75Z" fill="#B3B3B3"/>
5
+</svg>

+ 0
- 2
src/pages/index.jsx View File

@@ -127,8 +127,6 @@ const IndexPage = () => {
127 127
 				</section>
128 128
 			</div>
129 129
 			<Footer />
130
-
131
-			<noscript>fuck you</noscript>
132 130
 		</main>
133 131
 	);
134 132
 };

+ 1
- 1
src/pages/nous-contacter.jsx View File

@@ -1,4 +1,4 @@
1
-import * as React from "react";
1
+import React from "react";
2 2
 
3 3
 import Header from "../components/header";
4 4
 import ContactForm from "../components/contactForm";

+ 2
- 2
src/pages/statuts.jsx View File

@@ -3,7 +3,7 @@ import "../scss/index.scss";
3 3
 import Header from "../components/header";
4 4
 import Footer from "../components/footer";
5 5
 
6
-const Statuts = () => {
6
+const StatutsPage = () => {
7 7
 	return (
8 8
 		<main>
9 9
 			<title>Nos statuts</title>
@@ -252,4 +252,4 @@ const Statuts = () => {
252 252
 		</main>
253 253
 	);
254 254
 };
255
-export default Statuts;
255
+export default StatutsPage;

+ 1
- 1
src/scss/index.scss View File

@@ -117,7 +117,7 @@ section.services-list {
117 117
 
118 118
 .page-contact {
119 119
 	display: flex;
120
-	flex-wrap: wrap;
120
+	flex-wrap: wrap-reverse;
121 121
 
122 122
 	.contact-instructions {
123 123
 		margin: 1rem;

+ 11830
- 0
yarn-error.log
File diff suppressed because it is too large
View File


+ 25
- 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==
@@ -2926,6 +2926,11 @@ clone-response@1.0.2, clone-response@^1.0.2:
2926 2926
   dependencies:
2927 2927
     mimic-response "^1.0.0"
2928 2928
 
2929
+clsx@^1.1.1:
2930
+  version "1.1.1"
2931
+  resolved "https://registry.yarnpkg.com/clsx/-/clsx-1.1.1.tgz#98b3134f9abbdf23b2663491ace13c5c03a73188"
2932
+  integrity sha512-6/bPho624p3S2pMyvP5kKBPXnI3ufHLObBFCfgx+LkeR5lg2XYy2hqZqUf45ypD8COn2bhgGJSUE+l5dhNBieA==
2933
+
2929 2934
 code-point-at@^1.0.0:
2930 2935
   version "1.1.0"
2931 2936
   resolved "https://registry.yarnpkg.com/code-point-at/-/code-point-at-1.1.0.tgz#0d070b4d043a5bea33a2f1a40e2edb3d9a4ccf77"
@@ -3842,6 +3847,11 @@ electron-to-chromium@^1.3.564, electron-to-chromium@^1.3.793:
3842 3847
   resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.806.tgz#21502100f11aead6c501d1cd7f2504f16c936642"
3843 3848
   integrity sha512-AH/otJLAAecgyrYp0XK1DPiGVWcOgwPeJBOLeuFQ5l//vhQhwC9u6d+GijClqJAmsHG4XDue81ndSQPohUu0xA==
3844 3849
 
3850
+emailjs-com@^3.2.0:
3851
+  version "3.2.0"
3852
+  resolved "https://registry.yarnpkg.com/emailjs-com/-/emailjs-com-3.2.0.tgz#a53cb22f1bc433c701c84c53d8b56eefd5ce7111"
3853
+  integrity sha512-Prbz3E1usiAwGjMNYRv6EsJ5c373cX7/AGnZQwOfrpNJrygQJ15+E9OOq4pU8yC977Z5xMetRfc3WmDX6RcjAA==
3854
+
3845 3855
 "emoji-regex@>=6.0.0 <=6.1.1":
3846 3856
   version "6.1.1"
3847 3857
   resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-6.1.1.tgz#c6cd0ec1b0642e2a3c67a1137efc5e796da4f88e"
@@ -4906,6 +4916,13 @@ gatsby-page-utils@^1.11.0:
4906 4916
     lodash "^4.17.21"
4907 4917
     micromatch "^4.0.2"
4908 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
+
4909 4926
 gatsby-plugin-manifest@^3.11.0:
4910 4927
   version "3.11.0"
4911 4928
   resolved "https://registry.yarnpkg.com/gatsby-plugin-manifest/-/gatsby-plugin-manifest-3.11.0.tgz#9dfc08f3573636edb7eba904291da9ca482524f4"
@@ -9135,6 +9152,13 @@ react-refresh@^0.9.0:
9135 9152
   resolved "https://registry.yarnpkg.com/react-refresh/-/react-refresh-0.9.0.tgz#71863337adc3e5c2f8a6bfddd12ae3bfe32aafbf"
9136 9153
   integrity sha512-Gvzk7OZpiqKSkxsQvO/mbTN1poglhmAV7gR/DdIrRrSMXraRQQlfikRJOr3Nb9GTMPC5kof948Zy6jJZIFtDvQ==
9137 9154
 
9155
+react-toastify@^7.0.4:
9156
+  version "7.0.4"
9157
+  resolved "https://registry.yarnpkg.com/react-toastify/-/react-toastify-7.0.4.tgz#7d0b743f2b96f65754264ca6eae31911a82378db"
9158
+  integrity sha512-Rol7+Cn39hZp5hQ/k6CbMNE2CKYV9E5OQdC/hBLtIQU2xz7DdAm7xil4NITQTHR6zEbE5RVFbpgSwTD7xRGLeQ==
9159
+  dependencies:
9160
+    clsx "^1.1.1"
9161
+
9138 9162
 react@^17.0.1:
9139 9163
   version "17.0.2"
9140 9164
   resolved "https://registry.yarnpkg.com/react/-/react-17.0.2.tgz#d0b5cc516d29eb3eee383f75b62864cfb6800037"

Loading…
Cancel
Save