changes after second dev test

fixed full name issue, refresh issue on reservation and user/admin login issue
This commit is contained in:
belviskhoremk
2026-05-27 23:04:32 +00:00
parent 209ac114b0
commit 53365b9dbf
7 changed files with 60 additions and 27 deletions

View File

@@ -18,7 +18,7 @@ import { toast } from "sonner";
import { User, CalendarDays, ShoppingBag, X } from "lucide-react";
export default function MonCompte() {
const { user, isLoading } = useAuth();
const { user, isLoading, refreshUser } = useAuth();
const { t, locale } = useLanguage();
const router = useRouter();
@@ -39,6 +39,12 @@ export default function MonCompte() {
if (!isLoading && user?.role === "admin") router.replace("/admin");
}, [user, isLoading, router]);
// Refresh profile from server on mount to get the latest full_name
useEffect(() => {
if (user) refreshUser().catch(() => {});
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
useEffect(() => {
if (user) {
startTransition(() => {
@@ -65,6 +71,7 @@ export default function MonCompte() {
setSavingProfile(true);
try {
await updateProfile(name, phone || null);
await refreshUser();
toast.success(t("account.profile_saved"));
} catch (err) {
toast.error(err instanceof ApiError ? err.message : t("auth.error"));