From 53fda6cd7e0b4b3cbf9aeb080c26a1b8d6749755 Mon Sep 17 00:00:00 2001 From: "gpt-engineer-app[bot]" <159125892+gpt-engineer-app[bot]@users.noreply.github.com> Date: Tue, 27 Jan 2026 23:19:36 +0000 Subject: [PATCH] Changes --- src/integrations/supabase/types.ts | 9 +++ src/pages/Account.tsx | 76 ++++++++++++++----- ...0_c9658ecd-aa9d-40bb-84de-5729d1fd6e20.sql | 5 ++ 3 files changed, 71 insertions(+), 19 deletions(-) create mode 100644 supabase/migrations/20260127231900_c9658ecd-aa9d-40bb-84de-5729d1fd6e20.sql diff --git a/src/integrations/supabase/types.ts b/src/integrations/supabase/types.ts index a747141..9022231 100644 --- a/src/integrations/supabase/types.ts +++ b/src/integrations/supabase/types.ts @@ -17,31 +17,40 @@ export type Database = { profiles: { Row: { address: string | null + city: string | null company_name: string | null created_at: string display_name: string | null id: string phone: string | null + postal_code: string | null + street_address: string | null updated_at: string user_id: string } Insert: { address?: string | null + city?: string | null company_name?: string | null created_at?: string display_name?: string | null id?: string phone?: string | null + postal_code?: string | null + street_address?: string | null updated_at?: string user_id: string } Update: { address?: string | null + city?: string | null company_name?: string | null created_at?: string display_name?: string | null id?: string phone?: string | null + postal_code?: string | null + street_address?: string | null updated_at?: string user_id?: string } diff --git a/src/pages/Account.tsx b/src/pages/Account.tsx index 44f4798..49ae6fc 100644 --- a/src/pages/Account.tsx +++ b/src/pages/Account.tsx @@ -4,24 +4,29 @@ import { z } from "zod"; import { Button } from "@/components/ui/button"; import { Input } from "@/components/ui/input"; import { Label } from "@/components/ui/label"; -import { Textarea } from "@/components/ui/textarea"; import { useAuth } from "@/hooks/useAuth"; import { useToast } from "@/hooks/use-toast"; import { supabase } from "@/integrations/supabase/client"; import Header from "@/components/Header"; -import { LogOut, Save } from "lucide-react"; +import { Save } from "lucide-react"; const profileSchema = z.object({ - address: z.string().trim().max(500, { message: "Adress får max vara 500 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 { - address: string; + street_address: string; + postal_code: string; + city: string; } const Account = () => { const [profile, setProfile] = useState({ - address: "", + street_address: "", + postal_code: "", + city: "", }); const [isLoading, setIsLoading] = useState(true); const [isSaving, setIsSaving] = useState(false); @@ -44,7 +49,7 @@ const Account = () => { try { const { data, error } = await supabase .from("profiles") - .select("address") + .select("street_address, postal_code, city") .eq("user_id", user!.id) .maybeSingle(); @@ -57,7 +62,9 @@ const Account = () => { }); } else if (data) { setProfile({ - address: data.address || "", + street_address: data.street_address || "", + postal_code: data.postal_code || "", + city: data.city || "", }); } } finally { @@ -84,7 +91,9 @@ const Account = () => { const { error } = await supabase .from("profiles") .update({ - address: profile.address || null, + street_address: profile.street_address || null, + postal_code: profile.postal_code || null, + city: profile.city || null, }) .eq("user_id", user!.id); @@ -159,17 +168,46 @@ const Account = () => { /> -
- -