bug fix
This commit is contained in:
@@ -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'), {
|
||||
|
||||
@@ -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 = () => {
|
||||
<Avatar className="w-14 h-14 ring-2 ring-emerald-500 ring-offset-2 flex items-center justify-center">
|
||||
<AvatarImage />
|
||||
<AvatarFallback className="text-muted-foreground font-semibold">
|
||||
{user?.slice(0, 1).toUpperCase()}
|
||||
{user?.username.slice(0, 1).toUpperCase()}
|
||||
</AvatarFallback>
|
||||
</Avatar>
|
||||
<div>
|
||||
<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>
|
||||
</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">
|
||||
<AvatarImage />
|
||||
<AvatarFallback className="text-muted-foreground font-semibold">
|
||||
{user?.slice(0, 1).toUpperCase()}
|
||||
{user?.username?.slice(0, 1).toUpperCase()}
|
||||
</AvatarFallback>
|
||||
</Avatar>
|
||||
<div>
|
||||
<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>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user