Skip to content

Commit

Permalink
Importing emailjs public key from .env
Browse files Browse the repository at this point in the history
  • Loading branch information
sohamkl committed Sep 10, 2024
1 parent eb3db72 commit 1aad2ce
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 46 deletions.
16 changes: 10 additions & 6 deletions frontend/src/ui/contact/ContactForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,19 @@ import React, { useState, useEffect } from 'react';
import styles from './contacts.module.css';
import emailjs from 'emailjs-com';

const publicKey = process.env.REACT_APP_EMAILJS_PUBLIC_KEY;

function ContactForm() {
const [formData, setFormData] = useState({ firstName: "", lastName: "", email: "", query: "" });

useEffect(() => {
// Initialize EmailJS with your public key
emailjs.init('lgHt4sp2yoPmjiPiN');
}, []);
const publicKey = process.env.REACT_APP_EMAILJS_PUBLIC_KEY;

if (publicKey) {
emailjs.init(publicKey);
console.log('EmailJS initialized');
} else {
console.error('EmailJS public key is missing');
}
}, []); // Only initialize on mount

const handleChange = (event: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => {
const { name, value } = event.target;
Expand Down Expand Up @@ -105,4 +109,4 @@ function ContactForm() {
);
}

export default ContactForm;
export default ContactForm;
12 changes: 12 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"@openapitools/openapi-generator-cli": "^2.13.4",
"@types/express": "^4.17.21",
"@types/swagger-ui-express": "^4.1.6",
"dotenv": "^16.4.5",
"prettier": "^3.3.3"
},
"devDependencies": {
Expand Down
45 changes: 5 additions & 40 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -55,46 +55,6 @@
resolved "https://registry.npmjs.org/@next/swc-darwin-arm64/-/swc-darwin-arm64-14.2.7.tgz"
integrity sha512-UhZGcOyI9LE/tZL3h9rs/2wMZaaJKwnpAyegUVDGZqwsla6hMfeSj9ssBWQS9yA4UXun3pPhrFLVnw5KXZs3vw==

"@next/[email protected]":
version "14.2.7"
resolved "https://registry.npmjs.org/@next/swc-darwin-x64/-/swc-darwin-x64-14.2.7.tgz"
integrity sha512-ys2cUgZYRc+CbyDeLAaAdZgS7N1Kpyy+wo0b/gAj+SeOeaj0Lw/q+G1hp+DuDiDAVyxLBCJXEY/AkhDmtihUTA==

"@next/[email protected]":
version "14.2.7"
resolved "https://registry.npmjs.org/@next/swc-linux-arm64-gnu/-/swc-linux-arm64-gnu-14.2.7.tgz"
integrity sha512-2xoWtE13sUJ3qrC1lwE/HjbDPm+kBQYFkkiVECJWctRASAHQ+NwjMzgrfqqMYHfMxFb5Wws3w9PqzZJqKFdWcQ==

"@next/[email protected]":
version "14.2.7"
resolved "https://registry.npmjs.org/@next/swc-linux-arm64-musl/-/swc-linux-arm64-musl-14.2.7.tgz"
integrity sha512-+zJ1gJdl35BSAGpkCbfyiY6iRTaPrt3KTl4SF/B1NyELkqqnrNX6cp4IjjjxKpd64/7enI0kf6b9O1Uf3cL0pw==

"@next/[email protected]":
version "14.2.7"
resolved "https://registry.npmjs.org/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-14.2.7.tgz"
integrity sha512-m6EBqrskeMUzykBrv0fDX/28lWIBGhMzOYaStp0ihkjzIYJiKUOzVYD1gULHc8XDf5EMSqoH/0/TRAgXqpQwmw==

"@next/[email protected]":
version "14.2.7"
resolved "https://registry.npmjs.org/@next/swc-linux-x64-musl/-/swc-linux-x64-musl-14.2.7.tgz"
integrity sha512-gUu0viOMvMlzFRz1r1eQ7Ql4OE+hPOmA7smfZAhn8vC4+0swMZaZxa9CSIozTYavi+bJNDZ3tgiSdMjmMzRJlQ==

"@next/[email protected]":
version "14.2.7"
resolved "https://registry.npmjs.org/@next/swc-win32-arm64-msvc/-/swc-win32-arm64-msvc-14.2.7.tgz"
integrity sha512-PGbONHIVIuzWlYmLvuFKcj+8jXnLbx4WrlESYlVnEzDsa3+Q2hI1YHoXaSmbq0k4ZwZ7J6sWNV4UZfx1OeOlbQ==

"@next/[email protected]":
version "14.2.7"
resolved "https://registry.npmjs.org/@next/swc-win32-ia32-msvc/-/swc-win32-ia32-msvc-14.2.7.tgz"
integrity sha512-BiSY5umlx9ed5RQDoHcdbuKTUkuFORDqzYKPHlLeS+STUWQKWziVOn3Ic41LuTBvqE0TRJPKpio9GSIblNR+0w==

"@next/[email protected]":
version "14.2.7"
resolved "https://registry.npmjs.org/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-14.2.7.tgz"
integrity sha512-pxsI23gKWRt/SPHFkDEsP+w+Nd7gK37Hpv0ngc5HpWy2e7cKx9zR/+Q2ptAUqICNTecAaGWvmhway7pj/JLEWA==

"@nuxtjs/[email protected]":
version "0.3.2"
resolved "https://registry.npmjs.org/@nuxtjs/opencollective/-/opencollective-0.3.2.tgz"
Expand Down Expand Up @@ -450,6 +410,11 @@ delayed-stream@~1.0.0:
resolved "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz"
integrity sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==

dotenv@^16.4.5:
version "16.4.5"
resolved "https://registry.npmjs.org/dotenv/-/dotenv-16.4.5.tgz"
integrity sha512-ZmdL2rui+eB2YwhsWzjInR8LldtZHGDoQ1ugH85ppHKwpUHL7j7rN0Ti9NCnGiQbhaZ11FpR+7ao1dNsmduNUg==

[email protected]:
version "1.1.0"
resolved "https://registry.npmjs.org/easy-table/-/easy-table-1.1.0.tgz"
Expand Down

0 comments on commit 1aad2ce

Please sign in to comment.