diff --git a/src/features/auth/ui/Login.tsx b/src/features/auth/ui/Login.tsx
index d60d8fb..bb6c28c 100644
--- a/src/features/auth/ui/Login.tsx
+++ b/src/features/auth/ui/Login.tsx
@@ -46,6 +46,7 @@ const Login = () => {
setUser(form.getValues('username'));
router.push('/');
queryClient.refetchQueries({ queryKey: ['product_list'] });
+ queryClient.refetchQueries({ queryKey: ['get_me'] });
},
onError: () => {
toast.error(t('Username yoki parol xato kiritildi'), {
diff --git a/src/features/profile/ui/Profile.tsx b/src/features/profile/ui/Profile.tsx
index afede84..247cd29 100644
--- a/src/features/profile/ui/Profile.tsx
+++ b/src/features/profile/ui/Profile.tsx
@@ -2,13 +2,14 @@
import { useRouter } from '@/shared/config/i18n/navigation';
import { useCartId } from '@/shared/hooks/cartId';
-import { getMe, removeToken } from '@/shared/lib/token';
+import { removeToken } from '@/shared/lib/token';
import { Avatar, AvatarFallback, AvatarImage } from '@/shared/ui/avatar';
import { Button } from '@/shared/ui/button';
+import { userStore } from '@/widgets/welcome/lib/hook';
import { useQueryClient } from '@tanstack/react-query';
import { Headset, Home, LogOut } from 'lucide-react';
import { useTranslations } from 'next-intl';
-import { useState } from 'react';
+import { useEffect, useState } from 'react';
import HistoryTabs from './History';
const Profile = () => {
@@ -16,9 +17,15 @@ const Profile = () => {
const router = useRouter();
const t = useTranslations();
const queryClient = useQueryClient();
- const user = getMe();
+ const { user } = userStore();
const { setCartId } = useCartId();
+ useEffect(() => {
+ if (user === null) {
+ router.replace('/auth');
+ }
+ }, [user]);
+
const menuItems = [
{ id: 'overview', label: 'Umumiy', icon: Home },
{ id: 'support', label: "Qo'llab-quvatlash", icon: Headset },
@@ -66,12 +73,14 @@ const Profile = () => {
- {user && user.charAt(0).toUpperCase() + user.slice(1)} + {user && + user.username.charAt(0).toUpperCase() + + user.username.slice(1)}
- {user && user.charAt(0).toUpperCase() + user.slice(1)} + {user && + user.username.charAt(0).toUpperCase() + + user.username.slice(1)}