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:
@@ -7,7 +7,7 @@ import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import { TrendingUp, TrendingDown, Calculator, DollarSign } from "lucide-react";
|
||||
import { toast } from "sonner";
|
||||
import { clientFetch } from "@/lib/api";
|
||||
import { apiRequest } from "@/lib/api";
|
||||
|
||||
interface ProfitAnalysisModalProps {
|
||||
open: boolean;
|
||||
@@ -57,7 +57,7 @@ export const ProfitAnalysisModal: React.FC<ProfitAnalysisModalProps> = ({
|
||||
const fetchProfitAnalysis = async () => {
|
||||
try {
|
||||
setLoading(true);
|
||||
const response = await clientFetch(`/products/${productId}/profit-analysis`);
|
||||
const response = await apiRequest(`/products/${productId}/profit-analysis`);
|
||||
setProfitData(response);
|
||||
} catch (error) {
|
||||
console.error("Error fetching profit analysis:", error);
|
||||
|
||||
Reference in New Issue
Block a user