This commit is contained in:
Iliyan Angelov
2025-11-28 20:24:58 +02:00
parent b5698b6018
commit cf97df9aeb
135 changed files with 7641 additions and 357 deletions

View File

@@ -8,6 +8,8 @@ import { toast } from 'react-toastify';
import Recaptcha from '../components/common/Recaptcha';
import { recaptchaService } from '../services/api/systemSettingsService';
import ChatWidget from '../components/chat/ChatWidget';
import { useAntibotForm } from '../hooks/useAntibotForm';
import HoneypotField from '../components/common/HoneypotField';
const ContactPage: React.FC = () => {
const { settings } = useCompanySettings();
@@ -21,7 +23,25 @@ const ContactPage: React.FC = () => {
});
const [loading, setLoading] = useState(false);
const [errors, setErrors] = useState<Record<string, string>>({});
const [recaptchaToken, setRecaptchaToken] = useState<string | null>(null);
// Enhanced antibot protection
const {
honeypotValue,
setHoneypotValue,
recaptchaToken,
setRecaptchaToken,
validate: validateAntibot,
rateLimitInfo,
} = useAntibotForm({
formId: 'contact',
minTimeOnPage: 5000,
minTimeToFill: 3000,
requireRecaptcha: false,
maxAttempts: 5,
onValidationError: (errors) => {
errors.forEach((err) => toast.error(err));
},
});
const validateForm = (): boolean => {
const newErrors: Record<string, string> = {};
@@ -57,6 +77,11 @@ const ContactPage: React.FC = () => {
return;
}
// Validate antibot protection
const isValid = await validateAntibot();
if (!isValid) {
return;
}
if (recaptchaToken) {
try {
@@ -292,7 +317,15 @@ const ContactPage: React.FC = () => {
</h2>
</div>
<form onSubmit={handleSubmit} className="space-y-5 sm:space-y-6 md:space-y-7">
<form onSubmit={handleSubmit} className="space-y-5 sm:space-y-6 md:space-y-7 relative">
{/* Honeypot field - hidden from users */}
<HoneypotField value={honeypotValue} onChange={setHoneypotValue} />
{rateLimitInfo && !rateLimitInfo.allowed && (
<div className="bg-yellow-900/50 backdrop-blur-sm border border-yellow-500/50 text-yellow-200 px-4 py-3 rounded-lg text-sm font-light mb-4">
Too many contact form submissions. Please try again later.
</div>
)}
{}
<div>
<label htmlFor="name" className="block text-xs sm:text-sm font-medium text-gray-300 mb-2 sm:mb-3 tracking-wide">