fix type error

This commit is contained in:
hamid zarghami
2025-12-07 10:37:32 +03:30
parent 05861b3579
commit afbd680e73
2 changed files with 44 additions and 3 deletions
@@ -1,6 +1,6 @@
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
import * as api from "../service/CartService";
import type { CartResponse } from "../types/Types";
import type { CartResponse, CartItem } from "../types/Types";
export const useBulkCart = () => {
const queryClient = useQueryClient();
@@ -76,7 +76,7 @@ export const useDecrementCart = () => {
if (previousCart?.data) {
const updatedItems = previousCart.data.items
.map((item) => {
.map((item: CartItem) => {
if (item.foodId === String(id)) {
const newQuantity = item.quantity - 1;
if (newQuantity <= 0) {
@@ -89,7 +89,7 @@ export const useDecrementCart = () => {
}
return item;
})
.filter((item): item is NonNullable<typeof item> => item !== null);
.filter((item: CartItem | null): item is CartItem => item !== null);
queryClient.setQueryData<CartResponse>(["cart-items"], {
...previousCart,