Skip to content

Commit

Permalink
fix env vars
Browse files Browse the repository at this point in the history
  • Loading branch information
nachat-ayoub committed Feb 17, 2024
1 parent b2a5b7c commit 9110b7f
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 15 deletions.
1 change: 0 additions & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ jobs:
run: npm install
- name: Build
run: npm run build
#Allow repo secrets
env:
VITE_SERVICE_ID: ${{ secrets.VITE_SERVICE_ID }}
VITE_TEMPLATE_ID: ${{ secrets.VITE_TEMPLATE_ID }}
Expand Down
1 change: 1 addition & 0 deletions src/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export function App() {
<form
onSubmit={(e) => {
e.preventDefault();

email.value = email.value.trim();

if (email.value === '') {
Expand Down
32 changes: 18 additions & 14 deletions src/useForm.tsx
Original file line number Diff line number Diff line change
@@ -1,22 +1,26 @@
import emailjs from '@emailjs/browser';

function useForm() {
const SERVICE_ID = import.meta.env.SERVICE_ID;
const TEMPLATE_ID = import.meta.env.TEMPLATE_ID;
const PUBLIC_KEY = import.meta.env.PUBLIC_KEY;
const SERVICE_ID = import.meta.env.VITE_SERVICE_ID;
const TEMPLATE_ID = import.meta.env.VITE_TEMPLATE_ID;
const PUBLIC_KEY = import.meta.env.VITE_PUBLIC_KEY;

function sendEmail(e: any, cb: (error: string | null) => void) {
// React.FormEvent<HTMLFormElement>
emailjs.sendForm(SERVICE_ID, TEMPLATE_ID, e.target, PUBLIC_KEY).then(
function (response) {
console.log('SUCCESS!', response.status, response.text);
cb(null);
},
function (err) {
console.log('FAILED...', err);
cb('FAILED...');
}
);
try {
emailjs.sendForm(SERVICE_ID, TEMPLATE_ID, e.target, PUBLIC_KEY).then(
function (response) {
console.log('SUCCESS!', response.status, response.text);
cb(null);
},
function (err) {
console.log('FAILED...', err);
cb('FAILED...');
}
);
} catch (error) {
console.log(error);
cb('Failed because of ' + error);
}
}

return { sendEmail };
Expand Down

0 comments on commit 9110b7f

Please sign in to comment.