oa-componentbook 1.0.1-stage.435 → 1.0.1-stage.437
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.
|
@@ -123,12 +123,16 @@ function EntityOverviewLayout(_ref) {
|
|
|
123
123
|
});
|
|
124
124
|
};
|
|
125
125
|
const handleCloseDrawer = async () => {
|
|
126
|
-
|
|
127
|
-
//
|
|
128
|
-
const
|
|
129
|
-
const
|
|
130
|
-
const currentMisc = state === null || state === void 0 ? void 0 : state.misc; // Preserve misc to maintain enterpriseId
|
|
126
|
+
var _state$misc2, _state$misc3, _state$misc4;
|
|
127
|
+
// Get selected enterprise from session storage to ensure profile data reflects correct enterprise
|
|
128
|
+
const selectedEnterpriseFromStorage = JSON.parse(sessionStorage.getItem('selectedEnterprise') || 'null');
|
|
129
|
+
const enterpriseIdFromStorage = (selectedEnterpriseFromStorage === null || selectedEnterpriseFromStorage === void 0 ? void 0 : selectedEnterpriseFromStorage.value) || (selectedEnterpriseFromStorage === null || selectedEnterpriseFromStorage === void 0 ? void 0 : selectedEnterpriseFromStorage.enterpriseId) || (selectedEnterpriseFromStorage === null || selectedEnterpriseFromStorage === void 0 ? void 0 : selectedEnterpriseFromStorage.id);
|
|
131
130
|
|
|
131
|
+
// Update misc with enterpriseId from session storage
|
|
132
|
+
const currentMisc = _objectSpread(_objectSpread({}, (_state$misc2 = state === null || state === void 0 ? void 0 : state.misc) !== null && _state$misc2 !== void 0 ? _state$misc2 : {}), {}, {
|
|
133
|
+
enterpriseId: enterpriseIdFromStorage || (state === null || state === void 0 || (_state$misc3 = state.misc) === null || _state$misc3 === void 0 ? void 0 : _state$misc3.enterpriseId),
|
|
134
|
+
enterpriseData: selectedEnterpriseFromStorage || (state === null || state === void 0 || (_state$misc4 = state.misc) === null || _state$misc4 === void 0 ? void 0 : _state$misc4.enterpriseData)
|
|
135
|
+
});
|
|
132
136
|
dispatch({
|
|
133
137
|
type: _entityOverviewLayoutReducer.actionTypes.SET_LOADING,
|
|
134
138
|
payload: true
|
|
@@ -137,35 +141,50 @@ function EntityOverviewLayout(_ref) {
|
|
|
137
141
|
const {
|
|
138
142
|
error,
|
|
139
143
|
data
|
|
140
|
-
} = await (getInitialData === null || getInitialData === void 0 ? void 0 : getInitialData(_objectSpread({}, currentMisc
|
|
144
|
+
} = await (getInitialData === null || getInitialData === void 0 ? void 0 : getInitialData(_objectSpread({}, currentMisc)));
|
|
141
145
|
if (error) {
|
|
142
146
|
showErrorNotification(error);
|
|
143
147
|
const dynamicConfig = (0, _staticConfigResolver.default)(config, {});
|
|
144
|
-
//
|
|
145
|
-
if (currentProfileData) {
|
|
146
|
-
dynamicConfig.profileData = currentProfileData;
|
|
147
|
-
}
|
|
148
|
-
if (currentAccordionData) {
|
|
149
|
-
dynamicConfig.accordionData = currentAccordionData;
|
|
150
|
-
}
|
|
148
|
+
// Update misc with enterpriseId from session storage
|
|
151
149
|
if (currentMisc) {
|
|
152
|
-
dynamicConfig.misc = currentMisc;
|
|
150
|
+
dynamicConfig.misc = currentMisc;
|
|
153
151
|
}
|
|
152
|
+
// Don't preserve profile data - let it be re-rendered from config with correct enterprise
|
|
153
|
+
// Don't preserve accordion data - use fresh data from API (or empty if error)
|
|
154
154
|
dispatch({
|
|
155
155
|
type: _entityOverviewLayoutReducer.actionTypes.INIT,
|
|
156
156
|
payload: dynamicConfig
|
|
157
157
|
});
|
|
158
158
|
} else {
|
|
159
159
|
const dynamicConfig = (0, _staticConfigResolver.default)(config, data !== null && data !== void 0 ? data : {});
|
|
160
|
-
//
|
|
161
|
-
if (
|
|
162
|
-
dynamicConfig.
|
|
160
|
+
// Update misc with enterpriseId from session storage
|
|
161
|
+
if (currentMisc) {
|
|
162
|
+
dynamicConfig.misc = currentMisc;
|
|
163
163
|
}
|
|
164
|
-
|
|
165
|
-
|
|
164
|
+
// Use fresh profile data from API response to reflect correct enterprise
|
|
165
|
+
if (data !== null && data !== void 0 && data.data) {
|
|
166
|
+
dispatch({
|
|
167
|
+
type: _entityOverviewLayoutReducer.actionTypes.UPDATE_PROFILE_DATA,
|
|
168
|
+
payload: data.data
|
|
169
|
+
});
|
|
166
170
|
}
|
|
167
|
-
|
|
168
|
-
|
|
171
|
+
// Use fresh accordion data from API response (includes newly added users)
|
|
172
|
+
// Check for both 'accordionData' and 'accordianData' (typo in API response)
|
|
173
|
+
const freshAccordionData = (data === null || data === void 0 ? void 0 : data.accordionData) || (data === null || data === void 0 ? void 0 : data.accordianData);
|
|
174
|
+
if (freshAccordionData) {
|
|
175
|
+
let accordionDataToUpdate;
|
|
176
|
+
if (Array.isArray(freshAccordionData)) {
|
|
177
|
+
accordionDataToUpdate = freshAccordionData;
|
|
178
|
+
} else if (freshAccordionData.data && Array.isArray(freshAccordionData.data)) {
|
|
179
|
+
accordionDataToUpdate = freshAccordionData.data;
|
|
180
|
+
} else {
|
|
181
|
+
accordionDataToUpdate = freshAccordionData;
|
|
182
|
+
}
|
|
183
|
+
// Update accordion data with fresh data from API
|
|
184
|
+
dispatch({
|
|
185
|
+
type: _entityOverviewLayoutReducer.actionTypes.UPDATE_ACCORDION_DATA,
|
|
186
|
+
payload: accordionDataToUpdate
|
|
187
|
+
});
|
|
169
188
|
}
|
|
170
189
|
dispatch({
|
|
171
190
|
type: _entityOverviewLayoutReducer.actionTypes.INIT,
|
|
@@ -174,15 +193,9 @@ function EntityOverviewLayout(_ref) {
|
|
|
174
193
|
}
|
|
175
194
|
} else {
|
|
176
195
|
const dynamicConfig = (0, _staticConfigResolver.default)(config, {});
|
|
177
|
-
//
|
|
178
|
-
if (currentProfileData) {
|
|
179
|
-
dynamicConfig.profileData = currentProfileData;
|
|
180
|
-
}
|
|
181
|
-
if (currentAccordionData) {
|
|
182
|
-
dynamicConfig.accordionData = currentAccordionData;
|
|
183
|
-
}
|
|
196
|
+
// Update misc with enterpriseId from session storage
|
|
184
197
|
if (currentMisc) {
|
|
185
|
-
dynamicConfig.misc = currentMisc;
|
|
198
|
+
dynamicConfig.misc = currentMisc;
|
|
186
199
|
}
|
|
187
200
|
dispatch({
|
|
188
201
|
type: _entityOverviewLayoutReducer.actionTypes.INIT,
|
|
@@ -237,7 +250,6 @@ function EntityOverviewLayout(_ref) {
|
|
|
237
250
|
// Update accordion data if provided in the response
|
|
238
251
|
// Note: API returns 'accordianData' (typo) but we check for both
|
|
239
252
|
const accordionDataFromResponse = (data === null || data === void 0 ? void 0 : data.accordionData) || (data === null || data === void 0 ? void 0 : data.accordianData);
|
|
240
|
-
console.log('Checking accordion data from response:', accordionDataFromResponse);
|
|
241
253
|
|
|
242
254
|
// Check if accordionDataFromResponse is an object with data array, or if it's directly an array
|
|
243
255
|
if (accordionDataFromResponse) {
|
|
@@ -250,7 +262,6 @@ function EntityOverviewLayout(_ref) {
|
|
|
250
262
|
accordionDataToUpdate = accordionDataFromResponse.data;
|
|
251
263
|
}
|
|
252
264
|
if (accordionDataToUpdate) {
|
|
253
|
-
console.log('Dispatching UPDATE_ACCORDION_DATA with:', accordionDataToUpdate);
|
|
254
265
|
dispatch({
|
|
255
266
|
type: _entityOverviewLayoutReducer.actionTypes.UPDATE_ACCORDION_DATA,
|
|
256
267
|
payload: accordionDataToUpdate
|
|
@@ -259,14 +270,13 @@ function EntityOverviewLayout(_ref) {
|
|
|
259
270
|
console.log('Accordion data structure not recognized:', accordionDataFromResponse);
|
|
260
271
|
}
|
|
261
272
|
} else {
|
|
262
|
-
console.log('Accordion data not found. Checking refresh option...');
|
|
263
273
|
if (getInitialData && config !== null && config !== void 0 && config.refreshAccordionOnSwitch) {
|
|
264
|
-
var _state$
|
|
274
|
+
var _state$misc5;
|
|
265
275
|
// Optionally refresh accordion data by calling getInitialData again
|
|
266
276
|
const {
|
|
267
277
|
error: refreshError,
|
|
268
278
|
data: refreshData
|
|
269
|
-
} = await (getInitialData === null || getInitialData === void 0 ? void 0 : getInitialData(_objectSpread(_objectSpread({}, (_state$
|
|
279
|
+
} = await (getInitialData === null || getInitialData === void 0 ? void 0 : getInitialData(_objectSpread(_objectSpread({}, (_state$misc5 = state === null || state === void 0 ? void 0 : state.misc) !== null && _state$misc5 !== void 0 ? _state$misc5 : {}), {}, {
|
|
270
280
|
selectedValue
|
|
271
281
|
})));
|
|
272
282
|
if (!refreshError && refreshData !== null && refreshData !== void 0 && refreshData.accordionData) {
|
|
@@ -8,6 +8,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
8
8
|
exports.default = _default;
|
|
9
9
|
require("core-js/modules/web.dom-collections.iterator.js");
|
|
10
10
|
require("core-js/modules/es.promise.js");
|
|
11
|
+
require("core-js/modules/es.regexp.constructor.js");
|
|
12
|
+
require("core-js/modules/es.regexp.exec.js");
|
|
13
|
+
require("core-js/modules/es.regexp.to-string.js");
|
|
11
14
|
var _react = _interopRequireWildcard(require("react"));
|
|
12
15
|
var _antd = require("antd");
|
|
13
16
|
var _EditOutlined = _interopRequireDefault(require("@material-ui/icons/EditOutlined"));
|
|
@@ -239,15 +242,38 @@ function _default(_ref) {
|
|
|
239
242
|
};
|
|
240
243
|
const canDelete = users.length > 1;
|
|
241
244
|
const isEditing = editingUserId !== null || addingUser;
|
|
245
|
+
|
|
246
|
+
// Process rules to handle checkValidator structure (similar to FormWidget)
|
|
247
|
+
const processRules = rules => {
|
|
248
|
+
if (!rules || !Array.isArray(rules)) {
|
|
249
|
+
return rules;
|
|
250
|
+
}
|
|
251
|
+
return rules.map(r => {
|
|
252
|
+
// If rule has checkValidator, extract the nested rule object
|
|
253
|
+
if (r !== null && r !== void 0 && r.checkValidator && r !== null && r !== void 0 && r.rule) {
|
|
254
|
+
let processedRule = _objectSpread({}, r.rule);
|
|
255
|
+
|
|
256
|
+
// Handle pattern conversion if it's a string
|
|
257
|
+
if (processedRule.pattern && typeof processedRule.pattern === "string") {
|
|
258
|
+
processedRule.pattern = new RegExp(processedRule.pattern);
|
|
259
|
+
}
|
|
260
|
+
return processedRule;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
// Return rule as-is if it doesn't have checkValidator structure
|
|
264
|
+
return r;
|
|
265
|
+
});
|
|
266
|
+
};
|
|
242
267
|
const renderFormField = field => {
|
|
243
268
|
var _field$options;
|
|
244
269
|
const fieldNameWithPrefix = "".concat(fieldName, "_").concat(field.key);
|
|
270
|
+
const processedRules = processRules(field.rules);
|
|
245
271
|
switch (field.widget || field.type) {
|
|
246
272
|
case "input":
|
|
247
273
|
return /*#__PURE__*/_react.default.createElement(_antd.Form.Item, {
|
|
248
274
|
name: fieldNameWithPrefix,
|
|
249
275
|
label: field.label,
|
|
250
|
-
rules:
|
|
276
|
+
rules: processedRules,
|
|
251
277
|
style: {
|
|
252
278
|
marginBottom: 16
|
|
253
279
|
}
|
|
@@ -258,7 +284,7 @@ function _default(_ref) {
|
|
|
258
284
|
return /*#__PURE__*/_react.default.createElement(_antd.Form.Item, {
|
|
259
285
|
name: fieldNameWithPrefix,
|
|
260
286
|
label: field.label,
|
|
261
|
-
rules:
|
|
287
|
+
rules: processedRules,
|
|
262
288
|
style: {
|
|
263
289
|
marginBottom: 16
|
|
264
290
|
}
|
|
@@ -273,7 +299,7 @@ function _default(_ref) {
|
|
|
273
299
|
return /*#__PURE__*/_react.default.createElement(_antd.Form.Item, {
|
|
274
300
|
name: fieldNameWithPrefix,
|
|
275
301
|
label: field.label,
|
|
276
|
-
rules:
|
|
302
|
+
rules: processedRules,
|
|
277
303
|
style: {
|
|
278
304
|
marginBottom: 16
|
|
279
305
|
}
|