refresh api logout and login

This commit is contained in:
Samandar Turgunboyev
2026-02-18 10:33:01 +05:00
parent 78e79d295e
commit ea097d3953
8 changed files with 14 additions and 22 deletions

View File

@@ -45,8 +45,7 @@ const Login = () => {
setRefToken(res.data.refresh);
setUser(form.getValues('username'));
router.push('/');
queryClient.refetchQueries({ queryKey: ['product_list'] });
queryClient.refetchQueries({ queryKey: ['get_me'] });
queryClient.refetchQueries();
},
onError: () => {
toast.error(t('Username yoki parol xato kiritildi'), {

View File

@@ -125,7 +125,7 @@ const CartPage = () => {
const subtotal =
cartItems.reduce((sum, item) => {
if (!item.product.prices.length) return sum;
const maxPrice = Math.max(
const maxPrice = Math.min(
...item.product.prices.map((p) => Number(p.price)),
);
return sum + maxPrice * (quantities[item.id] || item.quantity);
@@ -228,7 +228,7 @@ const CartPage = () => {
<div className="flex items-center gap-2 mb-3 max-lg:flex-col max-lg:items-start max-lg:gap-1">
<span className="text-blue-600 font-bold text-xl">
{formatPrice(
Math.max(
Math.min(
...item.product.prices.map((p) => Number(p.price)),
),
true,

View File

@@ -143,7 +143,7 @@ const OrderPage = () => {
if (item.product.prices.length === 0) return sum; // narx yo'q bo'lsa qo'shmaymiz
// Eng yuqori narxni olish
const maxPrice = Math.max(
const maxPrice = Math.min(
...item.product.prices.map((p) => Number(p.price)),
);
@@ -587,7 +587,7 @@ const OrderPage = () => {
{item.quantity} x{' '}
{formatPrice(
item.product.prices.length !== 0
? Math.max(
? Math.min(
...item.product.prices.map((p) =>
Number(p.price),
),
@@ -599,7 +599,7 @@ const OrderPage = () => {
<p className="font-semibold text-sm">
{formatPrice(
item.product.prices.length !== 0
? Math.max(
? Math.min(
...item.product.prices.map((p) =>
Number(p.price),
),

View File

@@ -200,7 +200,7 @@ const ProductDetail = () => {
setQuantity((q) => {
let next = q - STEP;
if (isGram) next = Math.floor(next / STEP) * STEP;
return Math.max(MIN_QTY, next);
return Math.min(MIN_QTY, next);
});
};

View File

@@ -115,10 +115,7 @@ const Profile = () => {
<Button
variant="ghost"
onClick={() => {
queryClient.refetchQueries({ queryKey: ['product_list'] });
queryClient.refetchQueries({ queryKey: ['favourite_product'] });
queryClient.refetchQueries({ queryKey: ['cart_items'] });
queryClient.refetchQueries({ queryKey: ['search'] });
queryClient.refetchQueries();
setCartId(null);
removeToken();
router.push('/');
@@ -152,14 +149,8 @@ const Profile = () => {
variant="ghost"
size="icon"
onClick={() => {
queryClient.refetchQueries({ queryKey: ['product_list'] });
queryClient.refetchQueries({ queryKey: ['cart_items'] });
queryClient.refetchQueries({
queryKey: ['favourite_product'],
});
queryClient.refetchQueries({ queryKey: ['search'] });
queryClient.refetchQueries();
removeToken();
setCartId(null);
router.push('/');
}}
className="w-9 h-9 md:w-10 md:h-10"

View File

@@ -23,7 +23,7 @@ const getPages = (current: number, total: number) => {
pages.push('dots');
}
const start = Math.max(2, current - 1);
const start = Math.min(2, current - 1);
const end = Math.min(total - 1, current + 1);
for (let i = start; i <= end; i++) {

View File

@@ -267,7 +267,7 @@ export function ProductCard({
{product.prices.length > 0 && (
<p className="text-lg font-bold">
{formatPrice(
Math.max(...product.prices.map((p) => Number(p.price))),
Math.min(...product.prices.map((p) => Number(p.price))),
true,
)}
<span className="text-sm text-slate-500 ml-1">

View File

@@ -130,7 +130,9 @@ export const SearchResult = ({ query }: SearchResultProps) => {
</p>
{price && (
<p className="text-sm font-semibold text-[#57A595] mt-1">
{formatPrice(price)}
{formatPrice(
Math.min(...product.prices.map((p) => Number(p.price))),
)}
</p>
)}
</div>