diff --git a/src/pages/Account.tsx b/src/pages/Account.tsx index a487208..985dff6 100644 --- a/src/pages/Account.tsx +++ b/src/pages/Account.tsx @@ -105,7 +105,7 @@ const Account = () => { }); } else { // Navigate to confirmation page after successful save - navigate("/account/confirmation"); + navigate("/account/confirmation", { state: { justSaved: true } }); } } finally { setIsSaving(false); diff --git a/src/pages/AccountConfirmation.tsx b/src/pages/AccountConfirmation.tsx index cd8a9fa..619df3e 100644 --- a/src/pages/AccountConfirmation.tsx +++ b/src/pages/AccountConfirmation.tsx @@ -1,7 +1,7 @@ import { useState, useEffect } from "react"; -import { useNavigate } from "react-router-dom"; +import { useNavigate, useLocation } from "react-router-dom"; import { Button } from "@/components/ui/button"; -import { CheckCircle, Package } from "lucide-react"; +import { CheckCircle, Package, User } from "lucide-react"; import Header from "@/components/Header"; import { useAuth } from "@/hooks/useAuth"; import { supabase } from "@/integrations/supabase/client"; @@ -14,10 +14,14 @@ interface ProfileData { const AccountConfirmation = () => { const navigate = useNavigate(); + const location = useLocation(); const { user, loading: authLoading } = useAuth(); const [profile, setProfile] = useState(null); const [isLoading, setIsLoading] = useState(true); + // Check if user just saved their profile + const justSaved = location.state?.justSaved === true; + useEffect(() => { if (!authLoading && !user) { navigate("/"); @@ -60,6 +64,8 @@ const AccountConfirmation = () => { ); } + const hasAddress = profile && (profile.street_address || profile.postal_code || profile.city); + return (
@@ -68,29 +74,40 @@ const AccountConfirmation = () => {
- {/* Success message */} + {/* Header section */}
- + {justSaved ? ( + + ) : ( + + )}

- Uppgifter sparade! + {justSaved ? "Uppgifter sparade!" : "Mitt konto"}

-

- Dina kontuppgifter har uppdaterats. -

+ {justSaved && ( +

+ Dina kontuppgifter har uppdaterats. +

+ )} + {!justSaved && user?.email && ( +

+ {user.email} +

+ )}
- {profile && (profile.street_address || profile.postal_code || profile.city) && ( + {hasAddress && (

Leveransadress:

@@ -101,6 +118,16 @@ const AccountConfirmation = () => {

)} + +
+ +
{/* Subscription status */} @@ -131,24 +158,6 @@ const AccountConfirmation = () => { Beställ abonnemang
- - {/* Actions */} -
- - -