@bindu-dashing/dam-solution-v2 5.8.159 → 5.8.160
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.
|
@@ -43,20 +43,33 @@ const CreateClientForm = ({ teamsApi, username, password, toggleShow, onSuccess,
|
|
|
43
43
|
setFetchingClientData(true);
|
|
44
44
|
try {
|
|
45
45
|
let fetchedData;
|
|
46
|
-
|
|
47
|
-
|
|
46
|
+
let brandId = existingClientData === null || existingClientData === void 0 ? void 0 : existingClientData.brandId;
|
|
47
|
+
// If brandId is not provided, try to get it from subdomain first
|
|
48
|
+
if (!brandId && (existingClientData === null || existingClientData === void 0 ? void 0 : existingClientData.subdomain)) {
|
|
49
|
+
console.log("brandId not found, fetching by subdomain first:", existingClientData.subdomain);
|
|
50
|
+
const subdomainResponse = yield api.get(`${FETCH_BRAND_USING_SUBDOMAIN}?subdomain=${existingClientData.subdomain}`);
|
|
51
|
+
const subdomainData = get(subdomainResponse, "data.data", {});
|
|
52
|
+
brandId = get(subdomainData, "_id");
|
|
53
|
+
console.log("Extracted brandId from subdomain response:", brandId);
|
|
54
|
+
}
|
|
55
|
+
// Prioritize brandId if available, use brands/details endpoint
|
|
56
|
+
if (brandId) {
|
|
57
|
+
console.log("Fetching brand details using brandId:", brandId);
|
|
48
58
|
// Use reusable fetchBrandDetails function
|
|
49
|
-
fetchedData = yield fetchBrandDetails(api,
|
|
59
|
+
fetchedData = yield fetchBrandDetails(api, brandId);
|
|
60
|
+
console.log("Fetched client data from brands/details:", fetchedData);
|
|
50
61
|
}
|
|
51
62
|
else if (existingClientData === null || existingClientData === void 0 ? void 0 : existingClientData.subdomain) {
|
|
63
|
+
console.log("No brandId available, using subdomain endpoint:", existingClientData.subdomain);
|
|
52
64
|
const response = yield api.get(`${FETCH_BRAND_USING_SUBDOMAIN}?subdomain=${existingClientData.subdomain}`);
|
|
53
65
|
fetchedData = get(response, "data.data", {});
|
|
66
|
+
console.log("Fetched client data from subdomain:", fetchedData);
|
|
54
67
|
}
|
|
55
68
|
else {
|
|
69
|
+
console.warn("No brandId or subdomain provided");
|
|
56
70
|
setFetchingClientData(false);
|
|
57
71
|
return;
|
|
58
72
|
}
|
|
59
|
-
console.log("Fetched client data:", fetchedData);
|
|
60
73
|
// Store client data in state
|
|
61
74
|
setClientData(fetchedData);
|
|
62
75
|
setTeamsFetched(false); // Reset teams fetched flag when new client data is loaded
|
|
@@ -92,7 +105,7 @@ const CreateClientForm = ({ teamsApi, username, password, toggleShow, onSuccess,
|
|
|
92
105
|
}
|
|
93
106
|
});
|
|
94
107
|
fetchClientData();
|
|
95
|
-
}, [isEditMode, existingClientData === null || existingClientData === void 0 ? void 0 : existingClientData.brandId, existingClientData === null || existingClientData === void 0 ? void 0 : existingClientData.subdomain, api]);
|
|
108
|
+
}, [isEditMode, existingClientData === null || existingClientData === void 0 ? void 0 : existingClientData.brandId, existingClientData === null || existingClientData === void 0 ? void 0 : existingClientData.subdomain, api, form]);
|
|
96
109
|
const onFinish = (data) => __awaiter(void 0, void 0, void 0, function* () {
|
|
97
110
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
98
111
|
try {
|