@appcorp/stellar-solutions-modules 0.1.23 → 0.1.25

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,6 +1,6 @@
1
1
  import { BranchTypeBE, BRANCH_DRAWER } from './types';
2
2
  export declare enum BRANCH_ACTION_TYPES {
3
- CLEAR_ERRORS = "CLEAR_ERRORS",
3
+ RESET_ERRORS = "RESET_ERRORS",
4
4
  RESET_FORM = "RESET_FORM",
5
5
  SET_BRANCHES = "SET_BRANCHES",
6
6
  SET_COUNT = "SET_COUNT",
@@ -65,8 +65,8 @@ export type BranchSetDisableSaveButtonAction = {
65
65
  disableSaveButton: boolean;
66
66
  };
67
67
  };
68
- export type BranchClearErrorsAction = {
69
- type: BRANCH_ACTION_TYPES.CLEAR_ERRORS;
68
+ export type BranchResetErrorsAction = {
69
+ type: BRANCH_ACTION_TYPES.RESET_ERRORS;
70
70
  };
71
71
  export type BranchSetCurrentPageAction = {
72
72
  type: BRANCH_ACTION_TYPES.SET_CURRENT_PAGE;
@@ -80,4 +80,4 @@ export type BranchSetPageLimitAction = {
80
80
  pageLimit: number;
81
81
  };
82
82
  };
83
- export type BranchActions = BranchSetErrorsAction | BranchSetCountAction | BranchSetBranchesAction | BranchSetFormAction | BranchSetDrawerAction | BranchSetInputFieldAction | BranchSetDisableSaveButtonAction | BranchClearErrorsAction | BranchSetCurrentPageAction | BranchSetPageLimitAction | BranchResetFormAction | BranchSetSearchQueryAction;
83
+ export type BranchActions = BranchSetErrorsAction | BranchSetCountAction | BranchSetBranchesAction | BranchSetFormAction | BranchSetDrawerAction | BranchSetInputFieldAction | BranchSetDisableSaveButtonAction | BranchResetErrorsAction | BranchSetCurrentPageAction | BranchSetPageLimitAction | BranchResetFormAction | BranchSetSearchQueryAction;
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.BRANCH_ACTION_TYPES = void 0;
4
4
  var BRANCH_ACTION_TYPES;
5
5
  (function (BRANCH_ACTION_TYPES) {
6
- BRANCH_ACTION_TYPES["CLEAR_ERRORS"] = "CLEAR_ERRORS";
6
+ BRANCH_ACTION_TYPES["RESET_ERRORS"] = "RESET_ERRORS";
7
7
  BRANCH_ACTION_TYPES["RESET_FORM"] = "RESET_FORM";
8
8
  BRANCH_ACTION_TYPES["SET_BRANCHES"] = "SET_BRANCHES";
9
9
  BRANCH_ACTION_TYPES["SET_COUNT"] = "SET_COUNT";
@@ -44,42 +44,6 @@ var __importStar = (this && this.__importStar) || (function () {
44
44
  return result;
45
45
  };
46
46
  })();
47
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
48
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
49
- return new (P || (P = Promise))(function (resolve, reject) {
50
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
51
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
52
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
53
- step((generator = generator.apply(thisArg, _arguments || [])).next());
54
- });
55
- };
56
- var __generator = (this && this.__generator) || function (thisArg, body) {
57
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
58
- return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
59
- function verb(n) { return function (v) { return step([n, v]); }; }
60
- function step(op) {
61
- if (f) throw new TypeError("Generator is already executing.");
62
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
63
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
64
- if (y = 0, t) op = [op[0] & 2, t.value];
65
- switch (op[0]) {
66
- case 0: case 1: t = op; break;
67
- case 4: _.label++; return { value: op[1], done: false };
68
- case 5: _.label++; y = op[1]; op = [0]; continue;
69
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
70
- default:
71
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
72
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
73
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
74
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
75
- if (t[2]) _.ops.pop();
76
- _.trys.pop(); continue;
77
- }
78
- op = body.call(thisArg, _);
79
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
80
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
81
- }
82
- };
83
47
  Object.defineProperty(exports, "__esModule", { value: true });
84
48
  exports.useBranchStateContext = exports.BranchStateContextProvider = exports.BranchStateContext = void 0;
85
49
  var react_1 = __importStar(require("react"));
@@ -160,6 +124,9 @@ var useBranchState = function () {
160
124
  dispatch({
161
125
  type: actions_1.BRANCH_ACTION_TYPES.RESET_FORM,
162
126
  });
127
+ dispatch({
128
+ type: actions_1.BRANCH_ACTION_TYPES.RESET_ERRORS,
129
+ });
163
130
  listFetchNow();
164
131
  dispatch({
165
132
  type: actions_1.BRANCH_ACTION_TYPES.SET_DRAWER,
@@ -262,7 +229,7 @@ var useBranchState = function () {
262
229
  type: actions_1.BRANCH_ACTION_TYPES.RESET_FORM,
263
230
  });
264
231
  dispatch({
265
- type: actions_1.BRANCH_ACTION_TYPES.CLEAR_ERRORS,
232
+ type: actions_1.BRANCH_ACTION_TYPES.RESET_ERRORS,
266
233
  });
267
234
  };
268
235
  var handleOnChange = function (k, v) {
@@ -283,46 +250,27 @@ var useBranchState = function () {
283
250
  },
284
251
  });
285
252
  };
