with encrypted data on envolope submit

This commit is contained in:
Abin Toppo
2026-02-05 16:03:26 +05:30
parent 499e680404
commit c1ecc97e29
56 changed files with 4788 additions and 1482 deletions
+71 -17
View File
@@ -9,9 +9,28 @@ export const apiCall = async <R, D = {}>(
params?: any,
contentType?: string
): Promise<R> => {
const token: any = store.getState().token.token;
// 🔥 ONE MAIN GROUP FOR ENTIRE API CALL
console.group(
`%c🚀 API CALL → ${method.toUpperCase()} ${url}`,
'color:#0ea5e9;font-weight:bold'
);
// ===== REQUEST =====
console.group('📤 REQUEST');
console.log('%cMETHOD →', 'color:#22c55e;font-weight:bold', method);
console.log('%cURL →', 'color:#22c55e;font-weight:bold', url);
console.log('%cPARAMS →', 'color:#f59e0b;font-weight:bold', params);
console.log('%cPAYLOAD →', 'color:#a855f7;font-weight:bold', data);
console.log(
'%cTOKEN →',
'color:#ef4444;font-weight:bold',
token?.token ? '✔ PRESENT' : '❌ MISSING'
);
console.groupEnd();
try {
const token: any = store.getState().token.token;
console.log("api payload", data)
const response = await axios({
method,
url,
@@ -22,32 +41,67 @@ console.log("api payload", data)
'Content-Type': contentType || 'application/json',
},
});
console.log("method : ", method)
console.log("url : ", url)
console.log("params : ", params)
console.log("data : ", data)
// ===== RESPONSE =====
console.group('📥 RESPONSE');
console.log(
'%cSTATUS →',
'color:#22c55e;font-weight:bold',
response.status
);
console.log(
'%cRESPONSE DATA →',
'color:#0ea5e9;font-weight:bold',
response.data
);
console.groupEnd();
console.groupEnd(); // 🔚 MAIN GROUP
return response.data;
} catch (error: any) {
const errorMessage = error?.response?.data?.error;
// ===== ERROR =====
console.group('❌ ERROR');
console.error(
'%cSTATUS →',
'color:#ef4444;font-weight:bold',
error?.response?.status
);
console.error(
'%cMESSAGE →',
'color:#f97316;font-weight:bold',
error?.response?.data?.message || error.message
);
console.error(
'%cERROR DATA →',
'color:#fb7185;font-weight:bold',
error?.response?.data
);
console.error(
'%cFULL ERROR →',
'color:#7c2d12;font-weight:bold',
error
);
console.groupEnd();
if (error?.response?.statusCode === 401) {
// ===== AUTH ERROR =====
if (error?.response?.status === 401) {
console.warn(
'%c⚠ JWT ERROR → Token expired or malformed',
'color:#eab308;font-weight:bold'
);
store.dispatch(setToken({}));
console.groupEnd(); // 🔚 MAIN GROUP
return {
success: false,
message: 'JWT Error - Token expired or malformed',
} as R;
}
const data = {
data: {
success: false,
message: error?.response?.data?.message || 'No Response From Server',
}
}
return data as any
console.groupEnd(); // 🔚 MAIN GROUP
return {
success: false,
message:
error?.response?.data?.message || 'No Response From Server',
} as R;
}
};