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

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 } from "./helpers";
15
+ import { getBaseUrl, getTeamIDFromToken, 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";
@@ -63,7 +63,7 @@ export const DamConfigProvider = ({ children, config }) => {
63
63
  }
64
64
  });
65
65
  const getTeams = (token) => __awaiter(void 0, void 0, void 0, function* () {
66
- var _a;
66
+ var _a, _b, _c, _d;
67
67
  if (!token) {
68
68
  console.log("No token available to fetch teams");
69
69
  return;
@@ -74,20 +74,35 @@ export const DamConfigProvider = ({ children, config }) => {
74
74
  console.log("Could not extract teamID from token");
75
75
  return;
76
76
  }
77
- // Call the new API endpoint using base URL
77
+ // Get the Teams API base URL (different from MIXDRIVE_API_URL)
78
+ const teamsApiBaseUrl = getTeamsApiBaseUrl(appType);
78
79
  const teamsEndpoint = FETCH_TEAMS_LIST.replace(":teamID", teamID.toString());
79
- const response = yield axios.get(getBaseUrl(appType) + teamsEndpoint, {
80
+ const fullUrl = teamsApiBaseUrl + teamsEndpoint;
81
+ console.log("Fetching teams from:", fullUrl);
82
+ console.log("TeamID from token:", teamID);
83
+ // Call the new API endpoint using Teams API base URL
84
+ const response = yield axios.get(fullUrl, {
80
85
  headers: {
81
86
  Authorization: `Bearer ${token}`,
82
87
  },
83
88
  });
89
+ console.log("Teams API response:", response === null || response === void 0 ? void 0 : response.data);
84
90
  // Set teams from the API response
85
91
  // Assuming the response structure is { data: [...] } or similar
86
92
  const teamsData = ((_a = response === null || response === void 0 ? void 0 : response.data) === null || _a === void 0 ? void 0 : _a.data) || (response === null || response === void 0 ? void 0 : response.data) || [];
93
+ console.log("Parsed teams data:", teamsData);
87
94
  setTeams(Array.isArray(teamsData) ? teamsData : []);
88
95
  }
89
96
  catch (err) {
90
- console.log("Error fetching teams:", err);
97
+ console.error("Error fetching teams:", err);
98
+ console.error("Error details:", {
99
+ message: err === null || err === void 0 ? void 0 : err.message,
100
+ response: (_b = err === null || err === void 0 ? void 0 : err.response) === null || _b === void 0 ? void 0 : _b.data,
101
+ status: (_c = err === null || err === void 0 ? void 0 : err.response) === null || _c === void 0 ? void 0 : _c.status,
102
+ url: (_d = err === null || err === void 0 ? void 0 : err.config) === null || _d === void 0 ? void 0 : _d.url,
103
+ });
104
+ // Set empty array on error to prevent stale data
105
+ setTeams([]);
91
106
  }
92
107
  });
93
108
  useEffect(() => {
@@ -9,6 +9,13 @@ export declare const getDateRangeFromKey: (key: string) => {
9
9
  endDate?: string;
10
10
  };
11
11
  export declare const getBaseUrl: (appType: string) => string;
12
+ /**
13
+ * Get the Teams API base URL from environment variable
14
+ * Falls back to extracting from REACT_APP_TEAMS_API_URL if available
15
+ * @param appType Application type (reactJs or nextJs)
16
+ * @returns Teams API base URL
17
+ */
18
+ export declare const getTeamsApiBaseUrl: (appType: string) => string;
12
19
  export declare const getRelativeTime: (timestamp: string) => string;
13
20
  export declare const getReadableFileType: (file: FileEntity) => string;
14
21
  export declare const humanFileSize: (size: any) => any;
@@ -102,6 +102,34 @@ export const getBaseUrl = (appType) => {
102
102
  return process.env.REACT_APP_MIXDRIVE_API_URL || "";
103
103
  }
104
104
  };
105
+ /**
106
+ * Get the Teams API base URL from environment variable
107
+ * Falls back to extracting from REACT_APP_TEAMS_API_URL if available
108
+ * @param appType Application type (reactJs or nextJs)
109
+ * @returns Teams API base URL
110
+ */
111
+ 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";
132
+ };
105
133
  export const getRelativeTime = (timestamp) => {
106
134
  const now = new Date();
107
135
  const created = new Date(timestamp);
@@ -81,7 +81,7 @@ export declare const FETCH_CLIENT_KEY_URL = "/keys/:keyId";
81
81
  export declare const GENERATE_CLIENT_KEY_URL = "/keys/:keyId/generate";
82
82
  export declare const USER_LOGIN = "/users/login/keys";
83
83
  export declare const FETCH_BRAND_USING_SUBDOMAIN = "/brands/subdomain";
84
- export declare const FETCH_TEAMS_LIST = "/api/v1/teams/:teamID/list";
84
+ export declare const FETCH_TEAMS_LIST = "/teams/:teamID/list";
85
85
  export declare const CREATE_SUB_BRAND = "/brands/sub-brand";
86
86
  export declare const FETCH_IMAGEPICKERS_URL = "/image-picker";
87
87
  export declare const FETCH_IMAGEPICKER_URL = "/image-picker/:id";
@@ -96,7 +96,7 @@ export const GENERATE_CLIENT_KEY_URL = "/keys/:keyId/generate";
96
96
  // login
97
97
  export const USER_LOGIN = "/users/login/keys";
98
98
  export const FETCH_BRAND_USING_SUBDOMAIN = "/brands/subdomain";
99
- export const FETCH_TEAMS_LIST = "/api/v1/teams/:teamID/list";
99
+ export const FETCH_TEAMS_LIST = "/teams/:teamID/list";
100
100
  // brand
101
101
  export const CREATE_SUB_BRAND = "/brands/sub-brand";
102
102
  //image picker
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bindu-dashing/dam-solution-v2",
3
- "version": "5.8.133",
3
+ "version": "5.8.134",
4
4
  "dependencies": {
5
5
  "@ant-design/icons": "^5.0.1",
6
6
  "@emoji-mart/data": "^1.2.1",