Remove name field from contact form

Removed personal name field and simplified validation to reflect business-focused contact. Updated schema to require (or remove) name, adjusted form to only collect company, email, and message. Replaced name-related inputs with company field and updated submission payload accordingly.

X-Lovable-Edit-ID: edt-b4f27375-493d-4043-a6a2-1a2a47c4c3f8
This commit is contained in:
gpt-engineer-app[bot]
2026-01-28 13:05:20 +00:00
+7 -21
View File
@@ -12,9 +12,8 @@ import { supabase } from "@/integrations/supabase/client";
import { Send, ArrowLeft } from "lucide-react"; import { Send, ArrowLeft } from "lucide-react";
const contactSchema = z.object({ const contactSchema = z.object({
name: z.string().trim().min(1, "Namn krävs").max(100, "Max 100 tecken"),
email: z.string().trim().email("Ogiltig e-postadress").max(255, "Max 255 tecken"), email: z.string().trim().email("Ogiltig e-postadress").max(255, "Max 255 tecken"),
company: z.string().trim().max(100, "Max 100 tecken").optional(), company: z.string().trim().min(1, "Företag krävs").max(100, "Max 100 tecken"),
message: z.string().trim().min(1, "Meddelande krävs").max(2000, "Max 2000 tecken"), message: z.string().trim().min(1, "Meddelande krävs").max(2000, "Max 2000 tecken"),
}); });
@@ -23,7 +22,6 @@ type ContactForm = z.infer<typeof contactSchema>;
const Contact = () => { const Contact = () => {
const navigate = useNavigate(); const navigate = useNavigate();
const [form, setForm] = useState<ContactForm>({ const [form, setForm] = useState<ContactForm>({
name: "",
email: "", email: "",
company: "", company: "",
message: "", message: "",
@@ -45,9 +43,8 @@ const Contact = () => {
try { try {
const { error } = await supabase.functions.invoke("send-contact-email", { const { error } = await supabase.functions.invoke("send-contact-email", {
body: { body: {
name: form.name,
email: form.email, email: form.email,
company: form.company || "", company: form.company,
message: form.message, message: form.message,
}, },
}); });
@@ -110,13 +107,13 @@ const Contact = () => {
) : ( ) : (
<form onSubmit={handleSubmit} className="bg-card border border-border rounded-lg p-6 md:p-8 space-y-5"> <form onSubmit={handleSubmit} className="bg-card border border-border rounded-lg p-6 md:p-8 space-y-5">
<div className="space-y-2"> <div className="space-y-2">
<Label htmlFor="name">Namn *</Label> <Label htmlFor="company">Företag *</Label>
<Input <Input
id="name" id="company"
type="text" type="text"
value={form.name} value={form.company}
onChange={(e) => setForm({ ...form, name: e.target.value })} onChange={(e) => setForm({ ...form, company: e.target.value })}
placeholder="Namn" placeholder="Företagsnamn"
required required
/> />
</div> </div>
@@ -133,17 +130,6 @@ const Contact = () => {
/> />
</div> </div>
<div className="space-y-2">
<Label htmlFor="company">Företag</Label>
<Input
id="company"
type="text"
value={form.company}
onChange={(e) => setForm({ ...form, company: e.target.value })}
placeholder="Ditt företag (valfritt)"
/>
</div>
<div className="space-y-2"> <div className="space-y-2">
<Label htmlFor="message">Meddelande *</Label> <Label htmlFor="message">Meddelande *</Label>
<Textarea <Textarea