@appcorp/stellar-solutions-invoice-module 0.1.73 → 0.1.75
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.
- package/base-modules/invoice/add-service-product-section.d.ts +1 -5
- package/base-modules/invoice/add-service-product-section.js +3 -3
- package/base-modules/invoice/cache.d.ts +15 -0
- package/base-modules/invoice/cache.js +50 -0
- package/base-modules/invoice/calculate-subtotal.d.ts +6 -1
- package/base-modules/invoice/calculate-subtotal.js +2 -2
- package/base-modules/invoice/calculate-total.d.ts +1 -1
- package/base-modules/invoice/calculate-total.js +8 -8
- package/base-modules/invoice/company-form-section.d.ts +1 -5
- package/base-modules/invoice/company-form-section.js +25 -22
- package/base-modules/invoice/constants.d.ts +2 -3
- package/base-modules/invoice/constants.js +2 -3
- package/base-modules/invoice/context.d.ts +556 -20
- package/base-modules/invoice/context.js +542 -340
- package/base-modules/invoice/customer-form-section.d.ts +1 -5
- package/base-modules/invoice/customer-form-section.js +25 -9
- package/base-modules/invoice/form.d.ts +1 -5
- package/base-modules/invoice/form.js +9 -9
- package/base-modules/invoice/page.d.ts +8 -0
- package/base-modules/invoice/page.js +171 -0
- package/base-modules/invoice/pricing-form-section.d.ts +1 -5
- package/base-modules/invoice/pricing-form-section.js +16 -11
- package/base-modules/invoice/products-form-section.d.ts +1 -5
- package/base-modules/invoice/products-form-section.js +49 -41
- package/base-modules/invoice/services-form-section.d.ts +1 -5
- package/base-modules/invoice/services-form-section.js +10 -9
- package/base-modules/invoice/validate.d.ts +83 -25
- package/base-modules/invoice/validate.js +4 -4
- package/base-modules/payment/cache.d.ts +15 -0
- package/base-modules/payment/cache.js +52 -0
- package/base-modules/payment/constants.d.ts +1 -14
- package/base-modules/payment/constants.js +2 -15
- package/base-modules/payment/context.d.ts +214 -48
- package/base-modules/payment/context.js +312 -240
- package/base-modules/payment/drawer.d.ts +0 -6
- package/base-modules/payment/drawer.js +89 -44
- package/base-modules/payment/form.js +3 -2
- package/base-modules/payment/{payment.js → page.js} +2 -5
- package/base-modules/payment/types.d.ts +0 -85
- package/base-modules/payment/types.js +74 -21
- package/base-modules/payment/validate.d.ts +12 -0
- package/base-modules/payment/validate.js +19 -8
- package/base-modules/payment/view.d.ts +1 -5
- package/base-modules/payment/view.js +4 -3
- package/base-modules/quote/add-service-product-section.js +1 -1
- package/base-modules/quote/cache.d.ts +15 -0
- package/base-modules/quote/cache.js +50 -0
- package/base-modules/quote/company-form-section.d.ts +1 -1
- package/base-modules/quote/company-form-section.js +14 -12
- package/base-modules/quote/constants.js +1 -0
- package/base-modules/quote/context.d.ts +656 -46
- package/base-modules/quote/context.js +431 -293
- package/base-modules/quote/customer-form-section.d.ts +1 -1
- package/base-modules/quote/customer-form-section.js +24 -9
- package/base-modules/quote/form.d.ts +1 -5
- package/base-modules/quote/form.js +8 -9
- package/base-modules/quote/page.d.ts +8 -0
- package/base-modules/quote/page.js +163 -0
- package/base-modules/quote/pricing-form-section.js +9 -8
- package/base-modules/quote/products-form-section.js +2 -3
- package/base-modules/quote/services-form-section.js +1 -1
- package/base-modules/quote/types.d.ts +0 -127
- package/base-modules/quote/types.js +92 -35
- package/base-modules/quote/validate.d.ts +82 -25
- package/base-modules/quote/validate.js +3 -4
- package/package.json +12 -11
- package/base-modules/invoice/actions.d.ts +0 -215
- package/base-modules/invoice/actions.js +0 -38
- package/base-modules/invoice/drawer.d.ts +0 -13
- package/base-modules/invoice/drawer.js +0 -46
- package/base-modules/invoice/invoice.d.ts +0 -8
- package/base-modules/invoice/invoice.js +0 -69
- package/base-modules/invoice/reducer.d.ts +0 -4
- package/base-modules/invoice/reducer.js +0 -180
- package/base-modules/invoice/types.d.ts +0 -211
- package/base-modules/invoice/types.js +0 -43
- package/base-modules/payment/actions.d.ts +0 -203
- package/base-modules/payment/actions.js +0 -50
- package/base-modules/payment/reducer.d.ts +0 -29
- package/base-modules/payment/reducer.js +0 -215
- package/base-modules/quote/actions.d.ts +0 -215
- package/base-modules/quote/actions.js +0 -38
- package/base-modules/quote/drawer.d.ts +0 -13
- package/base-modules/quote/drawer.js +0 -46
- package/base-modules/quote/quote.d.ts +0 -8
- package/base-modules/quote/quote.js +0 -69
- package/base-modules/quote/reducer.d.ts +0 -4
- package/base-modules/quote/reducer.js +0 -181
- /package/base-modules/payment/{payment.d.ts → page.d.ts} +0 -0
|
@@ -1,203 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Payment Actions
|
|
3
|
-
*
|
|
4
|
-
* This module defines all action types and interfaces for the Payment state management.
|
|
5
|
-
* Actions are organized by functionality and follow consistent naming patterns.
|
|
6
|
-
*
|
|
7
|
-
* Organization:
|
|
8
|
-
* - Action Types Enum (grouped by functionality)
|
|
9
|
-
* - Reset Actions (form/error reset)
|
|
10
|
-
* - Form Data Actions (input fields, form state)
|
|
11
|
-
* - UI State Actions (drawers, modals, buttons)
|
|
12
|
-
* - List Management Actions (payments, pagination)
|
|
13
|
-
* - Search Actions (queries, filters)
|
|
14
|
-
* - Union Type Export
|
|
15
|
-
*
|
|
16
|
-
* Naming Convention: Payment{Operation}{Target}Action
|
|
17
|
-
* Examples: PaymentSetInputFieldAction, PaymentResetFormAction
|
|
18
|
-
*/
|
|
19
|
-
import { PAYMENT_DRAWER, PAYMENT_MODAL, PaymentModeTypeBE, PaymentTypeBE } from "./types";
|
|
20
|
-
import { QuoteInvoiceTypeBE } from "../invoice/types";
|
|
21
|
-
export declare enum PAYMENT_ACTION_TYPES {
|
|
22
|
-
RESET_ERRORS = "RESET_ERRORS",
|
|
23
|
-
RESET_FORM = "RESET_FORM",
|
|
24
|
-
SET_ERRORS = "SET_ERRORS",
|
|
25
|
-
SET_FORM = "SET_FORM",
|
|
26
|
-
SET_INPUT_FIELD = "SET_INPUT_FIELD",
|
|
27
|
-
SET_DISABLE_SAVE_BUTTON = "SET_DISABLE_SAVE_BUTTON",
|
|
28
|
-
SET_DRAWER = "SET_DRAWER",
|
|
29
|
-
SET_MODAL = "SET_MODAL",
|
|
30
|
-
SET_COUNT = "SET_COUNT",
|
|
31
|
-
SET_CURRENT_PAGE = "SET_CURRENT_PAGE",
|
|
32
|
-
SET_PAGE_LIMIT = "SET_PAGE_LIMIT",
|
|
33
|
-
SET_PAYMENT_MODES = "SET_PAYMENT_MODES",
|
|
34
|
-
SET_PAYMENTS = "SET_PAYMENTS",
|
|
35
|
-
SET_QUOTE_INVOICES = "SET_QUOTE_INVOICES",
|
|
36
|
-
SET_PAYMENT_MODE_QUERY = "SET_PAYMENT_MODE_QUERY",
|
|
37
|
-
SET_QUOTE_INVOICE_QUERY = "SET_QUOTE_INVOICE_QUERY",
|
|
38
|
-
SET_SEARCH_QUERY = "SET_SEARCH_QUERY",
|
|
39
|
-
SET_INVOICE = "SET_INVOICE"
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* Reset form validation errors
|
|
43
|
-
*/
|
|
44
|
-
export type PaymentResetErrorsAction = {
|
|
45
|
-
type: PAYMENT_ACTION_TYPES.RESET_ERRORS;
|
|
46
|
-
};
|
|
47
|
-
/**
|
|
48
|
-
* Reset entire form to initial state
|
|
49
|
-
*/
|
|
50
|
-
export type PaymentResetFormAction = {
|
|
51
|
-
type: PAYMENT_ACTION_TYPES.RESET_FORM;
|
|
52
|
-
};
|
|
53
|
-
/**
|
|
54
|
-
* Set form validation errors
|
|
55
|
-
*/
|
|
56
|
-
export type PaymentSetErrorsAction = {
|
|
57
|
-
type: PAYMENT_ACTION_TYPES.SET_ERRORS;
|
|
58
|
-
payload: {
|
|
59
|
-
errors: {
|
|
60
|
-
[key: string]: string;
|
|
61
|
-
};
|
|
62
|
-
};
|
|
63
|
-
};
|
|
64
|
-
/**
|
|
65
|
-
* Set entire form data (used when editing existing payment)
|
|
66
|
-
*/
|
|
67
|
-
export type PaymentSetFormAction = {
|
|
68
|
-
type: PAYMENT_ACTION_TYPES.SET_FORM;
|
|
69
|
-
payload: {
|
|
70
|
-
form: PaymentTypeBE;
|
|
71
|
-
};
|
|
72
|
-
};
|
|
73
|
-
/**
|
|
74
|
-
* Update individual form field dynamically
|
|
75
|
-
*/
|
|
76
|
-
export type PaymentSetInputFieldAction = {
|
|
77
|
-
type: PAYMENT_ACTION_TYPES.SET_INPUT_FIELD;
|
|
78
|
-
payload: {
|
|
79
|
-
key: string;
|
|
80
|
-
value: string | string[] | boolean | number | number[];
|
|
81
|
-
};
|
|
82
|
-
};
|
|
83
|
-
/**
|
|
84
|
-
* Disable or enable the save button
|
|
85
|
-
*/
|
|
86
|
-
export type PaymentSetDisableSaveButtonAction = {
|
|
87
|
-
type: PAYMENT_ACTION_TYPES.SET_DISABLE_SAVE_BUTTON;
|
|
88
|
-
payload: {
|
|
89
|
-
disableSaveButton: boolean;
|
|
90
|
-
};
|
|
91
|
-
};
|
|
92
|
-
/**
|
|
93
|
-
* Set the current drawer state
|
|
94
|
-
*/
|
|
95
|
-
export type PaymentSetDrawerAction = {
|
|
96
|
-
type: PAYMENT_ACTION_TYPES.SET_DRAWER;
|
|
97
|
-
payload: {
|
|
98
|
-
drawer: PAYMENT_DRAWER | null;
|
|
99
|
-
};
|
|
100
|
-
};
|
|
101
|
-
/**
|
|
102
|
-
* Set the current modal state
|
|
103
|
-
*/
|
|
104
|
-
export type PaymentSetModalAction = {
|
|
105
|
-
type: PAYMENT_ACTION_TYPES.SET_MODAL;
|
|
106
|
-
payload: {
|
|
107
|
-
modal: PAYMENT_MODAL | null;
|
|
108
|
-
};
|
|
109
|
-
};
|
|
110
|
-
/**
|
|
111
|
-
* Set the total count of payments
|
|
112
|
-
*/
|
|
113
|
-
export type PaymentSetCountAction = {
|
|
114
|
-
type: PAYMENT_ACTION_TYPES.SET_COUNT;
|
|
115
|
-
payload: {
|
|
116
|
-
count: number;
|
|
117
|
-
};
|
|
118
|
-
};
|
|
119
|
-
/**
|
|
120
|
-
* Set the current page for pagination
|
|
121
|
-
*/
|
|
122
|
-
export type PaymentSetCurrentPageAction = {
|
|
123
|
-
type: PAYMENT_ACTION_TYPES.SET_CURRENT_PAGE;
|
|
124
|
-
payload: {
|
|
125
|
-
currentPage: number;
|
|
126
|
-
};
|
|
127
|
-
};
|
|
128
|
-
/**
|
|
129
|
-
* Set the page limit for pagination
|
|
130
|
-
*/
|
|
131
|
-
export type PaymentSetPageLimitAction = {
|
|
132
|
-
type: PAYMENT_ACTION_TYPES.SET_PAGE_LIMIT;
|
|
133
|
-
payload: {
|
|
134
|
-
pageLimit: number;
|
|
135
|
-
};
|
|
136
|
-
};
|
|
137
|
-
/**
|
|
138
|
-
* Set the list of payment modes
|
|
139
|
-
*/
|
|
140
|
-
export type PaymentSetPaymentModesAction = {
|
|
141
|
-
type: PAYMENT_ACTION_TYPES.SET_PAYMENT_MODES;
|
|
142
|
-
payload: {
|
|
143
|
-
paymentModes: PaymentModeTypeBE[];
|
|
144
|
-
};
|
|
145
|
-
};
|
|
146
|
-
/**
|
|
147
|
-
* Set the list of payments
|
|
148
|
-
*/
|
|
149
|
-
export type PaymentSetPaymentsAction = {
|
|
150
|
-
type: PAYMENT_ACTION_TYPES.SET_PAYMENTS;
|
|
151
|
-
payload: {
|
|
152
|
-
payments: PaymentTypeBE[];
|
|
153
|
-
};
|
|
154
|
-
};
|
|
155
|
-
/**
|
|
156
|
-
* Set the list of quote invoices
|
|
157
|
-
*/
|
|
158
|
-
export type PaymentSetQuoteInvoicesAction = {
|
|
159
|
-
type: PAYMENT_ACTION_TYPES.SET_QUOTE_INVOICES;
|
|
160
|
-
payload: {
|
|
161
|
-
quoteInvoices: QuoteInvoiceTypeBE[];
|
|
162
|
-
};
|
|
163
|
-
};
|
|
164
|
-
/**
|
|
165
|
-
* Set the search query for payment modes
|
|
166
|
-
*/
|
|
167
|
-
export type PaymentSetPaymentModeQueryAction = {
|
|
168
|
-
type: PAYMENT_ACTION_TYPES.SET_PAYMENT_MODE_QUERY;
|
|
169
|
-
payload: {
|
|
170
|
-
paymentModeQuery: string;
|
|
171
|
-
};
|
|
172
|
-
};
|
|
173
|
-
/**
|
|
174
|
-
* Set the search query for quote invoices
|
|
175
|
-
*/
|
|
176
|
-
export type PaymentSetQuoteInvoiceQueryAction = {
|
|
177
|
-
type: PAYMENT_ACTION_TYPES.SET_QUOTE_INVOICE_QUERY;
|
|
178
|
-
payload: {
|
|
179
|
-
quoteInvoiceQuery: string;
|
|
180
|
-
};
|
|
181
|
-
};
|
|
182
|
-
/**
|
|
183
|
-
* Set the search query for payments
|
|
184
|
-
*/
|
|
185
|
-
export type PaymentSetSearchQueryAction = {
|
|
186
|
-
type: PAYMENT_ACTION_TYPES.SET_SEARCH_QUERY;
|
|
187
|
-
payload: {
|
|
188
|
-
searchQuery: string;
|
|
189
|
-
};
|
|
190
|
-
};
|
|
191
|
-
export type PaymentSetInvoiceAction = {
|
|
192
|
-
type: PAYMENT_ACTION_TYPES.SET_INVOICE;
|
|
193
|
-
payload: {
|
|
194
|
-
invoice: QuoteInvoiceTypeBE | null;
|
|
195
|
-
};
|
|
196
|
-
};
|
|
197
|
-
/**
|
|
198
|
-
* All Payment Actions
|
|
199
|
-
*
|
|
200
|
-
* A union of all action types for the Payment module, representing all possible actions
|
|
201
|
-
* that can be dispatched to modify the Payment state.
|
|
202
|
-
*/
|
|
203
|
-
export type PaymentActions = PaymentResetErrorsAction | PaymentResetFormAction | PaymentSetCountAction | PaymentSetCurrentPageAction | PaymentSetDisableSaveButtonAction | PaymentSetDrawerAction | PaymentSetErrorsAction | PaymentSetFormAction | PaymentSetInputFieldAction | PaymentSetModalAction | PaymentSetPageLimitAction | PaymentSetPaymentModeQueryAction | PaymentSetPaymentModesAction | PaymentSetPaymentsAction | PaymentSetQuoteInvoiceQueryAction | PaymentSetQuoteInvoicesAction | PaymentSetSearchQueryAction | PaymentSetInvoiceAction;
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Payment Actions
|
|
4
|
-
*
|
|
5
|
-
* This module defines all action types and interfaces for the Payment state management.
|
|
6
|
-
* Actions are organized by functionality and follow consistent naming patterns.
|
|
7
|
-
*
|
|
8
|
-
* Organization:
|
|
9
|
-
* - Action Types Enum (grouped by functionality)
|
|
10
|
-
* - Reset Actions (form/error reset)
|
|
11
|
-
* - Form Data Actions (input fields, form state)
|
|
12
|
-
* - UI State Actions (drawers, modals, buttons)
|
|
13
|
-
* - List Management Actions (payments, pagination)
|
|
14
|
-
* - Search Actions (queries, filters)
|
|
15
|
-
* - Union Type Export
|
|
16
|
-
*
|
|
17
|
-
* Naming Convention: Payment{Operation}{Target}Action
|
|
18
|
-
* Examples: PaymentSetInputFieldAction, PaymentResetFormAction
|
|
19
|
-
*/
|
|
20
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
-
exports.PAYMENT_ACTION_TYPES = void 0;
|
|
22
|
-
// ============================================================================
|
|
23
|
-
// ACTION TYPES ENUM
|
|
24
|
-
// ============================================================================
|
|
25
|
-
var PAYMENT_ACTION_TYPES;
|
|
26
|
-
(function (PAYMENT_ACTION_TYPES) {
|
|
27
|
-
// Reset Actions
|
|
28
|
-
PAYMENT_ACTION_TYPES["RESET_ERRORS"] = "RESET_ERRORS";
|
|
29
|
-
PAYMENT_ACTION_TYPES["RESET_FORM"] = "RESET_FORM";
|
|
30
|
-
// Form Data Actions
|
|
31
|
-
PAYMENT_ACTION_TYPES["SET_ERRORS"] = "SET_ERRORS";
|
|
32
|
-
PAYMENT_ACTION_TYPES["SET_FORM"] = "SET_FORM";
|
|
33
|
-
PAYMENT_ACTION_TYPES["SET_INPUT_FIELD"] = "SET_INPUT_FIELD";
|
|
34
|
-
// UI State Actions
|
|
35
|
-
PAYMENT_ACTION_TYPES["SET_DISABLE_SAVE_BUTTON"] = "SET_DISABLE_SAVE_BUTTON";
|
|
36
|
-
PAYMENT_ACTION_TYPES["SET_DRAWER"] = "SET_DRAWER";
|
|
37
|
-
PAYMENT_ACTION_TYPES["SET_MODAL"] = "SET_MODAL";
|
|
38
|
-
// List Management Actions
|
|
39
|
-
PAYMENT_ACTION_TYPES["SET_COUNT"] = "SET_COUNT";
|
|
40
|
-
PAYMENT_ACTION_TYPES["SET_CURRENT_PAGE"] = "SET_CURRENT_PAGE";
|
|
41
|
-
PAYMENT_ACTION_TYPES["SET_PAGE_LIMIT"] = "SET_PAGE_LIMIT";
|
|
42
|
-
PAYMENT_ACTION_TYPES["SET_PAYMENT_MODES"] = "SET_PAYMENT_MODES";
|
|
43
|
-
PAYMENT_ACTION_TYPES["SET_PAYMENTS"] = "SET_PAYMENTS";
|
|
44
|
-
PAYMENT_ACTION_TYPES["SET_QUOTE_INVOICES"] = "SET_QUOTE_INVOICES";
|
|
45
|
-
// Search Actions
|
|
46
|
-
PAYMENT_ACTION_TYPES["SET_PAYMENT_MODE_QUERY"] = "SET_PAYMENT_MODE_QUERY";
|
|
47
|
-
PAYMENT_ACTION_TYPES["SET_QUOTE_INVOICE_QUERY"] = "SET_QUOTE_INVOICE_QUERY";
|
|
48
|
-
PAYMENT_ACTION_TYPES["SET_SEARCH_QUERY"] = "SET_SEARCH_QUERY";
|
|
49
|
-
PAYMENT_ACTION_TYPES["SET_INVOICE"] = "SET_INVOICE";
|
|
50
|
-
})(PAYMENT_ACTION_TYPES || (exports.PAYMENT_ACTION_TYPES = PAYMENT_ACTION_TYPES = {}));
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Payment State Reducer
|
|
3
|
-
*
|
|
4
|
-
* This module manages the state transitions for the Payment feature using the reducer pattern.
|
|
5
|
-
* Handles all state updates in a predictable and optimized manner.
|
|
6
|
-
*
|
|
7
|
-
* Features:
|
|
8
|
-
* - Form state management (create/edit payment data)
|
|
9
|
-
* - UI state management (drawers, modals, loading states)
|
|
10
|
-
* - Search and pagination state
|
|
11
|
-
* - Error handling state
|
|
12
|
-
*
|
|
13
|
-
* Performance Optimizations:
|
|
14
|
-
* - Grouped related actions for better readability and maintainability
|
|
15
|
-
* - Helper functions for common operations (form reset, array updates, error merging)
|
|
16
|
-
* - Optimized object spreading patterns with shallow copies
|
|
17
|
-
* - Immutable state updates to prevent reference issues
|
|
18
|
-
* - Clear action-to-state mapping with logical grouping
|
|
19
|
-
*/
|
|
20
|
-
import { PaymentActions } from "./actions";
|
|
21
|
-
import { PaymentState } from "./types";
|
|
22
|
-
export declare const initialPaymentState: PaymentState;
|
|
23
|
-
/**
|
|
24
|
-
* Payment Reducer
|
|
25
|
-
*
|
|
26
|
-
* Handles all state transitions for the payment module.
|
|
27
|
-
* Maps actions to state updates in a predictable and optimized manner.
|
|
28
|
-
*/
|
|
29
|
-
export declare function paymentReducer(state: PaymentState, action: PaymentActions): PaymentState;
|
|
@@ -1,215 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Payment State Reducer
|
|
4
|
-
*
|
|
5
|
-
* This module manages the state transitions for the Payment feature using the reducer pattern.
|
|
6
|
-
* Handles all state updates in a predictable and optimized manner.
|
|
7
|
-
*
|
|
8
|
-
* Features:
|
|
9
|
-
* - Form state management (create/edit payment data)
|
|
10
|
-
* - UI state management (drawers, modals, loading states)
|
|
11
|
-
* - Search and pagination state
|
|
12
|
-
* - Error handling state
|
|
13
|
-
*
|
|
14
|
-
* Performance Optimizations:
|
|
15
|
-
* - Grouped related actions for better readability and maintainability
|
|
16
|
-
* - Helper functions for common operations (form reset, array updates, error merging)
|
|
17
|
-
* - Optimized object spreading patterns with shallow copies
|
|
18
|
-
* - Immutable state updates to prevent reference issues
|
|
19
|
-
* - Clear action-to-state mapping with logical grouping
|
|
20
|
-
*/
|
|
21
|
-
var __assign = (this && this.__assign) || function () {
|
|
22
|
-
__assign = Object.assign || function(t) {
|
|
23
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
24
|
-
s = arguments[i];
|
|
25
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
26
|
-
t[p] = s[p];
|
|
27
|
-
}
|
|
28
|
-
return t;
|
|
29
|
-
};
|
|
30
|
-
return __assign.apply(this, arguments);
|
|
31
|
-
};
|
|
32
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
33
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
34
|
-
if (ar || !(i in from)) {
|
|
35
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
36
|
-
ar[i] = from[i];
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
40
|
-
};
|
|
41
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
-
exports.initialPaymentState = void 0;
|
|
43
|
-
exports.paymentReducer = paymentReducer;
|
|
44
|
-
var actions_1 = require("./actions");
|
|
45
|
-
var types_1 = require("./types");
|
|
46
|
-
var pageLimit = Number(process.env.NEXT_PUBLIC_PAGE_LIMIT) || 10;
|
|
47
|
-
// ============================================================================
|
|
48
|
-
// HELPER FUNCTIONS
|
|
49
|
-
// ============================================================================
|
|
50
|
-
/**
|
|
51
|
-
* Helper function to reset form fields to their initial values
|
|
52
|
-
*/
|
|
53
|
-
var getFormResetState = function () { return ({
|
|
54
|
-
amount: "",
|
|
55
|
-
attachment: "",
|
|
56
|
-
balance: "",
|
|
57
|
-
currency: "",
|
|
58
|
-
date: new Date().toISOString(),
|
|
59
|
-
description: "",
|
|
60
|
-
disableSaveButton: false,
|
|
61
|
-
errors: {},
|
|
62
|
-
id: "",
|
|
63
|
-
mode: "Create",
|
|
64
|
-
paymentModeId: "",
|
|
65
|
-
paymentType: types_1.PAYMENT_TYPE.FULL_AMOUNT,
|
|
66
|
-
quoteInvoiceId: "",
|
|
67
|
-
ref: "",
|
|
68
|
-
invoice: null,
|
|
69
|
-
}); };
|
|
70
|
-
/**
|
|
71
|
-
* Helper function to safely update array state with immutability
|
|
72
|
-
*/
|
|
73
|
-
var updateArrayState = function (array) { return __spreadArray([], array, true); };
|
|
74
|
-
/**
|
|
75
|
-
* Helper function to safely merge errors with existing state
|
|
76
|
-
*/
|
|
77
|
-
var mergeErrors = function (errors) { return (__assign({}, errors)); };
|
|
78
|
-
// ============================================================================
|
|
79
|
-
// INITIAL STATE
|
|
80
|
-
// ============================================================================
|
|
81
|
-
exports.initialPaymentState = {
|
|
82
|
-
// Form data
|
|
83
|
-
amount: "",
|
|
84
|
-
attachment: "",
|
|
85
|
-
balance: "",
|
|
86
|
-
currency: "",
|
|
87
|
-
date: new Date().toISOString(),
|
|
88
|
-
description: "",
|
|
89
|
-
id: "",
|
|
90
|
-
mode: "Create",
|
|
91
|
-
paymentModeId: "",
|
|
92
|
-
paymentType: types_1.PAYMENT_TYPE.FULL_AMOUNT,
|
|
93
|
-
quoteInvoiceId: "",
|
|
94
|
-
ref: "",
|
|
95
|
-
invoice: null,
|
|
96
|
-
// List data
|
|
97
|
-
count: 0,
|
|
98
|
-
paymentModes: [],
|
|
99
|
-
payments: [],
|
|
100
|
-
quoteInvoices: [],
|
|
101
|
-
// Search & Pagination
|
|
102
|
-
currentPage: 1,
|
|
103
|
-
pageLimit: pageLimit,
|
|
104
|
-
paymentModeQuery: "",
|
|
105
|
-
quoteInvoiceQuery: "",
|
|
106
|
-
searchQuery: "",
|
|
107
|
-
// UI state
|
|
108
|
-
disableSaveButton: true,
|
|
109
|
-
drawer: null,
|
|
110
|
-
// Errors
|
|
111
|
-
errors: {},
|
|
112
|
-
};
|
|
113
|
-
// ============================================================================
|
|
114
|
-
// REDUCER FUNCTION
|
|
115
|
-
// ============================================================================
|
|
116
|
-
/**
|
|
117
|
-
* Payment Reducer
|
|
118
|
-
*
|
|
119
|
-
* Handles all state transitions for the payment module.
|
|
120
|
-
* Maps actions to state updates in a predictable and optimized manner.
|
|
121
|
-
*/
|
|
122
|
-
function paymentReducer(state, action) {
|
|
123
|
-
var _a;
|
|
124
|
-
switch (action.type) {
|
|
125
|
-
// ------------------------------------------------------------------------
|
|
126
|
-
// FORM RESET ACTIONS
|
|
127
|
-
// ------------------------------------------------------------------------
|
|
128
|
-
case actions_1.PAYMENT_ACTION_TYPES.RESET_ERRORS:
|
|
129
|
-
return __assign(__assign({}, state), { errors: {} });
|
|
130
|
-
case actions_1.PAYMENT_ACTION_TYPES.RESET_FORM:
|
|
131
|
-
return __assign(__assign(__assign({}, state), getFormResetState()), {
|
|
132
|
-
// Preserve lists when resetting form
|
|
133
|
-
paymentModes: state.paymentModes, payments: state.payments, quoteInvoices: state.quoteInvoices, count: state.count });
|
|
134
|
-
// ------------------------------------------------------------------------
|
|
135
|
-
// FORM INPUT ACTIONS
|
|
136
|
-
// ------------------------------------------------------------------------
|
|
137
|
-
case actions_1.PAYMENT_ACTION_TYPES.SET_INPUT_FIELD:
|
|
138
|
-
return __assign(__assign({}, state), (_a = {}, _a[action.payload.key] = action.payload.value, _a));
|
|
139
|
-
case actions_1.PAYMENT_ACTION_TYPES.SET_FORM:
|
|
140
|
-
return __assign(__assign(__assign({}, state), action.payload.form), { mode: "Edit" });
|
|
141
|
-
// ------------------------------------------------------------------------
|
|
142
|
-
// ERROR HANDLING ACTIONS
|
|
143
|
-
// ------------------------------------------------------------------------
|
|
144
|
-
case actions_1.PAYMENT_ACTION_TYPES.SET_ERRORS:
|
|
145
|
-
return __assign(__assign({}, state), { disableSaveButton: false, errors: mergeErrors(action.payload.errors) });
|
|
146
|
-
case actions_1.PAYMENT_ACTION_TYPES.SET_DISABLE_SAVE_BUTTON:
|
|
147
|
-
return __assign(__assign({}, state), { disableSaveButton: action.payload.disableSaveButton });
|
|
148
|
-
// ------------------------------------------------------------------------
|
|
149
|
-
// UI STATE ACTIONS
|
|
150
|
-
// ------------------------------------------------------------------------
|
|
151
|
-
case actions_1.PAYMENT_ACTION_TYPES.SET_DRAWER:
|
|
152
|
-
return __assign(__assign({}, state), { drawer: action.payload.drawer });
|
|
153
|
-
// ------------------------------------------------------------------------
|
|
154
|
-
// LIST DATA ACTIONS
|
|
155
|
-
// ------------------------------------------------------------------------
|
|
156
|
-
case actions_1.PAYMENT_ACTION_TYPES.SET_PAYMENTS:
|
|
157
|
-
return __assign(__assign({}, state), { payments: updateArrayState(action.payload.payments) });
|
|
158
|
-
case actions_1.PAYMENT_ACTION_TYPES.SET_PAYMENT_MODES:
|
|
159
|
-
return __assign(__assign({}, state), { paymentModes: updateArrayState(action.payload.paymentModes) });
|
|
160
|
-
case actions_1.PAYMENT_ACTION_TYPES.SET_QUOTE_INVOICES:
|
|
161
|
-
return __assign(__assign({}, state), { quoteInvoices: updateArrayState(action.payload.quoteInvoices) });
|
|
162
|
-
case actions_1.PAYMENT_ACTION_TYPES.SET_COUNT:
|
|
163
|
-
return __assign(__assign({}, state), { count: action.payload.count });
|
|
164
|
-
// ------------------------------------------------------------------------
|
|
165
|
-
// SEARCH ACTIONS
|
|
166
|
-
// ------------------------------------------------------------------------
|
|
167
|
-
case actions_1.PAYMENT_ACTION_TYPES.SET_PAYMENT_MODE_QUERY:
|
|
168
|
-
return __assign(__assign({}, state), { paymentModeQuery: action.payload.paymentModeQuery });
|
|
169
|
-
case actions_1.PAYMENT_ACTION_TYPES.SET_QUOTE_INVOICE_QUERY:
|
|
170
|
-
return __assign(__assign({}, state), { quoteInvoiceQuery: action.payload.quoteInvoiceQuery });
|
|
171
|
-
case actions_1.PAYMENT_ACTION_TYPES.SET_SEARCH_QUERY:
|
|
172
|
-
return __assign(__assign({}, state), { searchQuery: action.payload.searchQuery });
|
|
173
|
-
// ------------------------------------------------------------------------
|
|
174
|
-
// PAGINATION ACTIONS
|
|
175
|
-
// ------------------------------------------------------------------------
|
|
176
|
-
case actions_1.PAYMENT_ACTION_TYPES.SET_CURRENT_PAGE:
|
|
177
|
-
return __assign(__assign({}, state), { currentPage: action.payload.currentPage });
|
|
178
|
-
case actions_1.PAYMENT_ACTION_TYPES.SET_PAGE_LIMIT:
|
|
179
|
-
return __assign(__assign({}, state), { pageLimit: action.payload.pageLimit });
|
|
180
|
-
case actions_1.PAYMENT_ACTION_TYPES.SET_INVOICE:
|
|
181
|
-
return __assign(__assign({}, state), { invoice: action.payload.invoice });
|
|
182
|
-
// ------------------------------------------------------------------------
|
|
183
|
-
// DEFAULT CASE
|
|
184
|
-
// ------------------------------------------------------------------------
|
|
185
|
-
default:
|
|
186
|
-
return state;
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
// ============================================================================
|
|
190
|
-
// OPTIMIZATION SUMMARY
|
|
191
|
-
// ============================================================================
|
|
192
|
-
/*
|
|
193
|
-
* Reducer Optimizations Applied:
|
|
194
|
-
*
|
|
195
|
-
* 1. Structural Organization
|
|
196
|
-
* - Grouped related actions into logical sections
|
|
197
|
-
* - Added comprehensive documentation and comments
|
|
198
|
-
* - Organized initial state by functionality
|
|
199
|
-
*
|
|
200
|
-
* 2. Performance Improvements
|
|
201
|
-
* - Helper functions for common operations (getFormResetState, updateArrayState, mergeErrors)
|
|
202
|
-
* - Immutable state updates using spread operator
|
|
203
|
-
* - Optimized object creation patterns
|
|
204
|
-
* - Consistent shallow copying for arrays
|
|
205
|
-
*
|
|
206
|
-
* 3. Code Quality
|
|
207
|
-
* - Clear section headers for better navigation
|
|
208
|
-
* - Consistent action handling patterns
|
|
209
|
-
* - Improved readability with logical grouping
|
|
210
|
-
*
|
|
211
|
-
* 4. Maintainability
|
|
212
|
-
* - Predictable state update patterns
|
|
213
|
-
* - Easy-to-locate action handlers
|
|
214
|
-
* - Self-documenting code structure
|
|
215
|
-
*/
|