@bindu-dashing/dam-solution-v2 5.8.134 → 5.8.136

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.
@@ -12,7 +12,7 @@ import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
12
12
  import { createContext, useContext, useState, useEffect } from "react";
13
13
  import { USER_LOGIN, FETCH_TEAMS_LIST, } from "../utilities/constants/apiUrls";
14
14
  import axios from "axios";
15
- import { getBaseUrl, getTeamIDFromToken, getTeamsApiBaseUrl } from "./helpers";
15
+ import { getBaseUrl, getTeamsApiBaseUrl } from "./helpers";
16
16
  import { get } from "lodash";
17
17
  import Loader from "../common/loader/loader";
18
18
  import { SUBSCRIPTION_EXPIRED_ERROR_MESSAGE } from "./appConstants";
@@ -28,8 +28,9 @@ export const DamConfigProvider = ({ children, config }) => {
28
28
  const [teams, setTeams] = useState([]);
29
29
  const [isAdmin, setIsAdmin] = useState(false);
30
30
  const [showPaymentErr, setShowPaymentErr] = useState(false);
31
+ const [teamID, setTeamID] = useState(null);
31
32
  const getToken = () => __awaiter(void 0, void 0, void 0, function* () {
32
- var _a, _b, _c, _d, _e, _f, _g;
33
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
33
34
  setLoading(true);
34
35
  try {
35
36
  const response = yield axios.post(getBaseUrl(appType) + USER_LOGIN, {
@@ -38,6 +39,7 @@ export const DamConfigProvider = ({ children, config }) => {
38
39
  subdomain,
39
40
  teams: teamIds,
40
41
  });
42
+ console.log("Token response:", response === null || response === void 0 ? void 0 : response.data);
41
43
  const token = (_b = (_a = response === null || response === void 0 ? void 0 : response.data) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.access_token;
42
44
  const userData = (_d = (_c = response === null || response === void 0 ? void 0 : response.data) === null || _c === void 0 ? void 0 : _c.data) === null || _d === void 0 ? void 0 : _d.user;
43
45
  const brandData = (_f = (_e = response === null || response === void 0 ? void 0 : response.data) === null || _e === void 0 ? void 0 : _e.data) === null || _f === void 0 ? void 0 : _f.brand;
@@ -45,6 +47,7 @@ export const DamConfigProvider = ({ children, config }) => {
45
47
  setDamUser(userData);
46
48
  setLoading(false);
47
49
  setBrand(brandData);
50
+ setTeamID((_h = (_g = response === null || response === void 0 ? void 0 : response.data) === null || _g === void 0 ? void 0 : _g.data) === null || _h === void 0 ? void 0 : _h.teamID);
48
51
  // Use initialRootFolderId if provided, otherwise use rootFolderId from API
49
52
  const apiRootFolderId = get(response, "data.data.rootFolderId");
50
53
  setRootFolderId(initialRootFolderId || apiRootFolderId);
@@ -56,7 +59,7 @@ export const DamConfigProvider = ({ children, config }) => {
56
59
  }
57
60
  catch (error) {
58
61
  console.error("Error fetching token:", error);
59
- if (((_g = error === null || error === void 0 ? void 0 : error.response) === null || _g === void 0 ? void 0 : _g.status) === 402) {
62
+ if (((_j = error === null || error === void 0 ? void 0 : error.response) === null || _j === void 0 ? void 0 : _j.status) === 402) {
60
63
  setShowPaymentErr(true);
61
64
  }
62
65
  setLoading(false);
@@ -69,14 +72,13 @@ export const DamConfigProvider = ({ children, config }) => {
69
72
  return;
70
73
  }
71
74
  try {
72
- const teamID = getTeamIDFromToken(token);
73
75
  if (!teamID) {
74
76
  console.log("Could not extract teamID from token");
75
77
  return;
76
78
  }
77
79
  // Get the Teams API base URL (different from MIXDRIVE_API_URL)
78
80
  const teamsApiBaseUrl = getTeamsApiBaseUrl(appType);
79
- const teamsEndpoint = FETCH_TEAMS_LIST.replace(":teamID", teamID.toString());
81
+ const teamsEndpoint = FETCH_TEAMS_LIST.replace(":teamID", teamID);
80
82
  const fullUrl = teamsApiBaseUrl + teamsEndpoint;
81
83
  console.log("Fetching teams from:", fullUrl);
82
84
  console.log("TeamID from token:", teamID);
@@ -20,5 +20,3 @@ export declare const getRelativeTime: (timestamp: string) => string;
20
20
  export declare const getReadableFileType: (file: FileEntity) => string;
21
21
  export declare const humanFileSize: (size: any) => any;
22
22
  export declare const getFormattedValue: (outputFormatData: MetaDataFieldEntity[], fileUrl: string, item: any) => string;
23
- export declare const decodeJWT: (token: string) => any;
24
- export declare const getTeamIDFromToken: (token: string) => number | null;
@@ -1,6 +1,7 @@
1
1
  import dayjs from "dayjs";
2
2
  import { first, get, last, split, toLower, toUpper } from "lodash";
3
3
  import { DATE_FORMAT } from "./appConstants";
4
+ import { FETCH_TEAMS_LIST } from "../utilities/constants/apiUrls";
4
5
  export const getProfileName = (name) => {
5
6
  return name
6
7
  ? name
@@ -109,26 +110,7 @@ export const getBaseUrl = (appType) => {
109
110
  * @returns Teams API base URL
110
111
  */
111
112
  export const getTeamsApiBaseUrl = (appType) => {
112
- // Check for explicit teams API base URL
113
- const teamsApiUrl = appType === "reactJs"
114
- ? process.env.REACT_APP_TEAMS_API_URL
115
- : process.env.NEXT_PUBLIC_TEAMS_API_URL;
116
- if (teamsApiUrl) {
117
- // Extract base URL from full URL (remove /teams/:teamID/list part)
118
- // Example: https://f5ubolirub.execute-api.ap-southeast-2.amazonaws.com/dev/api/v1/teams/104/list
119
- // Should become: https://f5ubolirub.execute-api.ap-southeast-2.amazonaws.com/dev/api/v1
120
- const match = teamsApiUrl.match(/^(https?:\/\/[^\/]+(?:\/[^\/]+)*\/api\/v1)/);
121
- if (match) {
122
- return match[1];
123
- }
124
- // If pattern doesn't match, try to remove /teams/... part
125
- const teamsIndex = teamsApiUrl.indexOf('/teams/');
126
- if (teamsIndex !== -1) {
127
- return teamsApiUrl.substring(0, teamsIndex);
128
- }
129
- }
130
- // Fallback: use the hardcoded base URL
131
- return "https://f5ubolirub.execute-api.ap-southeast-2.amazonaws.com/dev/api/v1";
113
+ return getBaseUrl(appType) + FETCH_TEAMS_LIST;
132
114
  };
133
115
  export const getRelativeTime = (timestamp) => {
134
116
  const now = new Date();
@@ -203,36 +185,3 @@ export const getFormattedValue = (outputFormatData, fileUrl, item) => {
203
185
  }, "");
204
186
  return value ? value : fileUrl;
205
187
  };
206
- export const decodeJWT = (token) => {
207
- if (!token) {
208
- return null;
209
- }
210
- try {
211
- const parts = token.split(".");
212
- if (parts.length !== 3) {
213
- return null;
214
- }
215
- const payload = parts[1];
216
- // Base64URL decode
217
- const base64 = payload.replace(/-/g, "+").replace(/_/g, "/");
218
- const jsonPayload = decodeURIComponent(atob(base64)
219
- .split("")
220
- .map((c) => {
221
- return "%" + ("00" + c.charCodeAt(0).toString(16)).slice(-2);
222
- })
223
- .join(""));
224
- return JSON.parse(jsonPayload);
225
- }
226
- catch (error) {
227
- console.error("Error decoding JWT:", error);
228
- return null;
229
- }
230
- };
231
- export const getTeamIDFromToken = (token) => {
232
- const decoded = decodeJWT(token);
233
- if (!decoded) {
234
- return null;
235
- }
236
- // Handle both teamID and teamId (case variations)
237
- return decoded.teamID || decoded.teamId || null;
238
- };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bindu-dashing/dam-solution-v2",
3
- "version": "5.8.134",
3
+ "version": "5.8.136",
4
4
  "dependencies": {
5
5
  "@ant-design/icons": "^5.0.1",
6
6
  "@emoji-mart/data": "^1.2.1",