oa-componentbook 1.0.1-stage.425 → 1.0.1-stage.426
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.
|
@@ -46,8 +46,12 @@ function UserManagementWidget(_ref) {
|
|
|
46
46
|
const [addingUser, setAddingUser] = (0, _react.useState)(false);
|
|
47
47
|
const [deleteModalVisible, setDeleteModalVisible] = (0, _react.useState)(false);
|
|
48
48
|
const [userToDelete, setUserToDelete] = (0, _react.useState)(null);
|
|
49
|
-
const [updateTrigger, setUpdateTrigger] = (0, _react.useState)(0);
|
|
50
49
|
const notificationRef = (0, _react.useRef)(null);
|
|
50
|
+
|
|
51
|
+
// Use local state for users, initialized from initialData only
|
|
52
|
+
const [users, setUsers] = (0, _react.useState)(() => {
|
|
53
|
+
return Array.isArray(initialData) ? initialData : [];
|
|
54
|
+
});
|
|
51
55
|
const openNotification = (0, _react.useCallback)(params => notificationRef.current.openNotification(params), []);
|
|
52
56
|
const showErrorNotification = message => {
|
|
53
57
|
openNotification({
|
|
@@ -68,23 +72,21 @@ function UserManagementWidget(_ref) {
|
|
|
68
72
|
});
|
|
69
73
|
};
|
|
70
74
|
|
|
71
|
-
//
|
|
72
|
-
const users = form.getFieldValue(fieldName) || initialData;
|
|
73
|
-
|
|
74
|
-
// Update form state with new user list and trigger re-render
|
|
75
|
+
// Update both local state and form state
|
|
75
76
|
const updateUsers = newUsers => {
|
|
77
|
+
setUsers(newUsers);
|
|
76
78
|
form.setFieldsValue({
|
|
77
79
|
[fieldName]: newUsers
|
|
78
80
|
});
|
|
79
|
-
setUpdateTrigger(prev => prev + 1); // Trigger re-render
|
|
80
81
|
};
|
|
81
82
|
|
|
82
|
-
//
|
|
83
|
+
// Sync users state with form and initialData
|
|
83
84
|
(0, _react.useEffect)(() => {
|
|
84
|
-
const
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
85
|
+
const defaultUsers = Array.isArray(initialData) ? initialData : [];
|
|
86
|
+
setUsers(defaultUsers);
|
|
87
|
+
form.setFieldsValue({
|
|
88
|
+
[fieldName]: defaultUsers
|
|
89
|
+
});
|
|
88
90
|
}, [initialData, fieldName, form]);
|
|
89
91
|
const handleEdit = user => {
|
|
90
92
|
setEditingUserId(user.id);
|