@bindu-dashing/dam-solution-v2 5.8.200 → 5.8.202

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.
@@ -9,12 +9,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  };
10
10
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
11
11
  import { Button, Space } from "antd";
12
- import { useState } from "react";
13
- import axios from "axios";
12
+ import { useState, useMemo } from "react";
14
13
  import CreateClientForm from "./CreateClientForm";
15
14
  import { useDamConfig } from "../hocs/DamConfigContext";
16
- import { getBaseUrl } from "../hocs/helpers";
17
- import { REFRESH_KEY_URL, USER_LOGIN } from "../utilities/constants/apiUrls";
15
+ import { createApiClient } from "../hocs/configureAxios";
16
+ import { REFRESH_KEY_URL } from "../utilities/constants/apiUrls";
18
17
  import { showNotification } from "../common/notifications";
19
18
  import { NotificationStatus } from "../utilities/constants/interface";
20
19
  import { SOMETHING_WENT_WRONG } from "../utilities/constants/messages";
@@ -24,7 +23,7 @@ const CreateClient = ({ onSuccess, clientSubdomain, teamsApi, username, password
24
23
  const [refreshingKey, setRefreshingKey] = useState(false);
25
24
  const isEditMode = !!existingClientData;
26
25
  const damConfig = useDamConfig();
27
- const { appType, teamIds } = damConfig;
26
+ const api = useMemo(() => createApiClient(damConfig), [damConfig]);
28
27
  const toggleShow = () => {
29
28
  setShowForm(!showForm);
30
29
  };
@@ -33,38 +32,20 @@ const CreateClient = ({ onSuccess, clientSubdomain, teamsApi, username, password
33
32
  showNotification("Access key and secret key are required to refresh", NotificationStatus.ERROR);
34
33
  return;
35
34
  }
36
- const accessKey = existingClientData.accessKey;
37
- const secretKey = existingClientData.secretKey;
38
- const subdomain = existingClientData.subdomain || clientSubdomain || (damConfig === null || damConfig === void 0 ? void 0 : damConfig.subdomain) || "";
39
- if (!subdomain) {
40
- showNotification("Subdomain is required to refresh key", NotificationStatus.ERROR);
41
- return;
42
- }
43
35
  setRefreshingKey(true);
44
36
  try {
45
- // Step 1: Login with keys to get DAM token (same as Edit Client flow)
46
- const loginResponse = yield axios.post(getBaseUrl(appType) + USER_LOGIN, {
47
- accessKey,
48
- secretKey,
49
- subdomain,
50
- teams: teamIds && teamIds.length > 0 ? teamIds : [""],
51
- });
52
- const token = get(loginResponse, "data.data.access_token");
53
- if (!token) {
54
- throw new Error("Failed to get token from login");
55
- }
56
- // Step 2: Call refresh API with the DAM token (include subdomain header)
57
- const response = yield axios.put(getBaseUrl(appType) + REFRESH_KEY_URL, { accessKey, secretKey }, {
58
- headers: {
59
- Authorization: `Bearer ${token}`,
60
- subdomain: subdomain,
61
- },
37
+ const response = yield api.put(REFRESH_KEY_URL, {
38
+ accessKey: existingClientData.accessKey,
39
+ secretKey: existingClientData.secretKey,
62
40
  });
63
41
  setRefreshingKey(false);
64
- showNotification(get(response, "data.data.message", "Key refreshed successfully"), NotificationStatus.SUCCESS);
42
+ showNotification(get(response, "data.message", "Key refreshed successfully"), NotificationStatus.SUCCESS);
43
+ if (onSuccess) {
44
+ onSuccess(response === null || response === void 0 ? void 0 : response.data);
45
+ }
65
46
  }
66
47
  catch (error) {
67
- showNotification(get(error, "response.data.message", get(error, "message", SOMETHING_WENT_WRONG)), NotificationStatus.ERROR);
48
+ showNotification(get(error, "message", SOMETHING_WENT_WRONG), NotificationStatus.ERROR);
68
49
  setRefreshingKey(false);
69
50
  }
70
51
  });
@@ -19,7 +19,7 @@ import { getBaseUrl } from "../hocs/helpers";
19
19
  import { CREATE_SUCCESS, SOMETHING_WENT_WRONG, } from "../utilities/constants/messages";
20
20
  import { NotificationStatus } from "../utilities/constants/interface";
21
21
  import { showNotification } from "../common/notifications";
22
- import { get, isEqual } from "lodash";
22
+ import { get } from "lodash";
23
23
  const CreateClientForm = ({ teamsApi, username, password, toggleShow, onSuccess, clientSubdomain, existingClientData, }) => {
24
24
  const damConfig = useDamConfig();
25
25
  const { appType } = damConfig;
@@ -34,51 +34,6 @@ const CreateClientForm = ({ teamsApi, username, password, toggleShow, onSuccess,
34
34
  const api = useMemo(() => createApiClient(damConfig), [damConfig]);
35
35
  const [form] = Form.useForm();
36
36
  const isEditMode = !!existingClientData;
37
- // Watch form values to enable/disable Submit button
38
- const formValues = Form.useWatch([], form);
39
- const isFormValid = useMemo(() => {
40
- var _a;
41
- if (!formValues)
42
- return false;
43
- // In edit mode, disabled fields (subdomain, damLocationDetails) may be excluded from form values - use clientData as fallback
44
- const damLocationDetails = formValues.damLocationDetails || get(clientData, "damLocationDetails", {}) || {};
45
- const name = formValues.name;
46
- const accessTypes = formValues.accessTypes;
47
- const adminTeams = formValues.adminTeams;
48
- const subdomain = (_a = formValues.subdomain) !== null && _a !== void 0 ? _a : (isEditMode ? (get(clientData, "subdomain") || (existingClientData === null || existingClientData === void 0 ? void 0 : existingClientData.subdomain)) : undefined);
49
- const type = damLocationDetails.type;
50
- const rootPath = damLocationDetails.rootPath;
51
- if (!(name === null || name === void 0 ? void 0 : name.trim()))
52
- return false;
53
- if (!(accessTypes === null || accessTypes === void 0 ? void 0 : accessTypes.length))
54
- return false;
55
- if (!(adminTeams === null || adminTeams === void 0 ? void 0 : adminTeams.length))
56
- return false;
57
- if (!(subdomain === null || subdomain === void 0 ? void 0 : subdomain.trim()))
58
- return false;
59
- if (!type)
60
- return false;
61
- if (!(rootPath === null || rootPath === void 0 ? void 0 : rootPath.trim()))
62
- return false;
63
- if (damLocationType === "external") {
64
- const bucket = damLocationDetails.bucket;
65
- const accessKeyId = damLocationDetails.accessKeyId;
66
- const secretAccessKey = damLocationDetails.secretAccessKey;
67
- const url = damLocationDetails.url;
68
- const region = damLocationDetails.region;
69
- if (!(bucket === null || bucket === void 0 ? void 0 : bucket.trim()))
70
- return false;
71
- if (!(accessKeyId === null || accessKeyId === void 0 ? void 0 : accessKeyId.trim()))
72
- return false;
73
- if (!(secretAccessKey === null || secretAccessKey === void 0 ? void 0 : secretAccessKey.trim()))
74
- return false;
75
- if (!(url === null || url === void 0 ? void 0 : url.trim()))
76
- return false;
77
- if (!(region === null || region === void 0 ? void 0 : region.trim()))
78
- return false;
79
- }
80
- return true;
81
- }, [formValues, damLocationType, isEditMode, clientData, existingClientData === null || existingClientData === void 0 ? void 0 : existingClientData.subdomain]);
82
37
  const onChangeDamLocationType = (e) => {
83
38
  setDamLocationType(e);
84
39
  form.setFieldValue("dam_location_details", { type: e });
@@ -197,7 +152,7 @@ const CreateClientForm = ({ teamsApi, username, password, toggleShow, onSuccess,
197
152
  fetchClientData();
198
153
  }, [isEditMode, existingClientData === null || existingClientData === void 0 ? void 0 : existingClientData.brandId, existingClientData === null || existingClientData === void 0 ? void 0 : existingClientData.subdomain, api, form]);
199
154
  const onFinish = (data) => __awaiter(void 0, void 0, void 0, function* () {
200
- var _a, _b, _c, _d;
155
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
201
156
  try {
202
157
  // Use teamsApiDetails from clientData if available (from API response), otherwise use props
203
158
  const teamsApiDetailsFromData = get(clientData, "teamsApiDetails", {});
@@ -208,85 +163,54 @@ const CreateClientForm = ({ teamsApi, username, password, toggleShow, onSuccess,
208
163
  const adminTeamsAsStrings = Array.isArray(data.adminTeams)
209
164
  ? data.adminTeams.map((team) => String(team))
210
165
  : [];
166
+ const values = Object.assign(Object.assign({}, data), { adminTeams: adminTeamsAsStrings, showFilePreview: (_a = data.showFilePreview) !== null && _a !== void 0 ? _a : false, accessKey: appType == "reactJs"
167
+ ? process.env.REACT_APP_MIXDRIVE_CLIENT_PARENT_ACCESS_KEY
168
+ : process.env.NEXT_PUBLIC_MIXDRIVE_CLIENT_PARENT_ACCESS_KEY, secretKey: appType == "reactJs"
169
+ ? process.env.REACT_APP_MIXDRIVE_CLIENT_PARENT_SECRET_KEY
170
+ : process.env.NEXT_PUBLIC_MIXDRIVE_CLIENT_PARENT_SECRET_KEY, parentSubdomain: appType == "reactJs"
171
+ ? process.env.REACT_APP_MIXDRIVE_CLIENT_PARENT_SUBDOMAIN
172
+ : process.env.NEXT_PUBLIC_MIXDRIVE_CLIENT_PARENT_SUBDOMAIN, teamsApiDetails: {
173
+ teamsApi: finalTeamsApi,
174
+ username: finalUsername,
175
+ password: finalPassword,
176
+ }, damLocationDetails: damLocationType === "external"
177
+ ? {
178
+ bucket: (_b = data === null || data === void 0 ? void 0 : data.damLocationDetails) === null || _b === void 0 ? void 0 : _b.bucket,
179
+ locationType: "EXTERNAL",
180
+ rootPath: (_c = data === null || data === void 0 ? void 0 : data.damLocationDetails) === null || _c === void 0 ? void 0 : _c.rootPath,
181
+ accessKeyId: (_d = data === null || data === void 0 ? void 0 : data.damLocationDetails) === null || _d === void 0 ? void 0 : _d.accessKeyId,
182
+ secretAccessKey: (_e = data === null || data === void 0 ? void 0 : data.damLocationDetails) === null || _e === void 0 ? void 0 : _e.secretAccessKey,
183
+ url: (_f = data === null || data === void 0 ? void 0 : data.damLocationDetails) === null || _f === void 0 ? void 0 : _f.url,
184
+ region: (_g = data === null || data === void 0 ? void 0 : data.damLocationDetails) === null || _g === void 0 ? void 0 : _g.region,
185
+ }
186
+ : {
187
+ locationType: "INTERNAL",
188
+ rootPath: (_h = data === null || data === void 0 ? void 0 : data.damLocationDetails) === null || _h === void 0 ? void 0 : _h.rootPath,
189
+ } });
211
190
  setLoading(true);
212
191
  let response;
213
192
  const baseUrl = getBaseUrl(appType);
214
193
  if (isEditMode && brandIdForUpdate && authToken) {
215
- // Edit mode: send only changed fields (partial update)
216
- const originalAdminTeams = get(clientData, "adminTeams", []);
217
- const originalAdminTeamsStr = Array.isArray(originalAdminTeams)
218
- ? originalAdminTeams.map((t) => String(t)).sort()
219
- : [];
220
- const newAdminTeamsStr = [...adminTeamsAsStrings].sort();
221
- const payload = {};
222
- if (data.name !== undefined && data.name !== get(clientData, "name")) {
223
- payload.name = data.name;
224
- }
225
- if (!isEqual(newAdminTeamsStr, originalAdminTeamsStr)) {
226
- payload.adminTeams = adminTeamsAsStrings;
227
- }
228
- if (!isEqual(data.accessTypes || [], get(clientData, "accessTypes", []))) {
229
- payload.accessTypes = data.accessTypes;
230
- }
231
- if (((_a = data.showFilePreview) !== null && _a !== void 0 ? _a : false) !== get(clientData, "showFilePreview", false)) {
232
- payload.showFilePreview = (_b = data.showFilePreview) !== null && _b !== void 0 ? _b : false;
233
- }
234
- if (Object.keys(payload).length === 0) {
235
- setLoading(false);
236
- showNotification("No changes to save", NotificationStatus.INFO);
237
- return;
238
- }
239
- const putResponse = yield axios.put(`${baseUrl}/brands/${brandIdForUpdate}`, payload, {
194
+ // Update existing client: PUT to /brands/{brandId}
195
+ const putResponse = yield axios.put(`${baseUrl}/brands/${brandIdForUpdate}`, values, {
240
196
  headers: {
241
197
  'Authorization': `Bearer ${authToken}`,
242
198
  'Content-Type': 'application/json',
243
199
  'accept': 'application/json, text/plain, */*'
244
200
  }
245
201
  });
202
+ // Extract data from axios response (API returns { data: {...} } or { data: { data: {...} } })
246
203
  response = get(putResponse, "data.data", get(putResponse, "data", putResponse));
247
204
  }
248
205
  else {
249
- // Create mode: send full payload
250
- const damLocationDetailsFromForm = data === null || data === void 0 ? void 0 : data.damLocationDetails;
251
- const subdomainValue = data.subdomain;
252
- const values = Object.assign(Object.assign({}, data), { subdomain: subdomainValue, adminTeams: adminTeamsAsStrings, showFilePreview: (_c = data.showFilePreview) !== null && _c !== void 0 ? _c : false, accessKey: appType == "reactJs"
253
- ? process.env.REACT_APP_MIXDRIVE_CLIENT_PARENT_ACCESS_KEY
254
- : process.env.NEXT_PUBLIC_MIXDRIVE_CLIENT_PARENT_ACCESS_KEY, secretKey: appType == "reactJs"
255
- ? process.env.REACT_APP_MIXDRIVE_CLIENT_PARENT_SECRET_KEY
256
- : process.env.NEXT_PUBLIC_MIXDRIVE_CLIENT_PARENT_SECRET_KEY, parentSubdomain: appType == "reactJs"
257
- ? process.env.REACT_APP_MIXDRIVE_CLIENT_PARENT_SUBDOMAIN
258
- : process.env.NEXT_PUBLIC_MIXDRIVE_CLIENT_PARENT_SUBDOMAIN, teamsApiDetails: {
259
- teamsApi: finalTeamsApi,
260
- username: finalUsername,
261
- password: finalPassword,
262
- }, damLocationDetails: damLocationType === "external"
263
- ? {
264
- bucket: damLocationDetailsFromForm === null || damLocationDetailsFromForm === void 0 ? void 0 : damLocationDetailsFromForm.bucket,
265
- locationType: "EXTERNAL",
266
- rootPath: damLocationDetailsFromForm === null || damLocationDetailsFromForm === void 0 ? void 0 : damLocationDetailsFromForm.rootPath,
267
- accessKeyId: damLocationDetailsFromForm === null || damLocationDetailsFromForm === void 0 ? void 0 : damLocationDetailsFromForm.accessKeyId,
268
- secretAccessKey: damLocationDetailsFromForm === null || damLocationDetailsFromForm === void 0 ? void 0 : damLocationDetailsFromForm.secretAccessKey,
269
- url: damLocationDetailsFromForm === null || damLocationDetailsFromForm === void 0 ? void 0 : damLocationDetailsFromForm.url,
270
- region: damLocationDetailsFromForm === null || damLocationDetailsFromForm === void 0 ? void 0 : damLocationDetailsFromForm.region,
271
- }
272
- : {
273
- locationType: "INTERNAL",
274
- rootPath: damLocationDetailsFromForm === null || damLocationDetailsFromForm === void 0 ? void 0 : damLocationDetailsFromForm.rootPath,
275
- } });
276
206
  // Create new client: POST to /brands/sub-brand
277
207
  response = yield api.post(CREATE_SUB_BRAND, values);
278
208
  }
279
209
  setLoading(false);
280
- showNotification((_d = response === null || response === void 0 ? void 0 : response.message) !== null && _d !== void 0 ? _d : (get(response, "message") || CREATE_SUCCESS), NotificationStatus.SUCCESS);
210
+ showNotification((_j = response === null || response === void 0 ? void 0 : response.message) !== null && _j !== void 0 ? _j : (get(response, "message") || CREATE_SUCCESS), NotificationStatus.SUCCESS);
281
211
  toggleShow();
282
212
  if (onSuccess) {
283
- // Pass full brand object: API may return { data: {...} } or {...} directly
284
- // For PATCH (edit), response may be partial - merge with clientData and existingClientData
285
- // so parent gets accessKey, secretKey, subdomain (credentials may not be in API response)
286
- const apiBrand = get(response, "data", response);
287
- const brandData = isEditMode
288
- ? Object.assign(Object.assign(Object.assign({}, (clientData || {})), (existingClientData || {})), apiBrand) : apiBrand;
289
- onSuccess(brandData);
213
+ onSuccess(response === null || response === void 0 ? void 0 : response.data);
290
214
  }
291
215
  }
292
216
  catch (error) {
@@ -383,41 +307,41 @@ const CreateClientForm = ({ teamsApi, username, password, toggleShow, onSuccess,
383
307
  },
384
308
  ], children: _jsx(Select, { options: DAM_LOCATION_TYPES, onChange: (e) => {
385
309
  onChangeDamLocationType(e);
386
- }, placeholder: "Type", disabled: isEditMode }) }), _jsx(Form.Item, { label: "Root Path", name: ["damLocationDetails", "rootPath"], rules: [
310
+ }, placeholder: "Type" }) }), _jsx(Form.Item, { label: "Root Path", name: ["damLocationDetails", "rootPath"], rules: [
387
311
  {
388
312
  required: true,
389
313
  message: "Root path is required",
390
314
  },
391
- ], children: _jsx(Input, { placeholder: "Root path", disabled: isEditMode }) }), shouldShowExternalFields && (_jsxs(_Fragment, { children: [_jsx(Form.Item, { label: "Bucket", name: ["damLocationDetails", "bucket"], rules: [
315
+ ], children: _jsx(Input, { placeholder: "Root path" }) }), shouldShowExternalFields && (_jsxs(_Fragment, { children: [_jsx(Form.Item, { label: "Bucket", name: ["damLocationDetails", "bucket"], rules: [
392
316
  {
393
317
  required: damLocationType === "external",
394
318
  message: "Bucket is required",
395
319
  },
396
- ], children: _jsx(Input, { placeholder: "Bucket", disabled: damLocationType === "internal" || isEditMode }) }), _jsx(Form.Item, { label: "Access Key", name: ["damLocationDetails", "accessKeyId"], rules: [
320
+ ], children: _jsx(Input, { placeholder: "Bucket", disabled: damLocationType === "internal" }) }), _jsx(Form.Item, { label: "Access Key", name: ["damLocationDetails", "accessKeyId"], rules: [
397
321
  {
398
322
  required: damLocationType === "external",
399
323
  message: "Access key is required",
400
324
  },
401
- ], children: _jsx(Input, { placeholder: "Access Key", disabled: damLocationType === "internal" || isEditMode }) }), _jsx(Form.Item, { label: "Secret Access Key", name: ["damLocationDetails", "secretAccessKey"], rules: [
325
+ ], children: _jsx(Input, { placeholder: "Access Key", disabled: damLocationType === "internal" }) }), _jsx(Form.Item, { label: "Secret Access Key", name: ["damLocationDetails", "secretAccessKey"], rules: [
402
326
  {
403
327
  required: damLocationType === "external",
404
328
  message: "Secret Access Key is required",
405
329
  },
406
- ], children: _jsx(Input, { placeholder: "Secret Key", disabled: damLocationType === "internal" || isEditMode }) }), _jsx(Form.Item, { label: "Url", name: ["damLocationDetails", "url"], rules: [
330
+ ], children: _jsx(Input, { placeholder: "Secret Key", disabled: damLocationType === "internal" }) }), _jsx(Form.Item, { label: "Url", name: ["damLocationDetails", "url"], rules: [
407
331
  {
408
332
  required: damLocationType === "external",
409
333
  message: "Url is required",
410
334
  },
411
- ], children: _jsx(Input, { placeholder: "Url", disabled: damLocationType === "internal" || isEditMode }) }), _jsx(Form.Item, { label: "Region", name: ["damLocationDetails", "region"], rules: [
335
+ ], children: _jsx(Input, { placeholder: "Url", disabled: damLocationType === "internal" }) }), _jsx(Form.Item, { label: "Region", name: ["damLocationDetails", "region"], rules: [
412
336
  {
413
337
  required: damLocationType === "external",
414
338
  message: "Region is required",
415
339
  },
416
- ], children: _jsx(Input, { placeholder: "Region", disabled: damLocationType === "internal" || isEditMode }) })] }))] }), _jsx(Form.Item, { label: "Subdomain", name: "subdomain", rules: [
340
+ ], children: _jsx(Input, { placeholder: "Region", disabled: damLocationType === "internal" }) })] }))] }), _jsx(Form.Item, { label: "Subdomain", name: "subdomain", rules: [
417
341
  {
418
342
  required: true,
419
343
  message: "Subdomain is required",
420
344
  },
421
- ], children: _jsx(Input, { placeholder: "Subdomain", disabled: isEditMode }) }), _jsx(Form.Item, { name: "showFilePreview", valuePropName: "checked", initialValue: false, children: _jsx(Checkbox, { children: "Show File Preview Editor" }) }), _jsx(Form.Item, { children: _jsx(Button, { htmlType: "submit", type: "primary", block: true, loading: loading, disabled: !isFormValid || loading, children: "Submit" }) })] })) }));
345
+ ], children: _jsx(Input, { placeholder: "Subdomain" }) }), _jsx(Form.Item, { name: "showFilePreview", valuePropName: "checked", initialValue: false, children: _jsx(Checkbox, { children: "Show File Preview Editor" }) }), _jsx(Form.Item, { children: _jsx(Button, { htmlType: "submit", type: "primary", block: true, loading: loading, children: "Submit" }) })] })) }));
422
346
  };
