diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 07126f8..1c85952 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -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 }} diff --git a/src/app.tsx b/src/app.tsx index bef6442..013edb4 100644 --- a/src/app.tsx +++ b/src/app.tsx @@ -42,6 +42,7 @@ export function App() {
{ e.preventDefault(); + email.value = email.value.trim(); if (email.value === '') { diff --git a/src/useForm.tsx b/src/useForm.tsx index 77a146a..539b2b5 100644 --- a/src/useForm.tsx +++ b/src/useForm.tsx @@ -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 - 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 };