blixify-ui-web 1.2.52 → 1.2.53

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 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/data/dataTemplate/index.tsx"],"names":[],"mappings":"AAiCA,OAAO,KASN,MAAM,OAAO,CAAC;AA+Ef,OAAO,EACL,iBAAiB,EAKlB,MAAM,kBAAkB,CAAC;AAoC1B,eAAO,MAAM,YAAY,mFA8jWvB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/data/dataTemplate/index.tsx"],"names":[],"mappings":"AAiCA,OAAO,KASN,MAAM,OAAO,CAAC;AA+Ef,OAAO,EACL,iBAAiB,EAKlB,MAAM,kBAAkB,CAAC;AAiD1B,eAAO,MAAM,YAAY,mFAujWvB,CAAC"}
@@ -152,6 +152,20 @@ var referenceModal_1 = require("./referenceModal");
152
152
  var settingsModal_1 = require("./settingsModal");
153
153
  var flexFilterModel_1 = require("./flexFilterModel");
154
154
  var flexFilterModule_1 = require("./flexFilterModule");
155
+ // INFO: builds the notification message for a failed write. Callers must gate on
156
+ // `err.response` alone, never on a specific status — a catch that only handles 400 shows
157
+ // the user nothing at all for any other status, so a write silently disappears. A 5xx is
158
+ // the server's fault and self-resolves, so it gets a distinct message rather than the
159
+ // contact-your-administrator copy, which reads as though the user did something wrong.
160
+ var handleGetWriteErrorMessage = function (response) {
161
+ var _a;
162
+ if ((response === null || response === void 0 ? void 0 : response.status) >= 500) {
163
+ return "Our service is temporarily unavailable. Please try again in a few minutes.";
164
+ }
165
+ if (typeof ((_a = response === null || response === void 0 ? void 0 : response.data) === null || _a === void 0 ? void 0 : _a.err) === "string")
166
+ return response.data.err;
167
+ return "Please contact our administrator for assistance or try your request again later. We apologize for any inconvenience";
168
+ };
155
169
  exports.DataTemplate = (0, react_1.forwardRef)(function (props, ref) {
156
170
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36, _37, _38, _39, _40, _41;
157
171
  var intialiseDefaultFilterValues = function () {
@@ -3659,11 +3673,11 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (props, ref) {
3659
3673
  case 6: return [3 /*break*/, 8];
3660
3674
  case 7:
3661
3675
  err_17 = _a.sent();
3662
- if (err_17.response && err_17.response.status === 400) {
3676
+ if (err_17.response) {
3663
3677
  setNotification({
3664
3678
  type: false,
3665
3679
  title: "Error",
3666
- msg: err_17.response.data.err,
3680
+ msg: handleGetWriteErrorMessage(err_17.response),
3667
3681
  });
3668
3682
  }
3669
3683
  return [3 /*break*/, 8];
@@ -3828,15 +3842,15 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (props, ref) {
3828
3842
  var handleSubmitData = function (type, rowId, columnId, data, offlineId, isOfflineUpdate, isDraft) { return __awaiter(void 0, void 0, void 0, function () {
3829
3843
  var selectedId, id, createSelectedData_1, uniqueDataStructure, uniqueColumnId, res, offlineDataResp, offlineData, clonedForOffline, tempData, selectedIndex_3, err_20, isExistingDoc, newRecordData_1, changedAttributeIds, baseDraftValue, hasBaseDraftChange, offlineDataResp, clonedForOffline, tempData, selectedIndex_4, offlineData, err_21, dataToSubmit_2, changedAttributeIds, baseDraftValue, hasBaseDraftChange, operationType, selectedIndex_5, wentToServer, dataId, err_22, offlineDataResp, offlineData, clonedForOffline, tempData, selectedIndex_6, _a;
3830
3844
  var _b, _c, _d;
3831
- var _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x;
3832
- return __generator(this, function (_y) {
3833
- switch (_y.label) {
3845
+ var _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w;
3846
+ return __generator(this, function (_x) {
3847
+ switch (_x.label) {
3834
3848
  case 0:
3835
3849
  selectedId = "";
3836
3850
  id = "";
3837
- _y.label = 1;
3851
+ _x.label = 1;
3838
3852
  case 1:
3839
- _y.trys.push([1, 39, , 45]);
3853
+ _x.trys.push([1, 39, , 45]);
3840
3854
  if (type === "update")
3841
3855
  selectedId = rowId !== null && rowId !== void 0 ? rowId : "";
3842
3856
  else if (type === "create")
@@ -3866,8 +3880,8 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (props, ref) {
3866
3880
  return [3 /*break*/, 4];
3867
3881
  case 2: return [4 /*yield*/, handleUploadImage(id, data)];
3868
3882
  case 3:
3869
- createSelectedData_1 = _y.sent();
3870
- _y.label = 4;
3883
+ createSelectedData_1 = _x.sent();
3884
+ _x.label = 4;
3871
3885
  case 4:
3872
3886
  uniqueDataStructure = structure.filter(function (eachStructure) {
3873
3887
  return eachStructure.unique;
@@ -3887,12 +3901,12 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (props, ref) {
3887
3901
  if (isDraft)
3888
3902
  createSelectedData_1["baseDraft"] = true;
3889
3903
  if (!isOffline) return [3 /*break*/, 10];
3890
- _y.label = 5;
3904
+ _x.label = 5;
3891
3905
  case 5:
3892
- _y.trys.push([5, 8, , 9]);
3906
+ _x.trys.push([5, 8, , 9]);
3893
3907
  return [4 /*yield*/, indexedDb_1.indexedDb.getValue("local", props.collectionId)];
3894
3908
  case 6:
3895
- offlineDataResp = _y.sent();
3909
+ offlineDataResp = _x.sent();
3896
3910
  offlineData = (_g = offlineDataResp === null || offlineDataResp === void 0 ? void 0 : offlineDataResp.data) !== null && _g !== void 0 ? _g : [];
3897
3911
  clonedForOffline = (0, updateModule_1.handleClonedDataAttribute)(selectedData, structure, props.devSettings.server, true, showId);
3898
3912
  tempData = (0, updateModule_1.handleParseOfflineWrite)(clonedForOffline, structure);
@@ -3936,11 +3950,11 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (props, ref) {
3936
3950
  type: props.collectionId,
3937
3951
  })];
3938
3952
  case 7:
3939
- _y.sent();
3953
+ _x.sent();
3940
3954
  res = true;
3941
3955
  return [3 /*break*/, 9];
3942
3956
  case 8:
3943
- err_20 = _y.sent();
3957
+ err_20 = _x.sent();
3944
3958
  return [3 /*break*/, 9];
3945
3959
  case 9: return [3 /*break*/, 16];
3946
3960
  case 10:
@@ -4002,7 +4016,7 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (props, ref) {
4002
4016
  upsert: true,
4003
4017
  })];
4004
4018
  case 11:
4005
- res = _y.sent();
4019
+ res = _x.sent();
4006
4020
  return [3 /*break*/, 16];
4007
4021
  case 12:
4008
4022
  // INFO: stepper create guard — if a create is already in-flight, queue this
@@ -4022,7 +4036,7 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (props, ref) {
4022
4036
  })];
4023
4037
  case 13:
4024
4038
  //INFO: [CREATE] Create new data
4025
- res = _y.sent();
4039
+ res = _x.sent();
4026
4040
  if (!(selectedId === "new")) return [3 /*break*/, 16];
4027
4041
  isCreatingRef.current = false;
4028
4042
  if (!pendingDraftSaveRef.current) return [3 /*break*/, 15];
@@ -4034,23 +4048,23 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (props, ref) {
4034
4048
  })];
4035
4049
  case 14:
4036
4050
  // INFO: replay as update — inflightIdRef.current holds the real _id
4037
- _y.sent();
4038
- _y.label = 15;
4051
+ _x.sent();
4052
+ _x.label = 15;
4039
4053
  case 15:
4040
4054
  inflightIdRef.current = "";
4041
- _y.label = 16;
4055
+ _x.label = 16;
4042
4056
  case 16: return [3 /*break*/, 25];
4043
4057
  case 17:
4044
4058
  if (!selectedId) return [3 /*break*/, 25];
4045
4059
  if (!(isOffline &&
4046
4060
  !(isOfflineNetworkListener && !isNetworkOffline) &&
4047
4061
  !offlineId)) return [3 /*break*/, 23];
4048
- _y.label = 18;
4062
+ _x.label = 18;
4049
4063
  case 18:
4050
- _y.trys.push([18, 21, , 22]);
4064
+ _x.trys.push([18, 21, , 22]);
4051
4065
  return [4 /*yield*/, indexedDb_1.indexedDb.getValue("local", props.collectionId)];
4052
4066
  case 19:
4053
- offlineDataResp = _y.sent();
4067
+ offlineDataResp = _x.sent();
4054
4068
  clonedForOffline = (0, updateModule_1.handleClonedDataAttribute)(selectedData, structure, props.devSettings.server, true, showId);
4055
4069
  tempData = (0, updateModule_1.handleParseOfflineWrite)(clonedForOffline, structure);
4056
4070
  tempData[serverId] = selectedId;
@@ -4092,11 +4106,11 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (props, ref) {
4092
4106
  type: props.collectionId,
4093
4107
  })];
4094
4108
  case 20:
4095
- _y.sent();
4109
+ _x.sent();
4096
4110
  res = true;
4097
4111
  return [3 /*break*/, 22];
4098
4112
  case 21:
4099
- err_21 = _y.sent();
4113
+ err_21 = _x.sent();
4100
4114
  return [3 /*break*/, 22];
4101
4115
  case 22: return [3 /*break*/, 25];
4102
4116
  case 23:
@@ -4182,8 +4196,8 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (props, ref) {
4182
4196
  : undefined,
4183
4197
  })];
4184
4198
  case 24:
4185
- res = _y.sent();
4186
- _y.label = 25;
4199
+ res = _x.sent();
4200
+ _x.label = 25;
4187
4201
  case 25:
4188
4202
  if (!(type === "update" || type === "create")) return [3 /*break*/, 33];
4189
4203
  if (!res) return [3 /*break*/, 32];
@@ -4199,27 +4213,27 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (props, ref) {
4199
4213
  });
4200
4214
  return [4 /*yield*/, handleGetListData({ data: tableData[selectedIndex_5] }, "update", rowId)];
4201
4215
  case 26:
4202
- _y.sent();
4203
- _y.label = 27;
4216
+ _x.sent();
4217
+ _x.label = 27;
4204
4218
  case 27: return [3 /*break*/, 30];
4205
4219
  case 28: return [4 /*yield*/, handleGetListData({ data: [createSelectedData_1] }, "create")];
4206
4220
  case 29:
4207
- _y.sent();
4208
- _y.label = 30;
4221
+ _x.sent();
4222
+ _x.label = 30;
4209
4223
  case 30:
4210
4224
  if (!((_t = props.bareSettings) === null || _t === void 0 ? void 0 : _t.bareUpdateHandlePostComplete)) return [3 /*break*/, 32];
4211
4225
  return [4 /*yield*/, props.bareSettings.bareUpdateHandlePostComplete(__assign((_c = {}, _c[serverId] = id, _c), createSelectedData_1))];
4212
4226
  case 31:
4213
- _y.sent();
4214
- _y.label = 32;
4227
+ _x.sent();
4228
+ _x.label = 32;
4215
4229
  case 32: return [3 /*break*/, 38];
4216
4230
  case 33:
4217
4231
  createSelectedData_1[serverId] = id;
4218
4232
  if (!!isOffline) return [3 /*break*/, 35];
4219
4233
  return [4 /*yield*/, handleGetListData({ data: [createSelectedData_1] }, selectedId === "new" ? "create" : "update", id)];
4220
4234
  case 34:
4221
- _y.sent();
4222
- _y.label = 35;
4235
+ _x.sent();
4236
+ _x.label = 35;
4223
4237
  case 35:
4224
4238
  wentToServer = res &&
4225
4239
  !offlineId &&
@@ -4227,8 +4241,8 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (props, ref) {
4227
4241
  if (!(wentToServer && ((_u = props.bareSettings) === null || _u === void 0 ? void 0 : _u.bareUpdateHandlePostComplete))) return [3 /*break*/, 37];
4228
4242
  return [4 /*yield*/, props.bareSettings.bareUpdateHandlePostComplete(__assign((_d = {}, _d[serverId] = id, _d), createSelectedData_1))];
4229
4243
  case 36:
4230
- _y.sent();
4231
- _y.label = 37;
4244
+ _x.sent();
4245
+ _x.label = 37;
4232
4246
  case 37:
4233
4247
  setNotification({
4234
4248
  type: true,
@@ -4239,12 +4253,12 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (props, ref) {
4239
4253
  ? "Data sucessfully created"
4240
4254
  : "Data sucessfully updated",
4241
4255
  });
4242
- _y.label = 38;
4256
+ _x.label = 38;
4243
4257
  case 38:
4244
4258
  dataId = res ? id : "";
4245
4259
  return [2 /*return*/, dataId];
4246
4260
  case 39:
4247
- err_22 = _y.sent();
4261
+ err_22 = _x.sent();
4248
4262
  console.log("error", err_22);
4249
4263
  // INFO: clear in-flight guard on failure so the next save retries as a create
4250
4264
  if (isCreatingRef.current) {
@@ -4257,12 +4271,12 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (props, ref) {
4257
4271
  !offlineId &&
4258
4272
  !isOfflineUpdate &&
4259
4273
  !err_22.response)) return [3 /*break*/, 44];
4260
- _y.label = 40;
4274
+ _x.label = 40;
4261
4275
  case 40:
4262
- _y.trys.push([40, 43, , 44]);
4276
+ _x.trys.push([40, 43, , 44]);
4263
4277
  return [4 /*yield*/, indexedDb_1.indexedDb.getValue("local", props.collectionId)];
4264
4278
  case 41:
4265
- offlineDataResp = _y.sent();
4279
+ offlineDataResp = _x.sent();
4266
4280
  offlineData = (_w = offlineDataResp === null || offlineDataResp === void 0 ? void 0 : offlineDataResp.data) !== null && _w !== void 0 ? _w : [];
4267
4281
  clonedForOffline = (0, updateModule_1.handleClonedDataAttribute)(selectedData, structure, props.devSettings.server, true, showId);
4268
4282
  tempData = (0, updateModule_1.handleParseOfflineWrite)(clonedForOffline, structure);
@@ -4300,7 +4314,7 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (props, ref) {
4300
4314
  type: props.collectionId,
4301
4315
  })];
4302
4316
  case 42:
4303
- _y.sent();
4317
+ _x.sent();
4304
4318
  setNotification({
4305
4319
  type: false,
4306
4320
  title: selectedId === "new"
@@ -4312,22 +4326,15 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (props, ref) {
4312
4326
  // INFO: return id so handleSubmit can navigate as if the save succeeded
4313
4327
  return [2 /*return*/, id];
4314
4328
  case 43:
4315
- _a = _y.sent();
4329
+ _a = _x.sent();
4316
4330
  return [3 /*break*/, 44];
4317
4331
  case 44:
4318
- if (err_22.response && err_22.response.status === 400) {
4319
- if (typeof ((_x = err_22.response.data) === null || _x === void 0 ? void 0 : _x.err) === "string")
4320
- setNotification({
4321
- type: false,
4322
- title: "Error",
4323
- msg: err_22.response.data.err,
4324
- });
4325
- else
4326
- setNotification({
4327
- type: false,
4328
- title: "Error",
4329
- msg: "Please contact our administrator for assistance or try your request again later. We apologize for any inconvenience",
4330
- });
4332
+ if (err_22.response) {
4333
+ setNotification({
4334
+ type: false,
4335
+ title: "Error",
4336
+ msg: handleGetWriteErrorMessage(err_22.response),
4337
+ });
4331
4338
  }
4332
4339
  return [3 /*break*/, 45];
4333
4340
  case 45: return [2 /*return*/];