mirror of
http://88.130.71.182:3000/BlitTech/badoHair_fe.git
synced 2026-06-13 11:03:02 +00:00
changes after second dev test
fixed full name issue, refresh issue on reservation and user/admin login issue
This commit is contained in:
@@ -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"));
|
||||
|
||||
Reference in New Issue
Block a user