Refactor API calls to use apiRequest instead of clientFetch
Replaces all usages of clientFetch with the new apiRequest utility across dashboard pages, modal components, and the profit analytics service. This standardizes API interaction and improves consistency in request handling.
This commit is contained in:
@@ -6,7 +6,7 @@ import { Input } from "@/components/ui/input";
|
||||
import { Checkbox } from "@/components/ui/checkbox";
|
||||
import { ScrollArea } from "@/components/ui/scroll-area";
|
||||
import { Search, Package } from "lucide-react";
|
||||
import { clientFetch } from "@/lib/api";
|
||||
import { apiRequest } from "@/lib/api";
|
||||
|
||||
interface Product {
|
||||
_id: string;
|
||||
@@ -30,7 +30,7 @@ export default function ProductSelector({ selectedProducts, onSelectionChange }:
|
||||
useEffect(() => {
|
||||
const fetchProducts = async () => {
|
||||
try {
|
||||
const fetchedProducts = await clientFetch('/products/for-selection');
|
||||
const fetchedProducts = await apiRequest('/products/for-selection', 'GET');
|
||||
setProducts(fetchedProducts);
|
||||
} catch (error) {
|
||||
console.error('Error fetching products:', error);
|
||||
|
||||
Reference in New Issue
Block a user