refresh api logout and login
This commit is contained in:
@@ -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'), {
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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),
|
||||
),
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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++) {
|
||||
|
||||
@@ -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">
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user