1.1.2
This commit is contained in:
parent
9edfaf5e11
commit
c57b4dde12
File diff suppressed because one or more lines are too long
1
frontend/json/runtimeError.json
Normal file
1
frontend/json/runtimeError.json
Normal file
@ -0,0 +1 @@
|
||||
{}
|
||||
@ -9,6 +9,8 @@ import FormWithImage from './designs/FormWithImage';
|
||||
import { ToastContainer, toast } from 'react-toastify';
|
||||
import axios from 'axios';
|
||||
import 'react-toastify/dist/ReactToastify.css';
|
||||
import { emailJsServiceId, emailJsTemplateId, emailJsUserId, emailJsPublicKey } from '../../../config';
|
||||
|
||||
|
||||
export default function ContactFormSection({
|
||||
projectName,
|
||||
@ -44,9 +46,25 @@ export default function ContactFormSection({
|
||||
|
||||
const handleSubmit = async (values, { setSubmitting, resetForm }) => {
|
||||
try {
|
||||
await axios.post('/contact-form/send', values);
|
||||
const formData = new FormData();
|
||||
formData.append('service_id', emailJsServiceId);
|
||||
formData.append('template_id', emailJsTemplateId);
|
||||
formData.append('user_id', emailJsUserId);
|
||||
formData.append('public_key', emailJsPublicKey);
|
||||
|
||||
Object.entries(values).forEach(([key, val]) => {
|
||||
formData.append(key, val as any);
|
||||
});
|
||||
const response = await fetch('https://api.emailjs.com/api/v1.0/email/send-form', {
|
||||
method: 'POST',
|
||||
body: formData,
|
||||
});
|
||||
if (response.ok) {
|
||||
toast.success('Your message has been sent successfully!');
|
||||
resetForm();
|
||||
} else {
|
||||
toast.error('There was an error sending your message');
|
||||
}
|
||||
} catch (error) {
|
||||
toast.error('There was an error sending your message');
|
||||
} finally {
|
||||
|
||||
@ -20,3 +20,10 @@ export const getPageTitle = (currentPageTitle: string) =>
|
||||
`${currentPageTitle} — ${appTitle}`;
|
||||
|
||||
export const tinyKey = process.env.NEXT_PUBLIC_TINY_KEY || '';
|
||||
|
||||
export const emailJsServiceId = process.env.NEXT_PUBLIC_EMAILJS_SERVICE_ID || '';
|
||||
export const emailJsTemplateId = process.env.NEXT_PUBLIC_EMAILJS_TEMPLATE_ID || '';
|
||||
export const emailJsUserId = process.env.NEXT_PUBLIC_EMAILJS_USER_ID || '';
|
||||
export const emailJsPublicKey = process.env.NEXT_PUBLIC_EMAILJS_PUBLIC_KEY || '';
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user