286
- var handleSubmit = (0, react_1.useCallback)(function () { return __awaiter(void 0, void 0, void 0, function () {
287
- var validationResult, validationErrors_1;
288
- return __generator(this, function (_a) {
289
- dispatch({
290
- type: actions_1.BRANCH_ACTION_TYPES.SET_DISABLE_SAVE_BUTTON,
291
- payload: { disableSaveButton: true },
292
- });
293
- try {
294
- validationResult = validate_1.formValidation === null || validate_1.formValidation === void 0 ? void 0 : validate_1.formValidation.safeParse(__assign({}, updateParams));
295
- if (validationResult === null || validationResult === void 0 ? void 0 : validationResult.error) {
296
- validationErrors_1 = {};
297
- validationResult === null || validationResult === void 0 ? void 0 : validationResult.error.issues.forEach(function (err) {
298
- validationErrors_1[err.path[0]] = err.message;
299
- });
300
- dispatch({
301
- type: actions_1.BRANCH_ACTION_TYPES.SET_ERRORS,
302
- payload: { errors: validationErrors_1 },
303
- });
304
- }
305
- if (validationResult === null || validationResult === void 0 ? void 0 : validationResult.success) {
306
- updateFetchNow(undefined, {
307
- body: JSON.stringify(__assign({}, updateParams)),
308
- });
309
- }
310
- }
311
- catch (_b) {
312
- (0, generate_toast_1.generateToast)({
313
- description: '',
314
- variant: vista_notification_type_1.VISTA_NOTIFICATION_V1_VARIANT.ERROR,
253
+ var handleSubmit = (0, react_1.useCallback)(function () {
254
+ dispatch({
255
+ type: actions_1.BRANCH_ACTION_TYPES.SET_DISABLE_SAVE_BUTTON,
256
+ payload: { disableSaveButton: true },
257
+ });
258
+ (0, util_functions_1.validateForm)({
259
+ params: updateParams,
260
+ schema: validate_1.formValidation,
261
+ successCallback: function () {
262
+ updateFetchNow(undefined, {
263
+ body: JSON.stringify(__assign({}, updateParams)),
315
264
  });
316
- }
317
- dispatch({
318
- type: actions_1.BRANCH_ACTION_TYPES.RESET_FORM,
319
- });
320
- dispatch({
321
- type: actions_1.BRANCH_ACTION_TYPES.CLEAR_ERRORS,
322
- });
323
- return [2 /*return*/];
265
+ },
266
+ errorCallback: function (e) {
267
+ dispatch({
268
+ type: actions_1.BRANCH_ACTION_TYPES.SET_ERRORS,
269
+ payload: { errors: e },
270
+ });
271
+ },
324
272
  });
325
- }); }, [updateFetchNow, updateParams]);
273
+ }, [updateFetchNow, updateParams]);
326
274
  var dynamicFormElements = (0, react_1.useMemo)(function () {
327
275
  var _a, _b;
328
276
  var elements = __assign({}, constants_1.staticFormElements);
@@ -155,7 +155,7 @@ function branchReducer(state, action) {
155
155
  return __assign(__assign({}, state), (_a = {}, _a[action.payload.key] = action.payload.value, _a));
156
156
  case actions_1.BRANCH_ACTION_TYPES.SET_DISABLE_SAVE_BUTTON:
157
157
  return __assign(__assign({}, state), { disableSaveButton: action.payload.disableSaveButton });
158
- case actions_1.BRANCH_ACTION_TYPES.CLEAR_ERRORS:
158
+ case actions_1.BRANCH_ACTION_TYPES.RESET_ERRORS:
159
159
  return __assign(__assign({}, state), { errors: {} });
160
160
  case actions_1.BRANCH_ACTION_TYPES.SET_CURRENT_PAGE:
161
161
  return __assign(__assign({}, state), { currentPage: action.payload.currentPage });
@@ -1,6 +1,6 @@
1
1
  import { BranchTypeBE, PAYMENT_MODE_DRAWER, PaymentModeTypeBE } from './types';
2
2
  export declare enum PAYMENT_MODE_ACTION_TYPES {
3
- CLEAR_ERRORS = "CLEAR_ERRORS",
3
+ RESET_ERRORS = "RESET_ERRORS",
4
4
  RESET_FORM = "RESET_FORM",
5
5
  SET_PAYMENT_MODES = "SET_PAYMENT_MODES",
6
6
  SET_COUNT = "SET_COUNT",
@@ -65,8 +65,8 @@ export type PaymentModeSetDisableSaveButtonAction = {
65
65
  disableSaveButton: boolean;
66
66
  };
67
67
  };
68
- export type PaymentModeClearErrorsAction = {
69
- type: PAYMENT_MODE_ACTION_TYPES.CLEAR_ERRORS;
68
+ export type PaymentModeResetErrorsAction = {
69
+ type: PAYMENT_MODE_ACTION_TYPES.RESET_ERRORS;
70
70
  };
71
71
  export type PaymentModeSetCurrentPageAction = {
72
72
  type: PAYMENT_MODE_ACTION_TYPES.SET_CURRENT_PAGE;
@@ -80,4 +80,4 @@ export type PaymentModeSetPageLimitAction = {
80
80
  pageLimit: number;
81
81
  };
82
82
  };
83
- export type PaymentModeActions = PaymentModeSetErrorsAction | PaymentModeSetCountAction | PaymentModeSetPaymentModesAction | PaymentModeSetFormAction | PaymentModeSetDrawerAction | PaymentModeSetInputFieldAction | PaymentModeSetDisableSaveButtonAction | PaymentModeClearErrorsAction | PaymentModeSetCurrentPageAction | PaymentModeSetPageLimitAction | PaymentModeResetFormAction | PaymentModeSetSearchQueryAction;
83
+ export type PaymentModeActions = PaymentModeSetErrorsAction | PaymentModeSetCountAction | PaymentModeSetPaymentModesAction | PaymentModeSetFormAction | PaymentModeSetDrawerAction | PaymentModeSetInputFieldAction | PaymentModeSetDisableSaveButtonAction | PaymentModeResetErrorsAction | PaymentModeSetCurrentPageAction | PaymentModeSetPageLimitAction | PaymentModeResetFormAction | PaymentModeSetSearchQueryAction;
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PAYMENT_MODE_ACTION_TYPES = void 0;
4
4
  var PAYMENT_MODE_ACTION_TYPES;
5
5
  (function (PAYMENT_MODE_ACTION_TYPES) {
6
- PAYMENT_MODE_ACTION_TYPES["CLEAR_ERRORS"] = "CLEAR_ERRORS";
6
+ PAYMENT_MODE_ACTION_TYPES["RESET_ERRORS"] = "RESET_ERRORS";
7
7
  PAYMENT_MODE_ACTION_TYPES["RESET_FORM"] = "RESET_FORM";
8
8
  PAYMENT_MODE_ACTION_TYPES["SET_PAYMENT_MODES"] = "SET_PAYMENT_MODES";
9
9
  PAYMENT_MODE_ACTION_TYPES["SET_COUNT"] = "SET_COUNT";
@@ -44,42 +44,6 @@ var __importStar = (this && this.__importStar) || (function () {
44
44
  return result;
45
45
  };
46
46
  })();
47
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
48
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
49
- return new (P || (P = Promise))(function (resolve, reject) {
50
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
51
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
52
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
53
- step((generator = generator.apply(thisArg, _arguments || [])).next());
54
- });
55
- };
56
- var __generator = (this && this.__generator) || function (thisArg, body) {
57
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
58
- return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
59
- function verb(n) { return function (v) { return step([n, v]); }; }
60
- function step(op) {
61
- if (f) throw new TypeError("Generator is already executing.");
62
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
63
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
64
- if (y = 0, t) op = [op[0] & 2, t.value];
65
- switch (op[0]) {
66
- case 0: case 1: t = op; break;
67
- case 4: _.label++; return { value: op[1], done: false };
68
- case 5: _.label++; y = op[1]; op = [0]; continue;
69
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
70
- default:
71
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
72
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
73
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
74
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
75
- if (t[2]) _.ops.pop();
76
- _.trys.pop(); continue;
77
- }
78
- op = body.call(thisArg, _);
79
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
80
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
81
- }
82
- };
83
47
  Object.defineProperty(exports, "__esModule", { value: true });
84
48
  exports.usePaymentModeStateContext = exports.PaymentModeStateContextProvider = exports.PaymentModeStateContext = void 0;
85
49
  var react_1 = __importStar(require("react"));
@@ -156,6 +120,9 @@ var usePaymentModeState = function () {
156
120
  dispatch({
157
121
  type: actions_1.PAYMENT_MODE_ACTION_TYPES.RESET_FORM,
158
122
  });
123
+ dispatch({
124
+ type: actions_1.PAYMENT_MODE_ACTION_TYPES.RESET_ERRORS,
125
+ });
159
126
  listFetchNow();
160
127
  dispatch({
161
128
  type: actions_1.PAYMENT_MODE_ACTION_TYPES.SET_DRAWER,
@@ -258,7 +225,7 @@ var usePaymentModeState = function () {
258
225
  type: actions_1.PAYMENT_MODE_ACTION_TYPES.RESET_FORM,
259
226
  });
260
227
  dispatch({
261
- type: actions_1.PAYMENT_MODE_ACTION_TYPES.CLEAR_ERRORS,
228
+ type: actions_1.PAYMENT_MODE_ACTION_TYPES.RESET_ERRORS,
262
229
  });
263
230
  };
264
231
  var handleOnChange = function (k, v) {
@@ -279,46 +246,27 @@ var usePaymentModeState = function () {
279
246
  },
280
247
  });
281
248
  };
282
- var handleSubmit = (0, react_1.useCallback)(function () { return __awaiter(void 0, void 0, void 0, function () {
283
- var validationResult, validationErrors_1;
284
- return __generator(this, function (_a) {
285
- dispatch({
286
- type: actions_1.PAYMENT_MODE_ACTION_TYPES.SET_DISABLE_SAVE_BUTTON,
287
- payload: { disableSaveButton: true },
288
- });
289
- try {
290
- validationResult = validate_1.formValidation === null || validate_1.formValidation === void 0 ? void 0 : validate_1.formValidation.safeParse(__assign({}, updateParams));
291
- if (validationResult === null || validationResult === void 0 ? void 0 : validationResult.error) {
292
- validationErrors_1 = {};
293
- validationResult === null || validationResult === void 0 ? void 0 : validationResult.error.issues.forEach(function (err) {
294
- validationErrors_1[err.path[0]] = err.message;
295
- });
296
- dispatch({
297
- type: actions_1.PAYMENT_MODE_ACTION_TYPES.SET_ERRORS,
298
- payload: { errors: validationErrors_1 },
299
- });
300
- }
301
- if (validationResult === null || validationResult === void 0 ? void 0 : validationResult.success) {
302
- updateFetchNow(undefined, {
303
- body: JSON.stringify(__assign({}, updateParams)),
304
- });
305
- }
306
- }
307
- catch (_b) {
308
- (0, generate_toast_1.generateToast)({
309
- description: '',
310
- variant: vista_notification_type_1.VISTA_NOTIFICATION_V1_VARIANT.ERROR,
249
+ var handleSubmit = (0, react_1.useCallback)(function () {
250
+ dispatch({
251
+ type: actions_1.PAYMENT_MODE_ACTION_TYPES.SET_DISABLE_SAVE_BUTTON,
252
+ payload: { disableSaveButton: true },
253
+ });
254
+ (0, util_functions_1.validateForm)({
255
+ params: updateParams,
256
+ schema: validate_1.formValidation,
257
+ successCallback: function () {
258
+ updateFetchNow(undefined, {
259
+ body: JSON.stringify(__assign({}, updateParams)),
311
260
  });
312
- }
313
- dispatch({
314
- type: actions_1.PAYMENT_MODE_ACTION_TYPES.RESET_FORM,
315
- });
316
- dispatch({
317
- type: actions_1.PAYMENT_MODE_ACTION_TYPES.CLEAR_ERRORS,
318
- });
319
- return [2 /*return*/];
261
+ },
262
+ errorCallback: function (e) {
263
+ dispatch({
264
+ type: actions_1.PAYMENT_MODE_ACTION_TYPES.SET_ERRORS,
265
+ payload: { errors: e },
266
+ });
267
+ },
320
268
  });
321
- }); }, [updateFetchNow, updateParams]);
269
+ }, [updateFetchNow, updateParams]);
322
270
  var dynamicFormElements = (0, react_1.useMemo)(function () {
323
271
  var _a, _b;
324
272
  var elements = __assign({}, constants_1.staticFormElements);
@@ -151,7 +151,7 @@ function paymentModeReducer(state, action) {
151
151
  return __assign(__assign({}, state), (_a = {}, _a[action.payload.key] = action.payload.value, _a));
152
152
  case actions_1.PAYMENT_MODE_ACTION_TYPES.SET_DISABLE_SAVE_BUTTON:
153
153
  return __assign(__assign({}, state), { disableSaveButton: action.payload.disableSaveButton });
154
- case actions_1.PAYMENT_MODE_ACTION_TYPES.CLEAR_ERRORS:
154
+ case actions_1.PAYMENT_MODE_ACTION_TYPES.RESET_ERRORS:
155
155
  return __assign(__assign({}, state), { errors: {} });
156
156
  case actions_1.PAYMENT_MODE_ACTION_TYPES.SET_CURRENT_PAGE:
157
157
  return __assign(__assign({}, state), { currentPage: action.payload.currentPage });
@@ -104,6 +104,9 @@ var usePreferenceState = function () {
104
104
  dispatch({
105
105
  type: actions_1.PREFERENCE_ACTION_TYPES.RESET_FORM,
106
106
  });
107
+ dispatch({
108
+ type: actions_1.PREFERENCE_ACTION_TYPES.RESET_FORM,
109
+ });
107
110
  listFetchNow();
108
111
  // dispatch({
109
112
  // type: PREFERENCE_ACTION_TYPES.SET_DRAWER,
@@ -1,6 +1,6 @@
1
1
  import { TaxTypeBE, TAX_DRAWER } from './types';
2
2
  export declare enum TAX_ACTION_TYPES {
3
- CLEAR_ERRORS = "CLEAR_ERRORS",
3
+ RESET_ERRORS = "RESET_ERRORS",
4
4
  RESET_FORM = "RESET_FORM",
5
5
  SET_COUNT = "SET_COUNT",
6
6
  SET_CURRENT_PAGE = "SET_CURRENT_PAGE",
@@ -62,8 +62,8 @@ export type TaxSetDisableSaveButtonAction = {
62
62
  disableSaveButton: boolean;
63
63
  };
64
64
  };
65
- export type TaxClearErrorsAction = {
66
- type: TAX_ACTION_TYPES.CLEAR_ERRORS;
65
+ export type TaxResetErrorsAction = {
66
+ type: TAX_ACTION_TYPES.RESET_ERRORS;
67
67
  };
68
68
  export type TaxSetCurrentPageAction = {
69
69
  type: TAX_ACTION_TYPES.SET_CURRENT_PAGE;
@@ -80,4 +80,4 @@ export type TaxSetPageLimitAction = {
80
80
  export type TaxResetFormAction = {
81
81
  type: TAX_ACTION_TYPES.RESET_FORM;
82
82
  };
83
- export type TaxActions = TaxSetErrorsAction | TaxSetCountAction | TaxSetTaxesAction | TaxSetFormAction | TaxSetDrawerAction | TaxSetInputFieldAction | TaxSetDisableSaveButtonAction | TaxClearErrorsAction | TaxSetCurrentPageAction | TaxSetPageLimitAction | TaxResetFormAction | TaxSetSearchQuery;
83
+ export type TaxActions = TaxSetErrorsAction | TaxSetCountAction | TaxSetTaxesAction | TaxSetFormAction | TaxSetDrawerAction | TaxSetInputFieldAction | TaxSetDisableSaveButtonAction | TaxResetErrorsAction | TaxSetCurrentPageAction | TaxSetPageLimitAction | TaxResetFormAction | TaxSetSearchQuery;
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.TAX_ACTION_TYPES = void 0;
4
4
  var TAX_ACTION_TYPES;
5
5
  (function (TAX_ACTION_TYPES) {
6
- TAX_ACTION_TYPES["CLEAR_ERRORS"] = "CLEAR_ERRORS";
6
+ TAX_ACTION_TYPES["RESET_ERRORS"] = "RESET_ERRORS";
7
7
  TAX_ACTION_TYPES["RESET_FORM"] = "RESET_FORM";
8
8
  TAX_ACTION_TYPES["SET_COUNT"] = "SET_COUNT";
9
9
  TAX_ACTION_TYPES["SET_CURRENT_PAGE"] = "SET_CURRENT_PAGE";
@@ -44,42 +44,6 @@ var __importStar = (this && this.__importStar) || (function () {
44
44
  return result;
45
45
  };
46
46
  })();
47
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
48
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
49
- return new (P || (P = Promise))(function (resolve, reject) {
50
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
51
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
52
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
53
- step((generator = generator.apply(thisArg, _arguments || [])).next());
54
- });
55
- };
56
- var __generator = (this && this.__generator) || function (thisArg, body) {
57
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
58
- return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
59
- function verb(n) { return function (v) { return step([n, v]); }; }
60
- function step(op) {
61
- if (f) throw new TypeError("Generator is already executing.");
62
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
63
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
64
- if (y = 0, t) op = [op[0] & 2, t.value];
65
- switch (op[0]) {
66
- case 0: case 1: t = op; break;
67
- case 4: _.label++; return { value: op[1], done: false };
68
- case 5: _.label++; y = op[1]; op = [0]; continue;
69
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
70
- default:
71
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
72
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
73
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
74
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
75
- if (t[2]) _.ops.pop();
76
- _.trys.pop(); continue;
77
- }
78
- op = body.call(thisArg, _);
79
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
80
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
81
- }
82
- };
83
47
  Object.defineProperty(exports, "__esModule", { value: true });
84
48
  exports.useTaxStateContext = exports.TaxStateContextProvider = exports.TaxStateContext = void 0;
85
49
  var react_1 = __importStar(require("react"));
@@ -148,6 +112,9 @@ var useTaxState = function () {
148
112
  dispatch({
149
113
  type: actions_1.TAX_ACTION_TYPES.RESET_FORM,
150
114
  });
115
+ dispatch({
116
+ type: actions_1.TAX_ACTION_TYPES.RESET_ERRORS,
117
+ });
151
118
  listFetchNow();
152
119
  dispatch({
153
120
  type: actions_1.TAX_ACTION_TYPES.SET_DRAWER,
@@ -246,12 +213,12 @@ var useTaxState = function () {
246
213
  type: actions_1.TAX_ACTION_TYPES.RESET_FORM,
247
214
  });
248
215
  dispatch({
249
- type: actions_1.TAX_ACTION_TYPES.CLEAR_ERRORS,
216
+ type: actions_1.TAX_ACTION_TYPES.RESET_ERRORS,
250
217
  });
251
218
  };
252
219
  var handleOnChange = function (k, v) {
253
220
  dispatch({
254
- type: actions_1.TAX_ACTION_TYPES.CLEAR_ERRORS,
221
+ type: actions_1.TAX_ACTION_TYPES.RESET_ERRORS,
255
222
  });
256
223
  dispatch({
257
224
  type: actions_1.TAX_ACTION_TYPES.SET_DISABLE_SAVE_BUTTON,
@@ -274,40 +241,27 @@ var useTaxState = function () {
274
241
  },
275
242
  });
276
243
  };
277
- var handleSubmit = (0, react_1.useCallback)(function () { return __awaiter(void 0, void 0, void 0, function () {
278
- var validationResult, validationErrors_1;
279
- return __generator(this, function (_a) {
280
- dispatch({
281
- type: actions_1.TAX_ACTION_TYPES.SET_DISABLE_SAVE_BUTTON,
282
- payload: { disableSaveButton: true },
283
- });
284
- try {
285
- validationResult = validate_1.formValidation === null || validate_1.formValidation === void 0 ? void 0 : validate_1.formValidation.safeParse(__assign({}, updateParams));
286
- if (validationResult === null || validationResult === void 0 ? void 0 : validationResult.error) {
287
- validationErrors_1 = {};
288
- validationResult === null || validationResult === void 0 ? void 0 : validationResult.error.issues.forEach(function (err) {
289
- validationErrors_1[err.path[0]] = err.message;
290
- });
291
- dispatch({
292
- type: actions_1.TAX_ACTION_TYPES.SET_ERRORS,
293
- payload: { errors: validationErrors_1 },
294
- });
295
- }
296
- if (validationResult === null || validationResult === void 0 ? void 0 : validationResult.success) {
297
- updateFetchNow(undefined, {
298
- body: JSON.stringify(__assign(__assign({}, updateParams), { description: state.description })),
299
- });
300
- }
301
- }
302
- catch (_b) {
303
- (0, generate_toast_1.generateToast)({
304
- description: '',
305
- variant: vista_notification_type_1.VISTA_NOTIFICATION_V1_VARIANT.ERROR,
244
+ var handleSubmit = (0, react_1.useCallback)(function () {
245
+ dispatch({
246
+ type: actions_1.TAX_ACTION_TYPES.SET_DISABLE_SAVE_BUTTON,
247
+ payload: { disableSaveButton: true },
248
+ });
249
+ (0, util_functions_1.validateForm)({
250
+ params: updateParams,
251
+ schema: validate_1.formValidation,
252
+ successCallback: function () {
253
+ updateFetchNow(undefined, {
254
+ body: JSON.stringify(__assign(__assign({}, updateParams), { description: state.description })),
306
255
  });
307
- }
308
- return [2 /*return*/];
256
+ },
257
+ errorCallback: function (e) {
258
+ dispatch({
259
+ type: actions_1.TAX_ACTION_TYPES.SET_ERRORS,
260
+ payload: { errors: e },
261
+ });
262
+ },
309
263
  });
310
- }); }, [updateFetchNow, updateParams, state.description]);
264
+ }, [updateFetchNow, updateParams, state.description]);
311
265
  var dynamicFormElements = (0, react_1.useMemo)(function () {
312
266
  var _a, _b, _c;
313
267
  var elements = __assign({}, constants_1.staticFormElements);
@@ -58,7 +58,7 @@ function taxReducer(state, action) {
58
58
  return __assign(__assign({}, state), (_a = {}, _a[action.payload.key] = action.payload.value, _a));
59
59
  case actions_1.TAX_ACTION_TYPES.SET_DISABLE_SAVE_BUTTON:
60
60
  return __assign(__assign({}, state), { disableSaveButton: action.payload.disableSaveButton });
61
- case actions_1.TAX_ACTION_TYPES.CLEAR_ERRORS:
61
+ case actions_1.TAX_ACTION_TYPES.RESET_ERRORS:
62
62
  return __assign(__assign({}, state), { errors: {} });
63
63
  case actions_1.TAX_ACTION_TYPES.SET_CURRENT_PAGE:
64
64
  return __assign(__assign({}, state), { currentPage: action.payload.currentPage });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@appcorp/stellar-solutions-modules",
3
- "version": "0.1.23",
3
+ "version": "0.1.25",
4
4
  "scripts": {
5
5
  "build": "yarn clean && yarn build:ts && cp package.json lib && cp README.md lib && cp yarn.lock lib",
6
6
  "build:next": "next build",
@@ -21,7 +21,7 @@
21
21
  "@eslint/eslintrc": "^3",
22
22
  "@headlessui/react": "^2",
23
23
  "@heroicons/react": "^2",
24
- "@react-pakistan/util-functions": "^1.24.33",
24
+ "@react-pakistan/util-functions": "^1.24.36",
25
25
  "@supabase/supabase-js": "^2",
26
26
  "@tailwindcss/forms": "^0.5.10",
27
27
  "@tailwindcss/postcss": "^4",