@bindu-dashing/dam-solution-v2 5.8.163 → 5.8.164
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);
|
|
@@ -204,7 +209,26 @@ const CreateClientForm = ({ teamsApi, username, password, toggleShow, onSuccess,
|
|
|
204
209
|
rootPath: (_h = data === null || data === void 0 ? void 0 : data.damLocationDetails) === null || _h === void 0 ? void 0 : _h.rootPath,
|
|
205
210
|
} });
|
|
206
211
|
setLoading(true);
|
|
207
|
-
|
|
212
|
+
let response;
|
|
213
|
+
const baseUrl = getBaseUrl(appType);
|
|
214
|
+
if (isEditMode && brandIdForUpdate && authToken) {
|
|
215
|
+
// Update existing client: PUT to /brands/{brandId}
|
|
216
|
+
console.log("Updating client with brandId:", brandIdForUpdate);
|
|
217
|
+
console.log("Update payload:", values);
|
|
218
|
+
const putResponse = yield axios.put(`${baseUrl}/brands/${brandIdForUpdate}`, values, {
|
|
219
|
+
headers: {
|
|
220
|
+
'Authorization': `Bearer ${authToken}`,
|
|
221
|
+
'Content-Type': 'application/json',
|
|
222
|
+
'accept': 'application/json, text/plain, */*'
|
|
223
|
+
}
|
|
224
|
+
});
|
|
225
|
+
// Extract data from axios response (API returns { data: {...} } or { data: { data: {...} } })
|
|
226
|
+
response = get(putResponse, "data.data", get(putResponse, "data", putResponse));
|
|
227
|
+
}
|
|
228
|
+
else {
|
|
229
|
+
// Create new client: POST to /brands/sub-brand
|
|
230
|
+
response = yield api.post(CREATE_SUB_BRAND, values);
|
|
231
|
+
}
|
|
208
232
|
setLoading(false);
|
|
209
233
|
showNotification((_j = response === null || response === void 0 ? void 0 : response.message) !== null && _j !== void 0 ? _j : (get(response, "message") || CREATE_SUCCESS), NotificationStatus.SUCCESS);
|
|
210
234
|
toggleShow();
|