import React, { useRef } from "react";
import emailjs from "emailjs-com";
const WarrantyClaimForm = () => {
const formRef = useRef();
const handleSubmit = (e) => {
e.preventDefault();
const form = formRef.current;
// Basic validation
const requiredFields = ["customer_name", "customer_email", "customer_phone", "vehicle_make_model", "registration_number", "fault_description"];
for (let f of requiredFields) {
if (!form[f].value.trim()) {
alert("Please fill all required fields.");
form[f].focus();
return;
}
}
// Send internal notification
emailjs.sendForm("service_lsjkjdk", "template_7ryd8sg", form)
.then(() => alert("Claim submitted successfully!"))
.catch(err => alert("Error sending claim: " + JSON.stringify(err)));
// Customer auto-reply
emailjs.send("service_lsjkjdk", "template_7ryd8sg", {
customer_name: form.customer_name.value,
customer_email: form.customer_email.value
}).catch(console.log);
form.reset();
};
return (
);
};
// Inline styles for inputs and button
const inputStyle = {
width: "100%",
margin: "5px 0",
padding: "8px",
border: "1px solid #ccc",
borderRadius: 4,
color: "#000"
};
const buttonStyle = {
width: "100%",
padding: "14px",
background: "#0b5ed7",
color: "#fff",
border: "none",
cursor: "pointer",
marginTop: 10
};
export default WarrantyClaimForm;
ABARTH 595
1.4 Abarth 595 1.4 Tjet 140 Hp (2015)
£4995