Skip to content

Commit 3e8cc95

Browse files
committed
feat: improve contact form field order and remove LinkedIn
- Reorder employment fields: workplace first, then job title - Update field labels: 'Your workplace' and 'Your job' instead of 'Current Workplace' and 'Occupation' - Remove LinkedIn profile field from form completely - Update email templates to remove LinkedIn references - Clean up unused Linkedin import - Fix body scroll issue when form is open - Prevent background page scrolling when contact form is active - Store and restore scroll position when form opens/closes - Use fixed positioning to lock body scroll during form interaction
1 parent 1a62b50 commit 3e8cc95

File tree

1 file changed

+48
-43
lines changed

1 file changed

+48
-43
lines changed

src/components/ui/ContactForm.tsx

Lines changed: 48 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
'use client';
22

3-
import { useState } from 'react';
3+
import { useState, useEffect } from 'react';
44
import { motion, AnimatePresence } from 'framer-motion';
5-
import { X, Send, User, Mail, Briefcase, Linkedin, Building, Check, AlertCircle } from 'lucide-react';
5+
import { X, Send, User, Mail, Briefcase, Building, Check, AlertCircle } from 'lucide-react';
66
import emailjs from '@emailjs/browser';
77
import { useContactForm } from '@/contexts/ContactFormContext';
88

