client frontend added
This commit is contained in:
@@ -97,14 +97,8 @@ async function coreFetch<T>(
|
||||
|
||||
const responseJson = await response.json();
|
||||
|
||||
if (process.env.NODE_ENV !== "production") {
|
||||
console.log("Fetching:", url, fetchOptions);
|
||||
console.log("Response:", responseJson);
|
||||
}
|
||||
|
||||
return prepareResponse(responseJson, response.status);
|
||||
} catch (error) {
|
||||
console.error(`Fetch error (${url}):`, error);
|
||||
return {
|
||||
...DEFAULT_RESPONSE,
|
||||
error: error instanceof Error ? error.message : "Network error",
|
||||
|
||||
@@ -44,9 +44,6 @@ async function listApplicationsAvailable(payload: PaginationParams): Promise<Pag
|
||||
query: payload.query,
|
||||
};
|
||||
|
||||
console.log('Sending request to backend with service_uu_id:', payload.query.service_uu_id);
|
||||
console.log('Full request body:', JSON.stringify(requestBody, null, 2));
|
||||
|
||||
const response = await fetchDataWithToken(
|
||||
applicationListAvailableEndpoint,
|
||||
requestBody,
|
||||
@@ -56,7 +53,6 @@ async function listApplicationsAvailable(payload: PaginationParams): Promise<Pag
|
||||
|
||||
if (response?.status === 200 || response?.status === 202) {
|
||||
const responseData = response.data as PaginatedApiResponse<any>;
|
||||
console.log('list_events_available responseData:', JSON.stringify(responseData, null, 2));
|
||||
return {
|
||||
data: responseData.data || [],
|
||||
pagination: collectPaginationFromApiResponse(responseData)
|
||||
@@ -93,9 +89,6 @@ async function listApplicationsAppended(payload: PaginationParams): Promise<Pagi
|
||||
query: payload.query,
|
||||
};
|
||||
|
||||
console.log('Sending request to backend with service_uu_id:', payload.query.service_uu_id);
|
||||
console.log('Full request body:', JSON.stringify(requestBody, null, 2));
|
||||
|
||||
const response = await fetchDataWithToken(
|
||||
applicationListAppendedEndpoint,
|
||||
requestBody,
|
||||
@@ -105,7 +98,6 @@ async function listApplicationsAppended(payload: PaginationParams): Promise<Pagi
|
||||
|
||||
if (response?.status === 200 || response?.status === 202) {
|
||||
const responseData = response.data as PaginatedApiResponse<any>;
|
||||
console.log('list_events_available responseData:', JSON.stringify(responseData, null, 2));
|
||||
return {
|
||||
data: responseData.data || [],
|
||||
pagination: collectPaginationFromApiResponse(responseData)
|
||||
@@ -116,7 +108,6 @@ async function listApplicationsAppended(payload: PaginationParams): Promise<Pagi
|
||||
pagination: defaultPaginationResponse,
|
||||
};
|
||||
} catch (error) {
|
||||
console.error("Error fetching events list:", error);
|
||||
return {
|
||||
data: [],
|
||||
pagination: defaultPaginationResponse,
|
||||
@@ -134,8 +125,6 @@ async function listAllApplications(payload: PaginationParams): Promise<Paginated
|
||||
query: payload.query,
|
||||
};
|
||||
|
||||
// console.log('Sending request to backend with service_uu_id:', payload.query.service_uu_id);
|
||||
// console.log('Full request body:', JSON.stringify(requestBody, null, 2));
|
||||
|
||||
const response = await fetchDataWithToken(
|
||||
applicationListEndpoint,
|
||||
@@ -156,7 +145,6 @@ async function listAllApplications(payload: PaginationParams): Promise<Paginated
|
||||
pagination: defaultPaginationResponse,
|
||||
};
|
||||
} catch (error) {
|
||||
console.error("Error fetching events list:", error);
|
||||
return {
|
||||
data: [],
|
||||
pagination: defaultPaginationResponse,
|
||||
@@ -174,7 +162,7 @@ async function appendApplicationToService(payload: AppendApplicationToService) {
|
||||
);
|
||||
return response?.status === 200 || response?.status === 202 ? response.data : null;
|
||||
} catch (error) {
|
||||
console.error("Error appending event to service:", error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -188,12 +176,10 @@ async function removeApplicationFromService(payload: RemoveApplicationFromServic
|
||||
);
|
||||
return response?.status === 200 || response?.status === 202 ? response.data : null;
|
||||
} catch (error) {
|
||||
console.error("Error removing event from service:", error);
|
||||
}
|
||||
}
|
||||
|
||||
async function createApplication(payload: any) {
|
||||
console.log("Creating application with payload:", payload);
|
||||
try {
|
||||
const response = await fetchDataWithToken(
|
||||
applicationCreateEndpoint,
|
||||
@@ -211,7 +197,6 @@ async function createApplication(payload: any) {
|
||||
}
|
||||
|
||||
async function updateApplication(payload: any, uuId: string) {
|
||||
console.log("Updating application with payload:", payload, 'uuId:', uuId);
|
||||
try {
|
||||
const response = await fetchDataWithToken(
|
||||
`${applicationUpdateEndpoint}/${uuId}`,
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
"use server";
|
||||
|
||||
import { fetchDataWithToken } from "../api-fetcher";
|
||||
import { baseUrlApplication } from "../basics";
|
||||
import { PaginationParams } from "../schemas/list";
|
||||
import { fetchDataWithToken } from "@/apicalls/api-fetcher";
|
||||
import { baseUrlApplication } from "@/apicalls/basics";
|
||||
import { PaginationParams } from "@/apicalls/schemas/list";
|
||||
import { PaginatedApiResponse, collectPaginationFromApiResponse, defaultPaginationResponse } from "@/app/api/utils/types";
|
||||
|
||||
const eventsListAvailableEndpoint = `${baseUrlApplication}/events/list/available`;
|
||||
@@ -36,9 +36,6 @@ async function list_events_available(payload: PaginationParams): Promise<Paginat
|
||||
query: payload.query,
|
||||
};
|
||||
|
||||
console.log('Sending request to backend with service_uu_id:', payload.query.service_uu_id);
|
||||
console.log('Full request body:', JSON.stringify(requestBody, null, 2));
|
||||
|
||||
const response = await fetchDataWithToken(
|
||||
eventsListAvailableEndpoint,
|
||||
requestBody,
|
||||
@@ -48,7 +45,6 @@ async function list_events_available(payload: PaginationParams): Promise<Paginat
|
||||
|
||||
if (response?.status === 200 || response?.status === 202) {
|
||||
const responseData = response.data as PaginatedApiResponse<any>;
|
||||
console.log('list_events_available responseData:', JSON.stringify(responseData, null, 2));
|
||||
return {
|
||||
data: responseData.data || [],
|
||||
pagination: collectPaginationFromApiResponse(responseData)
|
||||
@@ -59,7 +55,6 @@ async function list_events_available(payload: PaginationParams): Promise<Paginat
|
||||
pagination: defaultPaginationResponse,
|
||||
};
|
||||
} catch (error) {
|
||||
console.error("Error fetching events list:", error);
|
||||
return {
|
||||
data: [],
|
||||
pagination: defaultPaginationResponse,
|
||||
|
||||
@@ -72,10 +72,8 @@ async function retrieveUserSelection() {
|
||||
decrpytUserSelection = decrpytUserSelection
|
||||
? JSON.parse(decrpytUserSelection)
|
||||
: null;
|
||||
console.log("decrpytUserSelection", decrpytUserSelection);
|
||||
const userSelection = decrpytUserSelection?.selected;
|
||||
const accessObjects = (await retrieveAccessObjects()) || {};
|
||||
console.log("accessObjects", accessObjects);
|
||||
|
||||
if (decrpytUserSelection?.user_type === "employee") {
|
||||
const companyList = accessObjects?.selectionList;
|
||||
|
||||
Reference in New Issue
Block a user