bug fix
This commit is contained in:
@@ -46,6 +46,7 @@ const Login = () => {
|
|||||||
setUser(form.getValues('username'));
|
setUser(form.getValues('username'));
|
||||||
router.push('/');
|
router.push('/');
|
||||||
queryClient.refetchQueries({ queryKey: ['product_list'] });
|
queryClient.refetchQueries({ queryKey: ['product_list'] });
|
||||||
|
queryClient.refetchQueries({ queryKey: ['get_me'] });
|
||||||
},
|
},
|
||||||
onError: () => {
|
onError: () => {
|
||||||
toast.error(t('Username yoki parol xato kiritildi'), {
|
toast.error(t('Username yoki parol xato kiritildi'), {
|
||||||
|
|||||||
@@ -2,13 +2,14 @@
|
|||||||
|
|
||||||
import { useRouter } from '@/shared/config/i18n/navigation';
|
import { useRouter } from '@/shared/config/i18n/navigation';
|
||||||
import { useCartId } from '@/shared/hooks/cartId';
|
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 { Avatar, AvatarFallback, AvatarImage } from '@/shared/ui/avatar';
|
||||||
import { Button } from '@/shared/ui/button';
|
import { Button } from '@/shared/ui/button';
|
||||||
|
import { userStore } from '@/widgets/welcome/lib/hook';
|
||||||
import { useQueryClient } from '@tanstack/react-query';
|
import { useQueryClient } from '@tanstack/react-query';
|
||||||
import { Headset, Home, LogOut } from 'lucide-react';
|
import { Headset, Home, LogOut } from 'lucide-react';
|
||||||
import { useTranslations } from 'next-intl';
|
import { useTranslations } from 'next-intl';
|
||||||
import { useState } from 'react';
|
import { useEffect, useState } from 'react';
|
||||||
import HistoryTabs from './History';
|
import HistoryTabs from './History';
|
||||||
|
|
||||||
const Profile = () => {
|
const Profile = () => {
|
||||||
@@ -16,9 +17,15 @@ const Profile = () => {
|
|||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const t = useTranslations();
|
const t = useTranslations();
|
||||||
const queryClient = useQueryClient();
|
const queryClient = useQueryClient();
|
||||||
const user = getMe();
|
const { user } = userStore();
|
||||||
const { setCartId } = useCartId();
|
const { setCartId } = useCartId();
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (user === null) {
|
||||||
|
router.replace('/auth');
|
||||||
|
}
|
||||||
|
}, [user]);
|
||||||
|
|
||||||
const menuItems = [
|
const menuItems = [
|
||||||
{ id: 'overview', label: 'Umumiy', icon: Home },
|
{ id: 'overview', label: 'Umumiy', icon: Home },
|
||||||
{ id: 'support', label: "Qo'llab-quvatlash", icon: Headset },
|
{ id: 'support', label: "Qo'llab-quvatlash", icon: Headset },
|
||||||
@@ -66,12 +73,14 @@ const Profile = () => {
|
|||||||
<Avatar className="w-14 h-14 ring-2 ring-emerald-500 ring-offset-2 flex items-center justify-center">
|
<Avatar className="w-14 h-14 ring-2 ring-emerald-500 ring-offset-2 flex items-center justify-center">
|
||||||
<AvatarImage />
|
<AvatarImage />
|
||||||
<AvatarFallback className="text-muted-foreground font-semibold">
|
<AvatarFallback className="text-muted-foreground font-semibold">
|
||||||
{user?.slice(0, 1).toUpperCase()}
|
{user?.username.slice(0, 1).toUpperCase()}
|
||||||
</AvatarFallback>
|
</AvatarFallback>
|
||||||
</Avatar>
|
</Avatar>
|
||||||
<div>
|
<div>
|
||||||
<p className="text-lg text-muted-foreground font-medium">
|
<p className="text-lg text-muted-foreground font-medium">
|
||||||
{user && user.charAt(0).toUpperCase() + user.slice(1)}
|
{user &&
|
||||||
|
user.username.charAt(0).toUpperCase() +
|
||||||
|
user.username.slice(1)}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -120,12 +129,14 @@ const Profile = () => {
|
|||||||
<Avatar className="w-10 h-10 md:w-12 md:h-12 ring-2 ring-emerald-500 ring-offset-2">
|
<Avatar className="w-10 h-10 md:w-12 md:h-12 ring-2 ring-emerald-500 ring-offset-2">
|
||||||
<AvatarImage />
|
<AvatarImage />
|
||||||
<AvatarFallback className="text-muted-foreground font-semibold">
|
<AvatarFallback className="text-muted-foreground font-semibold">
|
||||||
{user?.slice(0, 1).toUpperCase()}
|
{user?.username?.slice(0, 1).toUpperCase()}
|
||||||
</AvatarFallback>
|
</AvatarFallback>
|
||||||
</Avatar>
|
</Avatar>
|
||||||
<div>
|
<div>
|
||||||
<p className="text-md md:text-xl text-muted-foreground">
|
<p className="text-md md:text-xl text-muted-foreground">
|
||||||
{user && user.charAt(0).toUpperCase() + user.slice(1)}
|
{user &&
|
||||||
|
user.username.charAt(0).toUpperCase() +
|
||||||
|
user.username.slice(1)}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user