Remove callApi, refactor API integrations, and adjust error handling
- Delete unused `callApi` utility and related imports across components. - Replace `callApi` with direct `fetch` usage in `validateCustomer` and `addCustomer`. - Update `customerRoutes` to include `/api` prefix for consistency. - Refactor `useErrorHandler` to ensure comprehensive state management during errors. - Improve `ErrorBoundary` component text for better clarity in fallback UI. - Align `CustomersPage` logic with `useCallback` for optimized dependency management.
This commit is contained in:
10
internal_frontend/app/api/customers/validate/route.ts
Normal file
10
internal_frontend/app/api/customers/validate/route.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import {NextRequest, NextResponse} from "next/server";
|
||||
import {serverCall} from "@/lib/api/serverCall";
|
||||
import {customerRoutes} from "@/app/api/customers/customerRoutes";
|
||||
|
||||
export async function POST(req: NextRequest) {
|
||||
const body = await req.json();
|
||||
const result = await serverCall(customerRoutes.validate, "POST", body);
|
||||
const data = await result.json();
|
||||
return NextResponse.json(data);
|
||||
}
|
||||
Reference in New Issue
Block a user