@bindu-dashing/dam-solution-v2 5.8.163 → 5.8.165
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.
|
@@ -29,6 +29,8 @@ const CreateClientForm = ({ teamsApi, username, password, toggleShow, onSuccess,
|
|
|
29
29
|
const [filteredTeams, setFilteredTeams] = useState([]);
|
|
30
30
|
const [clientData, setClientData] = useState(null);
|
|
31
31
|
const [teamsFetched, setTeamsFetched] = useState(false);
|
|
32
|
+
const [authToken, setAuthToken] = useState(null);
|
|
33
|
+
const [brandIdForUpdate, setBrandIdForUpdate] = useState(null);
|
|
32
34
|
const api = useMemo(() => createApiClient(damConfig), [damConfig]);
|
|
33
35
|
const [form] = Form.useForm();
|
|
34
36
|
const isEditMode = !!existingClientData;
|
|
@@ -100,6 +102,9 @@ const CreateClientForm = ({ teamsApi, username, password, toggleShow, onSuccess,
|
|
|
100
102
|
setFetchingClientData(false);
|
|
101
103
|
return;
|
|
102
104
|
}
|
|
105
|
+
// Store token and brandId for use in update API
|
|
106
|
+
setAuthToken(token);
|
|
107
|
+
setBrandIdForUpdate(loginBrandId);
|
|
103
108
|
}
|
|
104
109
|
catch (loginError) {
|
|
105
110
|
console.error("Error logging in with DAM credentials:", loginError);
|
|
@@ -179,7 +184,11 @@ const CreateClientForm = ({ teamsApi, username, password, toggleShow, onSuccess,
|
|
|
179
184
|
const finalTeamsApi = teamsApiDetailsFromData.teamsApi || teamsApi;
|
|
180
185
|
const finalUsername = teamsApiDetailsFromData.username || username;
|
|
181
186
|
const finalPassword = teamsApiDetailsFromData.password || password;
|
|
182
|
-
|
|
187
|
+
// Convert adminTeams to strings for API (API expects strings like ["547"] not numbers like [547])
|
|
188
|
+
const adminTeamsAsStrings = Array.isArray(data.adminTeams)
|
|
189
|
+
? data.adminTeams.map((team) => String(team))
|
|
190
|
+
: [];
|
|
191
|
+
const values = Object.assign(Object.assign({}, data), { adminTeams: adminTeamsAsStrings, showFilePreview: (_a = data.showFilePreview) !== null && _a !== void 0 ? _a : false, accessKey: appType == "reactJs"
|
|
183
192
|
? process.env.REACT_APP_MIXDRIVE_CLIENT_PARENT_ACCESS_KEY
|
|
184
193
|
: process.env.NEXT_PUBLIC_MIXDRIVE_CLIENT_PARENT_ACCESS_KEY, secretKey: appType == "reactJs"
|
|
185
194
|
? process.env.REACT_APP_MIXDRIVE_CLIENT_PARENT_SECRET_KEY
|
|
@@ -204,7 +213,26 @@ const CreateClientForm = ({ teamsApi, username, password, toggleShow, onSuccess,
|
|
|
204
213
|
rootPath: (_h = data === null || data === void 0 ? void 0 : data.damLocationDetails) === null || _h === void 0 ? void 0 : _h.rootPath,
|
|
205
214
|
} });
|
|
206
215
|
setLoading(true);
|
|
207
|
-
|
|
216
|
+
let response;
|
|
217
|
+
const baseUrl = getBaseUrl(appType);
|
|
218
|
+
if (isEditMode && brandIdForUpdate && authToken) {
|
|
219
|
+
// Update existing client: PUT to /brands/{brandId}
|
|
220
|
+
console.log("Updating client with brandId:", brandIdForUpdate);
|
|
221
|
+
console.log("Update payload:", values);
|
|
222
|
+
const putResponse = yield axios.put(`${baseUrl}/brands/${brandIdForUpdate}`, values, {
|
|
223
|
+
headers: {
|
|
224
|
+
'Authorization': `Bearer ${authToken}`,
|
|
225
|
+
'Content-Type': 'application/json',
|
|
226
|
+
'accept': 'application/json, text/plain, */*'
|
|
227
|
+
}
|
|
228
|
+
});
|
|
229
|
+
// Extract data from axios response (API returns { data: {...} } or { data: { data: {...} } })
|
|
230
|
+
response = get(putResponse, "data.data", get(putResponse, "data", putResponse));
|
|
231
|
+
}
|
|
232
|
+
else {
|
|
233
|
+
// Create new client: POST to /brands/sub-brand
|
|
234
|
+
response = yield api.post(CREATE_SUB_BRAND, values);
|
|
235
|
+
}
|
|
208
236
|
setLoading(false);
|
|
209
237
|
showNotification((_j = response === null || response === void 0 ? void 0 : response.message) !== null && _j !== void 0 ? _j : (get(response, "message") || CREATE_SUCCESS), NotificationStatus.SUCCESS);
|
|
210
238
|
toggleShow();
|