Remove personal name fields
Eliminated all personal-name fields from checkout/forms: - AbonnemangForm: removed kontaktperson; stop syncing to profiles - Profile pages: removed display_name; profile fetch/update adjusted - Updated checkout data flow to require only company information for business customers X-Lovable-Edit-ID: edt-8f8c2c0e-9e3f-4fe5-b636-5d6de99afb59
This commit is contained in:
@@ -5,7 +5,6 @@ import { supabase } from "@/integrations/supabase/client";
|
||||
|
||||
const formSchema = z.object({
|
||||
företag: z.string().trim().min(1, "Fyll i företagsnamn").max(100),
|
||||
kontaktperson: z.string().trim().max(100).optional(),
|
||||
epost: z.string().trim().email("Ange en giltig e-postadress").max(255),
|
||||
telefon: z.string().trim().max(20).optional(),
|
||||
adress: z.string().trim().max(200).optional(),
|
||||
@@ -24,7 +23,6 @@ const AbonnemangForm = ({ selectedPlan, onClose }: AbonnemangFormProps) => {
|
||||
const { user } = useAuth();
|
||||
const [formData, setFormData] = useState({
|
||||
företag: "",
|
||||
kontaktperson: "",
|
||||
epost: "",
|
||||
telefon: "",
|
||||
adress: "",
|
||||
@@ -50,14 +48,11 @@ const AbonnemangForm = ({ selectedPlan, onClose }: AbonnemangFormProps) => {
|
||||
if (data) {
|
||||
setFormData((prev) => ({
|
||||
...prev,
|
||||
kontaktperson: data.display_name || prev.kontaktperson,
|
||||
telefon: data.phone || prev.telefon,
|
||||
epost: user.email || prev.epost,
|
||||
// Parse address if it exists (format: "gatuadress, postnummer ort")
|
||||
adress: data.address?.split(",")[0]?.trim() || prev.adress,
|
||||
}));
|
||||
} else {
|
||||
// At least fill in email
|
||||
setFormData((prev) => ({
|
||||
...prev,
|
||||
epost: user.email || prev.epost,
|
||||
@@ -98,7 +93,6 @@ const AbonnemangForm = ({ selectedPlan, onClose }: AbonnemangFormProps) => {
|
||||
.update({
|
||||
address: fullAddress,
|
||||
phone: formData.telefon || null,
|
||||
display_name: formData.kontaktperson || null,
|
||||
})
|
||||
.eq("user_id", user.id);
|
||||
}
|
||||
@@ -176,20 +170,6 @@ const AbonnemangForm = ({ selectedPlan, onClose }: AbonnemangFormProps) => {
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* Kontaktperson */}
|
||||
<div>
|
||||
<label className="block mb-2 font-semibold text-foreground">
|
||||
Kontaktperson
|
||||
</label>
|
||||
<input
|
||||
type="text"
|
||||
name="kontaktperson"
|
||||
value={formData.kontaktperson}
|
||||
onChange={handleChange}
|
||||
className="w-full px-4 py-3 rounded-sm bg-background border border-border text-foreground focus:outline-none focus:ring-2 focus:ring-primary/30"
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* E-post & Telefon */}
|
||||
<div className="grid grid-cols-1 md:grid-cols-2 gap-4">
|
||||
<div>
|
||||
|
||||
+1
-19
@@ -11,20 +11,17 @@ import { supabase } from "@/integrations/supabase/client";
|
||||
import Header from "@/components/Header";
|
||||
|
||||
const profileSchema = z.object({
|
||||
display_name: z.string().trim().max(100, { message: "Namn får max vara 100 tecken" }).optional(),
|
||||
phone: z.string().trim().max(20, { message: "Telefonnummer får max vara 20 tecken" }).optional(),
|
||||
address: z.string().trim().max(500, { message: "Adress får max vara 500 tecken" }).optional(),
|
||||
});
|
||||
|
||||
interface ProfileData {
|
||||
display_name: string;
|
||||
phone: string;
|
||||
address: string;
|
||||
}
|
||||
|
||||
const Profile = () => {
|
||||
const [profile, setProfile] = useState<ProfileData>({
|
||||
display_name: "",
|
||||
phone: "",
|
||||
address: "",
|
||||
});
|
||||
@@ -49,7 +46,7 @@ const Profile = () => {
|
||||
try {
|
||||
const { data, error } = await supabase
|
||||
.from("profiles")
|
||||
.select("display_name, phone, address")
|
||||
.select("phone, address")
|
||||
.eq("user_id", user!.id)
|
||||
.maybeSingle();
|
||||
|
||||
@@ -62,7 +59,6 @@ const Profile = () => {
|
||||
});
|
||||
} else if (data) {
|
||||
setProfile({
|
||||
display_name: data.display_name || "",
|
||||
phone: data.phone || "",
|
||||
address: data.address || "",
|
||||
});
|
||||
@@ -91,7 +87,6 @@ const Profile = () => {
|
||||
const { error } = await supabase
|
||||
.from("profiles")
|
||||
.update({
|
||||
display_name: profile.display_name || null,
|
||||
phone: profile.phone || null,
|
||||
address: profile.address || null,
|
||||
})
|
||||
@@ -137,19 +132,6 @@ const Profile = () => {
|
||||
</p>
|
||||
|
||||
<form onSubmit={handleSubmit} className="space-y-4">
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="display_name">Namn</Label>
|
||||
<Input
|
||||
id="display_name"
|
||||
type="text"
|
||||
value={profile.display_name}
|
||||
onChange={(e) =>
|
||||
setProfile({ ...profile, display_name: e.target.value })
|
||||
}
|
||||
placeholder="Ditt namn"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="phone">Telefon</Label>
|
||||
<Input
|
||||
|
||||
Reference in New Issue
Block a user