From 6a883f4c675f2f951266d0fd355bef793aa23106 Mon Sep 17 00:00:00 2001 From: "gpt-engineer-app[bot]" <159125892+gpt-engineer-app[bot]@users.noreply.github.com> Date: Wed, 28 Jan 2026 13:06:45 +0000 Subject: [PATCH] Changes --- src/pages/Account.tsx | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/pages/Account.tsx b/src/pages/Account.tsx index 86fb260..b318be9 100644 --- a/src/pages/Account.tsx +++ b/src/pages/Account.tsx @@ -12,12 +12,14 @@ import { Save, Package } from "lucide-react"; import { useShopifyProducts } from "@/hooks/useShopifyProducts"; const profileSchema = z.object({ + company_name: z.string().trim().max(100, { message: "Företagsnamn får max vara 100 tecken" }).optional(), street_address: z.string().trim().max(200, { message: "Gatuadress får max vara 200 tecken" }).optional(), postal_code: z.string().trim().max(10, { message: "Postnummer får max vara 10 tecken" }).optional(), city: z.string().trim().max(100, { message: "Ort får max vara 100 tecken" }).optional(), }); interface ProfileData { + company_name: string; street_address: string; postal_code: string; city: string; @@ -25,11 +27,13 @@ interface ProfileData { const Account = () => { const [profile, setProfile] = useState({ + company_name: "", street_address: "", postal_code: "", city: "", }); const [originalProfile, setOriginalProfile] = useState({ + company_name: "", street_address: "", postal_code: "", city: "", @@ -42,6 +46,7 @@ const Account = () => { const { products, isLoading: productsLoading } = useShopifyProducts("product_type:Abonnemang"); const hasChanges = + profile.company_name !== originalProfile.company_name || profile.street_address !== originalProfile.street_address || profile.postal_code !== originalProfile.postal_code || profile.city !== originalProfile.city; @@ -61,7 +66,7 @@ const Account = () => { try { const { data, error } = await supabase .from("profiles") - .select("street_address, postal_code, city") + .select("company_name, street_address, postal_code, city") .eq("user_id", user!.id) .maybeSingle(); @@ -74,6 +79,7 @@ const Account = () => { }); } else if (data) { const profileData = { + company_name: data.company_name || "", street_address: data.street_address || "", postal_code: data.postal_code || "", city: data.city || "", @@ -105,6 +111,7 @@ const Account = () => { const { error } = await supabase .from("profiles") .update({ + company_name: profile.company_name || null, street_address: profile.street_address || null, postal_code: profile.postal_code || null, city: profile.city || null, @@ -183,6 +190,19 @@ const Account = () => { /> +
+ + + setProfile({ ...profile, company_name: e.target.value }) + } + placeholder="Företagsnamn" + /> +
+