Changes
This commit is contained in:
+7
-21
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user