@dexteel/mesf-core 7.8.0 → 7.8.1

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.
@@ -1,3 +1,3 @@
1
1
  {
2
- ".": "7.8.0"
2
+ ".": "7.8.1"
3
3
  }
package/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Changelog
2
2
 
3
+ ## [7.8.1](https://github.com/dexteel/mesf-core-frontend/compare/@dexteel/mesf-core-v7.8.0...@dexteel/mesf-core-v7.8.1) (2025-12-22)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * **Create User:** enhance user creation process with password and profile management ([9400641](https://github.com/dexteel/mesf-core-frontend/commit/94006418d13d944364cacf410a94b385f48b6140))
9
+ * **Edit User:** streamline user update process and improve profile ID handling ([f1397e5](https://github.com/dexteel/mesf-core-frontend/commit/f1397e58496fa8e9f4d10bd4a4d84db2af3c08e8))
10
+
3
11
  ## [7.8.0](https://github.com/dexteel/mesf-core-frontend/compare/@dexteel/mesf-core-v7.7.0...@dexteel/mesf-core-v7.8.0) (2025-12-22)
4
12
 
5
13
 
package/dist/index.esm.js CHANGED
@@ -4578,36 +4578,36 @@ var CreateUser = function (_a) {
4578
4578
  setOpen(false);
4579
4579
  };
4580
4580
  var UserName = watch("UserName");
4581
- var profilesIds = watch("ProfilesId");
4582
- var setProfiles = useMutation({
4583
- mutationFn: setProfilesToUser,
4584
- onError: function (error) {
4585
- setError(error.message);
4586
- },
4587
- });
4588
4581
  var createUser = useMutation({
4589
- mutationFn: upsertUser,
4590
- onSuccess: function (userCreatedId) { return __awaiter(void 0, void 0, void 0, function () {
4582
+ mutationFn: function (data) { return __awaiter(void 0, void 0, void 0, function () {
4583
+ var userId, passwordResult;
4591
4584
  return __generator(this, function (_a) {
4592
4585
  switch (_a.label) {
4593
- case 0:
4594
- _a.trys.push([0, 2, , 3]);
4595
- return [4 /*yield*/, setProfiles.mutateAsync({
4596
- UserId: userCreatedId,
4597
- profileIds: profilesIds,
4598
- })];
4586
+ case 0: return [4 /*yield*/, upsertUser(data)];
4599
4587
  case 1:
4600
- _a.sent();
4601
- setOpen(true);
4602
- onHide(true);
4603
- return [3 /*break*/, 3];
4588
+ userId = _a.sent();
4589
+ return [4 /*yield*/, setPassword(userId, data.UserName)];
4604
4590
  case 2:
4591
+ passwordResult = _a.sent();
4592
+ if (!passwordResult.ok) {
4593
+ throw new Error(passwordResult.message || "Error setting password");
4594
+ }
4595
+ if (!(data.ProfilesId && Array.isArray(data.ProfilesId))) return [3 /*break*/, 4];
4596
+ return [4 /*yield*/, setProfilesToUser({
4597
+ UserId: userId,
4598
+ profileIds: data.ProfilesId,
4599
+ })];
4600
+ case 3:
4605
4601
  _a.sent();
4606
- return [3 /*break*/, 3];
4607
- case 3: return [2 /*return*/];
4602
+ _a.label = 4;
4603
+ case 4: return [2 /*return*/, userId];
4608
4604
  }
4609
4605
  });
4610
4606
  }); },
4607
+ onSuccess: function () {
4608
+ setOpen(true);
4609
+ onHide(true);
4610
+ },
4611
4611
  onError: function (error) {
4612
4612
  setError(error.message);
4613
4613
  },
@@ -5072,41 +5072,41 @@ var EditUser = function (_a) {
5072
5072
  }
5073
5073
  setOpen(false);
5074
5074
  };
5075
- var setProfiles = useMutation({
5076
- mutationFn: setProfilesToUser,
5077
- onError: function (error) {
5078
- setError(error.message);
5079
- },
5080
- });
5081
5075
  var editUser = useMutation({
5082
- mutationFn: upsertUser,
5083
- onSuccess: function (userUpdatedId) { return __awaiter(void 0, void 0, void 0, function () {
5084
- var currentLoggedUserId;
5076
+ mutationFn: function (data) { return __awaiter(void 0, void 0, void 0, function () {
5077
+ var userUpdatedId, validProfileIds;
5085
5078
  return __generator(this, function (_a) {
5086
5079
  switch (_a.label) {
5087
- case 0:
5088
- _a.trys.push([0, 2, , 3]);
5089
- return [4 /*yield*/, setProfiles.mutateAsync({
5080
+ case 0: return [4 /*yield*/, upsertUser(data)];
5081
+ case 1:
5082
+ userUpdatedId = _a.sent();
5083
+ validProfileIds = Array.isArray(profilesIds)
5084
+ ? profilesIds.filter(function (id) { return !isNaN(id) && id > 0; })
5085
+ : [];
5086
+ // Step 3: Set the profiles for the user
5087
+ return [4 /*yield*/, setProfilesToUser({
5090
5088
  UserId: userUpdatedId,
5091
- profileIds: profilesIds,
5089
+ profileIds: validProfileIds,
5092
5090
  })];
5093
- case 1:
5094
- _a.sent();
5095
- currentLoggedUserId = getUserId();
5096
- if (currentLoggedUserId === userUpdatedId) {
5097
- // Update context - the area-selector effect will update the name
5098
- setDefaultAreaId(defaultAssetId);
5099
- }
5100
- onHide(true);
5101
- setOpen(true);
5102
- return [3 /*break*/, 3];
5103
5091
  case 2:
5092
+ // Step 3: Set the profiles for the user
5104
5093
  _a.sent();
5105
- return [3 /*break*/, 3];
5106
- case 3: return [2 /*return*/];
5094
+ return [2 /*return*/, userUpdatedId];
5107
5095
  }
5108
5096
  });
5109
5097
  }); },
5098
+ onSuccess: function (userUpdatedId) { return __awaiter(void 0, void 0, void 0, function () {
5099
+ var currentLoggedUserId;
5100
+ return __generator(this, function (_a) {
5101
+ currentLoggedUserId = getUserId();
5102
+ if (currentLoggedUserId === userUpdatedId && defaultAssetId) {
5103
+ setDefaultAreaId(defaultAssetId);
5104
+ }
5105
+ onHide(true);
5106
+ setOpen(true);
5107
+ return [2 /*return*/];
5108
+ });
5109
+ }); },
5110
5110
  onError: function (error) {
5111
5111
  setError(error.message);
5112
5112
  },
@@ -5133,7 +5133,13 @@ var EditUser = function (_a) {
5133
5133
  if (isSuccess) {
5134
5134
  var userSelected = rows ? rows[0] : null;
5135
5135
  if (userSelected) {
5136
- var profilesIds_1 = (((_a = userSelected.ProfilesId) === null || _a === void 0 ? void 0 : _a.toString()) || "").split(",") || [];
5136
+ var profilesIdsString = ((_a = userSelected.ProfilesId) === null || _a === void 0 ? void 0 : _a.toString()) || "";
5137
+ var profilesIds_1 = profilesIdsString
5138
+ .split(",")
5139
+ .map(function (pId) { return pId.trim(); })
5140
+ .filter(function (pId) { return pId !== ""; })
5141
+ .map(function (pId) { return parseInt(pId); })
5142
+ .filter(function (pId) { return !isNaN(pId); });
5137
5143
  setValue("UserId", userSelected.UserId);
5138
5144
  setValue("UserName", userSelected.UserName);
5139
5145
  setValue("FirstName", userSelected.FirstName);
@@ -5142,7 +5148,7 @@ var EditUser = function (_a) {
5142
5148
  setValue("IsActive", userSelected.IsActive);
5143
5149
  setValue("LastLogin", userSelected.LastLogin);
5144
5150
  setValue("DefaultAssetId", userSelected.DefaultAssetId);
5145
- setValue("ProfilesId", profilesIds_1.map(function (pId) { return parseInt(pId); }));
5151
+ setValue("ProfilesId", profilesIds_1);
5146
5152
  }
5147
5153
  }
5148
5154
  }