From 1bbf4698fbfb0fec8a66ab62b084958e8889b0f3 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:15:47 +0000 Subject: [PATCH] Changes --- src/App.tsx | 2 + src/integrations/supabase/types.ts | 3 ++ src/pages/Account.tsx | 49 ++++++------------ src/pages/AccountConfirmation.tsx | 50 +++++++++++++++++++ ...9_1e04b3dd-4432-4067-a6d6-a5453eb26b53.sql | 3 ++ 5 files changed, 74 insertions(+), 33 deletions(-) create mode 100644 src/pages/AccountConfirmation.tsx create mode 100644 supabase/migrations/20260127231459_1e04b3dd-4432-4067-a6d6-a5453eb26b53.sql diff --git a/src/App.tsx b/src/App.tsx index c3eb6f4..78654f8 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -8,6 +8,7 @@ import NotFound from "./pages/NotFound"; import ResetPassword from "./pages/ResetPassword"; import Profile from "./pages/Profile"; import Account from "./pages/Account"; +import AccountConfirmation from "./pages/AccountConfirmation"; import { useCartSync } from "./hooks/useCartSync"; const queryClient = new QueryClient(); @@ -22,6 +23,7 @@ function AppContent() { } /> } /> } /> + } /> {/* ADD ALL CUSTOM ROUTES ABOVE THE CATCH-ALL "*" ROUTE */} } /> diff --git a/src/integrations/supabase/types.ts b/src/integrations/supabase/types.ts index e375cad..a747141 100644 --- a/src/integrations/supabase/types.ts +++ b/src/integrations/supabase/types.ts @@ -17,6 +17,7 @@ export type Database = { profiles: { Row: { address: string | null + company_name: string | null created_at: string display_name: string | null id: string @@ -26,6 +27,7 @@ export type Database = { } Insert: { address?: string | null + company_name?: string | null created_at?: string display_name?: string | null id?: string @@ -35,6 +37,7 @@ export type Database = { } Update: { address?: string | null + company_name?: string | null created_at?: string display_name?: string | null id?: string diff --git a/src/pages/Account.tsx b/src/pages/Account.tsx index a936aff..55360c8 100644 --- a/src/pages/Account.tsx +++ b/src/pages/Account.tsx @@ -12,21 +12,18 @@ import Header from "@/components/Header"; import { LogOut, Save } from "lucide-react"; 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(), + company_name: z.string().trim().max(100, { message: "Företagsnamn får max vara 100 tecken" }).optional(), address: z.string().trim().max(500, { message: "Adress får max vara 500 tecken" }).optional(), }); interface ProfileData { - display_name: string; - phone: string; + company_name: string; address: string; } const Account = () => { const [profile, setProfile] = useState({ - display_name: "", - phone: "", + company_name: "", address: "", }); const [isLoading, setIsLoading] = useState(true); @@ -50,7 +47,7 @@ const Account = () => { try { const { data, error } = await supabase .from("profiles") - .select("display_name, phone, address") + .select("company_name, address") .eq("user_id", user!.id) .maybeSingle(); @@ -63,8 +60,7 @@ const Account = () => { }); } else if (data) { setProfile({ - display_name: data.display_name || "", - phone: data.phone || "", + company_name: data.company_name || "", address: data.address || "", }); } @@ -92,8 +88,7 @@ const Account = () => { const { error } = await supabase .from("profiles") .update({ - display_name: profile.display_name || null, - phone: profile.phone || null, + company_name: profile.company_name || null, address: profile.address || null, }) .eq("user_id", user!.id); @@ -105,10 +100,8 @@ const Account = () => { variant: "destructive", }); } else { - toast({ - title: "Profil sparad!", - description: "Dina uppgifter har uppdaterats.", - }); + // Navigate to confirmation page after successful save + navigate("/account/confirmation"); } } finally { setIsSaving(false); @@ -150,29 +143,19 @@ const Account = () => {
- + - setProfile({ ...profile, display_name: e.target.value }) + setProfile({ ...profile, company_name: e.target.value }) } - placeholder="Ditt namn" - /> -
- -
- - - setProfile({ ...profile, phone: e.target.value }) - } - placeholder="070-123 45 67" + placeholder="Ditt företag eller e-postadress" /> +

+ Inloggad som: {user?.email} +

diff --git a/src/pages/AccountConfirmation.tsx b/src/pages/AccountConfirmation.tsx new file mode 100644 index 0000000..d7bf9a0 --- /dev/null +++ b/src/pages/AccountConfirmation.tsx @@ -0,0 +1,50 @@ +import { useNavigate } from "react-router-dom"; +import { Button } from "@/components/ui/button"; +import { CheckCircle } from "lucide-react"; +import Header from "@/components/Header"; + +const AccountConfirmation = () => { + const navigate = useNavigate(); + + return ( +
+
+
+
+
+
+ +
+ +

+ Uppgifter sparade! +

+ +

+ Dina kontuppgifter har sparats. Du kan nu beställa abonnemang med dessa uppgifter. +

+ +
+ + + +
+
+
+
+
+ ); +}; + +export default AccountConfirmation; diff --git a/supabase/migrations/20260127231459_1e04b3dd-4432-4067-a6d6-a5453eb26b53.sql b/supabase/migrations/20260127231459_1e04b3dd-4432-4067-a6d6-a5453eb26b53.sql new file mode 100644 index 0000000..ee8720c --- /dev/null +++ b/supabase/migrations/20260127231459_1e04b3dd-4432-4067-a6d6-a5453eb26b53.sql @@ -0,0 +1,3 @@ +-- Add company_name column to profiles table +ALTER TABLE public.profiles +ADD COLUMN company_name text; \ No newline at end of file