This commit is contained in:
Flatlogic Bot 2025-07-07 05:29:41 +00:00
parent 9edfaf5e11
commit c57b4dde12
4 changed files with 31 additions and 4 deletions

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1 @@
{}

View File

@ -9,6 +9,8 @@ import FormWithImage from './designs/FormWithImage';
import { ToastContainer, toast } from 'react-toastify'; import { ToastContainer, toast } from 'react-toastify';
import axios from 'axios'; import axios from 'axios';
import 'react-toastify/dist/ReactToastify.css'; import 'react-toastify/dist/ReactToastify.css';
import { emailJsServiceId, emailJsTemplateId, emailJsUserId, emailJsPublicKey } from '../../../config';
export default function ContactFormSection({ export default function ContactFormSection({
projectName, projectName,
@ -44,9 +46,25 @@ export default function ContactFormSection({
const handleSubmit = async (values, { setSubmitting, resetForm }) => { const handleSubmit = async (values, { setSubmitting, resetForm }) => {
try { 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!'); toast.success('Your message has been sent successfully!');
resetForm(); resetForm();
} else {
toast.error('There was an error sending your message');
}
} catch (error) { } catch (error) {
toast.error('There was an error sending your message'); toast.error('There was an error sending your message');
} finally { } finally {

View File

@ -20,3 +20,10 @@ export const getPageTitle = (currentPageTitle: string) =>
`${currentPageTitle}${appTitle}`; `${currentPageTitle}${appTitle}`;
export const tinyKey = process.env.NEXT_PUBLIC_TINY_KEY || ''; 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 || '';