fix: sync db schema via prisma db push, add suppressHydrationWarning, and handle 401 profile errors gracefully

This commit is contained in:
parsa aghaei 2026-07-26 19:46:36 +03:30
parent 73e26d8f12
commit abf22cc18d
3 changed files with 10 additions and 3 deletions

View File

@ -69,8 +69,8 @@ export default function RootLayout({
};
return (
<html lang="fa" dir="rtl">
<body className="min-h-screen bg-medical-gray-50 font-sans">
<html lang="fa" dir="rtl" suppressHydrationWarning>
<body className="min-h-screen bg-medical-gray-50 font-sans" suppressHydrationWarning>
<script
type="application/ld+json"
dangerouslySetInnerHTML={{ __html: JSON.stringify(jsonLd) }}

View File

@ -102,11 +102,14 @@ export class AuthService {
/**
* Get current user profile
*/
public async getProfile(): Promise<User> {
public async getProfile(): Promise<User | null> {
try {
const response = await api.get('/users/profile');
return response.data;
} catch (error: any) {
if (error.response?.status === 401 || error.response?.status === 403) {
return null;
}
const message = error.response?.data?.message || 'خطا در دریافت اطلاعات کاربری';
throw new Error(Array.isArray(message) ? message[0] : message);
}

View File

@ -155,6 +155,10 @@ export const useUserStore = create<UserStore>()(
fetchProfile: async () => {
try {
const profileData = await authService.getProfile();
if (!profileData) {
set({ isLoggedIn: false, role: "User_Guest" });
return;
}
set((state) => {
const backendWallet = Number(profileData.walletBalance || 0);
const backendCharity = Number(profileData.charityDonationTotal || 0);