423
347
  export default CreateClientForm;
@@ -9,49 +9,32 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  };
10
10
  import { jsx as _jsx } from "react/jsx-runtime";
11
11
  import { Button } from "antd";
12
- import { useState } from "react";
13
- import axios from "axios";
12
+ import { useMemo, useState } from "react";
14
13
  import { showNotification } from "../common/notifications";
15
14
  import { NotificationStatus } from "../utilities/constants/interface";
16
15
  import { SOMETHING_WENT_WRONG } from "../utilities/constants/messages";
17
16
  import { get } from "lodash";
18
- import { REFRESH_KEY_URL, USER_LOGIN } from "../utilities/constants/apiUrls";
17
+ import { REFRESH_KEY_URL } from "../utilities/constants/apiUrls";
19
18
  import { useDamConfig } from "../hocs/DamConfigContext";
20
- import { getBaseUrl } from "../hocs/helpers";
19
+ import { createApiClient } from "../hocs/configureAxios";
21
20
  export default function RefreshKeyBtn() {
22
21
  const [loading, setLoading] = useState(false);
23
22
  const damConfig = useDamConfig();
24
- const { damAccessKey, secretKey, subdomain, teamIds, appType } = damConfig;
23
+ const { damAccessKey, secretKey } = damConfig;
24
+ const api = useMemo(() => createApiClient(damConfig), [damConfig]);
25
25
  const onRefreshKey = () => __awaiter(this, void 0, void 0, function* () {
26
- if (!damAccessKey || !secretKey || !subdomain) {
27
- showNotification("Access key, secret key, and subdomain are required to refresh", NotificationStatus.ERROR);
28
- return;
29
- }
30
26
  setLoading(true);
31
27
  try {
32
- // Step 1: Login with keys to get DAM token (same as Edit Client flow)
33
- const loginResponse = yield axios.post(getBaseUrl(appType) + USER_LOGIN, {
28
+ const response = yield api.put(REFRESH_KEY_URL, {
34
29
  accessKey: damAccessKey,
35
30
  secretKey,
36
- subdomain,
37
- teams: teamIds && teamIds.length > 0 ? teamIds : [""],
38
- });
39
- const token = get(loginResponse, "data.data.access_token");
40
- if (!token) {
41
- throw new Error("Failed to get token from login");
42
- }
43
- // Step 2: Call refresh API with the DAM token (include subdomain header)
44
- const response = yield axios.put(getBaseUrl(appType) + REFRESH_KEY_URL, { accessKey: damAccessKey, secretKey }, {
45
- headers: {
46
- Authorization: `Bearer ${token}`,
47
- subdomain: subdomain,
48
- },
49
31
  });
32
+ // console.log(response);
50
33
  setLoading(false);
51
34
  showNotification(get(response, "data.message", "Key refreshed successfully"), NotificationStatus.SUCCESS);
52
35
  }
53
36
  catch (error) {
54
- showNotification(get(error, "response.data.message", get(error, "message", SOMETHING_WENT_WRONG)), NotificationStatus.ERROR);
37
+ showNotification(get(error, "message", SOMETHING_WENT_WRONG), NotificationStatus.ERROR);
55
38
  setLoading(false);
56
39
  }
57
40
  });
@@ -143,7 +143,6 @@ export const DamConfigProvider = ({ children, config }) => {
143
143
  loading,
144
144
  setAccessToken,
145
145
  setDamUser,
146
- setBrand,
147
146
  appType,
148
147
  setRootFolderId,
149
148
  rootFolderId,
@@ -44,10 +44,10 @@ export const createApiClient = ({ accessToken, appType, subdomain, damAccessKey,
44
44
  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;
45
45
  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;
46
46
  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;
47
- setAccessToken === null || setAccessToken === void 0 ? void 0 : setAccessToken(token);
48
- setDamUser === null || setDamUser === void 0 ? void 0 : setDamUser(userData);
49
- setBrand === null || setBrand === void 0 ? void 0 : setBrand(brandData);
50
- setRootFolderId === null || setRootFolderId === void 0 ? void 0 : setRootFolderId(get(response, "data.data.rootFolderId"));
47
+ setAccessToken(token);
48
+ setDamUser(userData);
49
+ setBrand(brandData);
50
+ setRootFolderId(get(response, "data.data.rootFolderId"));
51
51
  originalRequest.headers["Authorization"] = `Bearer ${token}`;
52
52
  return api(originalRequest);
53
53
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bindu-dashing/dam-solution-v2",
3
- "version": "5.8.200",
3
+ "version": "5.8.202",
4
4
  "dependencies": {
5
5
  "@ant-design/icons": "^5.0.1",
6
6
  "@emoji-mart/data": "^1.2.1",