Add customer management

This commit is contained in:
2025-07-06 08:31:48 +00:00
parent 2bd76aa6bb
commit 916dbfcf95
57 changed files with 2442 additions and 161 deletions

View File

@@ -0,0 +1,28 @@
// lib/callBackendApi.ts
import {getServerSession} from "next-auth";
import {authOptions} from "@/lib/auth/authOptions";
export async function serverCall(
path: string,
method: "GET" | "POST" | "PUT" | "DELETE" | "PATCH",
body?: unknown
): Promise<Response> {
const url = `${process.env.INTERNAL_BACKEND_URL ?? "http://localhost:8080/api"}${path}`;
const session = await getServerSession(authOptions);
const headers: Record<string, string> = {
"Content-Type": "application/json",
};
if (session != null) {
headers["Authorization"] = `Bearer ${session.accessToken}`;
}
console.log("[api] Calling backend API: ", method, url, body);
return fetch(url, {
method,
headers,
body: body ? JSON.stringify(body) : undefined,
});
}