@@ -12,7 +12,6 @@ const ContactForm = () => {
1212
name: '',
1313
email: '',
1414
occupation: '',
15-
linkedin: '',
1615
employmentStatus: '', // 'yes', 'no', 'student', or empty
1716
workplace: '',
1817
discussion: '',
@@ -21,6 +20,29 @@ const ContactForm = () => {
2120
const [isSubmitted, setIsSubmitted] = useState(false);
2221
const [error, setError] = useState('');
2322

23+
// Prevent body scroll when form is open
24+
useEffect(() => {
25+
if (isFormOpen) {
26+
// Store the current scroll position
27+
const scrollY = window.scrollY;
28+
29+
// Disable body scroll
30+
document.body.style.position = 'fixed';
31+
document.body.style.top = `-${scrollY}px`;
32+
document.body.style.width = '100%';
33+
34+
return () => {
35+
// Re-enable body scroll
36+
document.body.style.position = '';
37+
document.body.style.top = '';
38+
document.body.style.width = '';
39+
40+
// Restore scroll position
41+
window.scrollTo(0, scrollY);
42+
};
43+
}
44+
}, [isFormOpen]);
45+
2446
const handleInputChange = (e: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => {
2547
const { name, value } = e.target;
2648
setFormData(prev => ({
@@ -51,16 +73,15 @@ const ContactForm = () => {
5173
// Use EmailJS for direct email sending
5274
emailjs.init(emailjsPublicKey);
5375

54-
const templateParams = {
55-
from_name: formData.name,
56-
from_email: formData.email,
57-
occupation: formData.occupation,
58-
linkedin: formData.linkedin || 'Not provided',
59-
employment_status: formData.employmentStatus === 'yes' ? 'Yes, employed' : formData.employmentStatus === 'no' ? 'No, not employed' : 'Student',
60-
workplace: formData.employmentStatus === 'yes' ? formData.workplace : '',
61-
message: formData.discussion,
62-
to_email: 'max@buzzvil.com'
63-
};
76+
const templateParams = {
77+
from_name: formData.name,
78+
from_email: formData.email,
79+
occupation: formData.occupation,
80+
employment_status: formData.employmentStatus === 'yes' ? 'Yes, employed' : formData.employmentStatus === 'no' ? 'No, not employed' : 'Student',
81+
workplace: formData.employmentStatus === 'yes' ? formData.workplace : '',
82+
message: formData.discussion,
83+
to_email: 'max@buzzvil.com'
84+
};
6485

6586
const result = await emailjs.send(
6687
process.env.NEXT_PUBLIC_EMAILJS_SERVICE_ID!,
@@ -87,12 +108,12 @@ New Coffee Chat Request
87108
=== About You ===
88109
Name: ${formData.name}
89110
Email: ${formData.email}
90-
Occupation: ${formData.occupation}
91-
LinkedIn: ${formData.linkedin || 'Not provided'}
92111
93112
=== Current Status ===
94113
Employment Status: ${formData.employmentStatus === 'yes' ? 'Yes, employed' : formData.employmentStatus === 'no' ? 'No, not employed' : 'Student'}
95-
${formData.employmentStatus === 'yes' ? `Current Workplace: ${formData.workplace}` : ''}
114+
${formData.employmentStatus === 'yes' ? `Job: ${formData.occupation}` : ''}
115+
${formData.employmentStatus === 'student' ? `Study Field: ${formData.occupation}` : ''}
116+
${formData.employmentStatus === 'yes' ? `Workplace: ${formData.workplace}` : ''}
96117
97118
=== Discussion Topic ===
98119
What would you like to discuss:
@@ -122,7 +143,6 @@ ${formData.discussion}
122143
name: '',
123144
email: '',
124145
occupation: '',
125-
linkedin: '',
126146
employmentStatus: '',
127147
workplace: '',
128148
discussion: '',
@@ -219,21 +239,6 @@ ${formData.discussion}
219239
/>
220240
</div>
221241

222-
{/* LinkedIn */}
223-
<div className="lg:col-span-2">
224-
<label className="block text-sm font-medium text-white mb-2">
225-
<Linkedin className="w-4 h-4 inline mr-2" />
226-
LinkedIn Profile
227-
</label>
228-
<input
229-
type="url"
230-
name="linkedin"
231-
value={formData.linkedin}
232-
onChange={handleInputChange}
233-
className="w-full px-4 py-3 bg-white/10 border border-white/20 rounded-lg focus:ring-2 focus:ring-white/50 focus:border-transparent transition-all text-white placeholder-white/70"
234-
placeholder="https://linkedin.com/in/yourname"
235-
/>
236-
</div>
237242
</div>
238243
</div>
239244

@@ -300,38 +305,38 @@ ${formData.discussion}
300305
</div>
301306
</div>
302307

303-
{/* Occupation and Workplace - only show if employed */}
308+
{/* Workplace and Job - only show if employed */}
304309
{formData.employmentStatus === 'yes' && (
305310
<div className="grid grid-cols-1 lg:grid-cols-2 gap-4">
306311
<div>
307312
<label className="block text-sm font-medium text-white mb-2">
308-
<Briefcase className="w-4 h-4 inline mr-2" />
309-
Occupation *
313+
<Building className="w-4 h-4 inline mr-2" />
314+
Your workplace *
310315
</label>
311316
<input
312317
type="text"
313-
name="occupation"
314-
value={formData.occupation}
318+
name="workplace"
319+
value={formData.workplace}
315320
onChange={handleInputChange}
316321
required
317322
className="w-full px-4 py-3 bg-white/10 border border-white/20 rounded-lg focus:ring-2 focus:ring-white/50 focus:border-transparent transition-all text-white placeholder-white/70"
318-
placeholder="e.g., Product Designer, UX Researcher, Developer"
323+
placeholder="Your current company or organization"
319324
/>
320325
</div>
321326

322327
<div>
323328
<label className="block text-sm font-medium text-white mb-2">
324-
<Building className="w-4 h-4 inline mr-2" />
325-
Current Workplace *
329+
<Briefcase className="w-4 h-4 inline mr-2" />
330+
Your job *
326331
</label>
327332
<input
328333
type="text"
329-
name="workplace"
330-
value={formData.workplace}
334+
name="occupation"
335+
value={formData.occupation}
331336
onChange={handleInputChange}
332337
required
333338
className="w-full px-4 py-3 bg-white/10 border border-white/20 rounded-lg focus:ring-2 focus:ring-white/50 focus:border-transparent transition-all text-white placeholder-white/70"
334-
placeholder="Your current company or organization"
339+
placeholder="e.g., Product Designer, UX Researcher, Developer"
335340
/>
336341
</div>
337342
</div>

0 commit comments

Comments
 (0)