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 { Button } from "@/components/ui/button";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { Textarea } from "@/components/ui/textarea";
|
||||
import { Save, Send, Key, MessageSquare, Shield, Globe, Wallet } from "lucide-react";
|
||||
import { clientFetch } from "@/lib/api";
|
||||
import { apiRequest } from "@/lib/api";
|
||||
import { toast } from "sonner";
|
||||
import BroadcastDialog from "@/components/modals/broadcast-dialog";
|
||||
import Dashboard from "@/components/dashboard/dashboard";
|
||||
@@ -115,7 +115,7 @@ export default function StorefrontPage() {
|
||||
const fetchStorefront = async () => {
|
||||
try {
|
||||
setLoading(true);
|
||||
const data = await clientFetch("/storefront");
|
||||
const data = await apiRequest("/storefront");
|
||||
setStorefront({
|
||||
pgpKey: data.pgpKey || "",
|
||||
welcomeMessage: data.welcomeMessage || "",
|
||||
@@ -154,10 +154,7 @@ export default function StorefrontPage() {
|
||||
const saveStorefront = async () => {
|
||||
try {
|
||||
setSaving(true);
|
||||
await clientFetch("/storefront", {
|
||||
method: "PUT",
|
||||
body: JSON.stringify(storefront),
|
||||
});
|
||||
await apiRequest("/storefront", "PUT", storefront);
|
||||
toast.success("Storefront updated successfully!");
|
||||
} catch (error) {
|
||||
toast.error("Failed to update storefront.");
|
||||
|
||||
Reference in New Issue
Block a user