@iblai/web-utils 1.2.10 → 1.2.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/data-layer/src/features/reports/api-slice.d.ts +150 -279
- package/dist/index.esm.js +35 -4
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +35 -4
- package/dist/index.js.map +1 -1
- package/dist/package.json +1 -1
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -2761,7 +2761,7 @@ async function isDmTokenExpired(storageService) {
|
|
|
2761
2761
|
try {
|
|
2762
2762
|
const dmTokenExpires = await storageService.getItem(LOCAL_STORAGE_KEYS.DM_TOKEN_EXPIRES);
|
|
2763
2763
|
if (!dmTokenExpires) {
|
|
2764
|
-
return
|
|
2764
|
+
return false;
|
|
2765
2765
|
}
|
|
2766
2766
|
const expiryTime = new Date(dmTokenExpires).getTime();
|
|
2767
2767
|
const currentTime = Date.now();
|
|
@@ -2991,14 +2991,15 @@ function useAuthProvider({ middleware = new Map(), onAuthSuccess, onAuthFailure,
|
|
|
2991
2991
|
}
|
|
2992
2992
|
// Check JWT token expiry and force logout for protected routes
|
|
2993
2993
|
if (isProtectedRoute && storageService) {
|
|
2994
|
+
const dmTokenInLocalStorage = await storageService.getItem(LOCAL_STORAGE_KEYS.DM_TOKEN_KEY);
|
|
2994
2995
|
const dmTokenExpired = await isDmTokenExpired(storageService);
|
|
2995
|
-
if (dmTokenExpired) {
|
|
2996
|
+
if (!dmTokenInLocalStorage || dmTokenExpired) {
|
|
2996
2997
|
console.log("[auth-redirect] DM token has expired, forcing logout");
|
|
2997
2998
|
// Clear all auth-related storage keys
|
|
2998
2999
|
clearAuthCookies();
|
|
2999
3000
|
const reason = "DM token expired";
|
|
3000
3001
|
onAuthFailure === null || onAuthFailure === void 0 ? void 0 : onAuthFailure(reason);
|
|
3001
|
-
safeRedirectToAuthSpa(undefined, undefined,
|
|
3002
|
+
safeRedirectToAuthSpa(undefined, undefined, !!dmTokenInLocalStorage); // with no dm token at all in storage, don't force logout
|
|
3002
3003
|
return;
|
|
3003
3004
|
}
|
|
3004
3005
|
// Validate JWT token user_id
|
|
@@ -16063,7 +16064,37 @@ createApi({
|
|
|
16063
16064
|
tagTypes: ['reports', 'reportDetail'],
|
|
16064
16065
|
endpoints: (builder) => ({
|
|
16065
16066
|
getReports: builder.query({
|
|
16066
|
-
|
|
16067
|
+
async queryFn({ key, mentor_id }) {
|
|
16068
|
+
var _a, _b;
|
|
16069
|
+
try {
|
|
16070
|
+
const baseUrl = getServiceUrl(SERVICES.DM);
|
|
16071
|
+
const authHeaders = await getHeaders(SERVICES.DM);
|
|
16072
|
+
const url = new URL(`/dm/api/reports/platforms/${encodeURIComponent(key)}/`, baseUrl);
|
|
16073
|
+
if (mentor_id) {
|
|
16074
|
+
url.searchParams.set('mentor_id', mentor_id);
|
|
16075
|
+
}
|
|
16076
|
+
const response = await fetch(url.toString(), {
|
|
16077
|
+
method: 'GET',
|
|
16078
|
+
headers: {
|
|
16079
|
+
'Content-Type': 'application/json',
|
|
16080
|
+
...(authHeaders !== null && authHeaders !== void 0 ? authHeaders : {}),
|
|
16081
|
+
},
|
|
16082
|
+
});
|
|
16083
|
+
const data = (await response.json());
|
|
16084
|
+
if (!response.ok) {
|
|
16085
|
+
return { error: { status: response.status, data } };
|
|
16086
|
+
}
|
|
16087
|
+
return { data };
|
|
16088
|
+
}
|
|
16089
|
+
catch (err) {
|
|
16090
|
+
return {
|
|
16091
|
+
error: {
|
|
16092
|
+
status: (_a = err === null || err === void 0 ? void 0 : err.status) !== null && _a !== void 0 ? _a : 500,
|
|
16093
|
+
data: (_b = err === null || err === void 0 ? void 0 : err.message) !== null && _b !== void 0 ? _b : 'Unknown error',
|
|
16094
|
+
},
|
|
16095
|
+
};
|
|
16096
|
+
}
|
|
16097
|
+
},
|
|
16067
16098
|
providesTags: ['reports'],
|
|
16068
16099
|
}),
|
|
16069
16100
|
getReportDetail: builder.query({
|