@appcorp/stellar-solutions-modules 0.1.55 → 0.1.58
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/global-modules/bank/bank.d.ts +7 -1
- package/global-modules/bank/bank.js +5 -19
- package/global-modules/bank/constants.js +5 -5
- package/global-modules/bank/context.js +39 -41
- package/global-modules/bank/drawer.d.ts +0 -4
- package/global-modules/bank/drawer.js +8 -6
- package/global-modules/bank/form.d.ts +0 -3
- package/global-modules/bank/form.js +16 -13
- package/global-modules/bank/types.d.ts +2 -22
- package/global-modules/bank/validate.js +2 -2
- package/global-modules/branch/branch.d.ts +7 -1
- package/global-modules/branch/branch.js +6 -16
- package/global-modules/branch/constants.js +1 -1
- package/global-modules/branch/context.js +35 -21
- package/global-modules/branch/drawer.d.ts +0 -4
- package/global-modules/branch/drawer.js +8 -6
- package/global-modules/branch/form.d.ts +0 -3
- package/global-modules/branch/form.js +11 -12
- package/global-modules/branch/types.d.ts +9 -106
- package/global-modules/branch/validate.js +6 -6
- package/global-modules/currency/actions.d.ts +203 -0
- package/global-modules/currency/actions.js +153 -0
- package/global-modules/currency/constants.d.ts +33 -0
- package/global-modules/currency/constants.js +71 -0
- package/global-modules/currency/context.d.ts +41 -0
- package/global-modules/currency/context.js +422 -0
- package/global-modules/currency/currency.d.ts +8 -0
- package/global-modules/currency/currency.js +57 -0
- package/global-modules/currency/drawer.d.ts +27 -0
- package/global-modules/currency/drawer.js +76 -0
- package/global-modules/currency/form.d.ts +19 -0
- package/global-modules/currency/form.js +52 -0
- package/global-modules/currency/reducer.d.ts +25 -0
- package/global-modules/currency/reducer.js +153 -0
- package/global-modules/currency/types.d.ts +163 -0
- package/global-modules/currency/types.js +44 -0
- package/global-modules/currency/validate.d.ts +9 -0
- package/global-modules/currency/validate.js +18 -0
- package/global-modules/payment-mode/constants.js +1 -1
- package/global-modules/payment-mode/context.js +7 -9
- package/global-modules/payment-mode/drawer.d.ts +0 -4
- package/global-modules/payment-mode/drawer.js +8 -6
- package/global-modules/payment-mode/form.d.ts +0 -3
- package/global-modules/payment-mode/form.js +6 -7
- package/global-modules/payment-mode/payment-mode.d.ts +1 -1
- package/global-modules/payment-mode/payment-mode.js +38 -38
- package/global-modules/payment-mode/types.d.ts +12 -223
- package/global-modules/payment-mode/types.js +1 -9
- package/global-modules/payment-mode/validate.js +2 -2
- package/global-modules/preferences/constants.d.ts +0 -4
- package/global-modules/preferences/constants.js +14 -17
- package/global-modules/preferences/context.js +2 -1
- package/global-modules/preferences/preferences.js +2 -6
- package/global-modules/preferences/types.d.ts +14 -240
- package/global-modules/preferences/types.js +3 -6
- package/global-modules/tax/constants.js +1 -1
- package/global-modules/tax/context.js +8 -4
- package/global-modules/tax/drawer.d.ts +0 -4
- package/global-modules/tax/drawer.js +8 -6
- package/global-modules/tax/form.d.ts +0 -4
- package/global-modules/tax/form.js +6 -7
- package/global-modules/tax/tax.d.ts +1 -1
- package/global-modules/tax/tax.js +37 -37
- package/global-modules/tax/types.d.ts +9 -254
- package/global-modules/tax/types.js +1 -9
- package/i18n/routing.d.ts +1 -1
- package/package.json +3 -3
|
@@ -96,7 +96,7 @@ var useBranchState = function () {
|
|
|
96
96
|
// STATE & CORE HOOKS
|
|
97
97
|
// ---------------------------------------------------------------------------
|
|
98
98
|
var _a = (0, react_1.useReducer)(reducer_1.branchReducer, reducer_1.initialBranchState), state = _a[0], dispatch = _a[1];
|
|
99
|
-
var
|
|
99
|
+
var preferences = (0, context_1.usePreferenceStateContext)().preferences;
|
|
100
100
|
var theme = (0, next_themes_1.useTheme)().theme;
|
|
101
101
|
var t = (0, next_intl_1.useTranslations)("branch");
|
|
102
102
|
var tCommon = (0, next_intl_1.useTranslations)("common");
|
|
@@ -175,6 +175,10 @@ var useBranchState = function () {
|
|
|
175
175
|
var data = _a.data, error = _a.error;
|
|
176
176
|
if (error) {
|
|
177
177
|
showErrorToast(tCommon("messagesNetworkError"));
|
|
178
|
+
dispatch({
|
|
179
|
+
type: actions_1.BRANCH_ACTION_TYPES.SET_DISABLE_SAVE_BUTTON,
|
|
180
|
+
payload: { disableSaveButton: false },
|
|
181
|
+
});
|
|
178
182
|
}
|
|
179
183
|
if (data) {
|
|
180
184
|
showSuccessToast(t("messagesBranchUpdated"));
|
|
@@ -221,7 +225,7 @@ var useBranchState = function () {
|
|
|
221
225
|
// ---------------------------------------------------------------------------
|
|
222
226
|
// MODULE ENTITY HOOK
|
|
223
227
|
// ---------------------------------------------------------------------------
|
|
224
|
-
var
|
|
228
|
+
var _b = (0, util_functions_1.useModuleEntity)({
|
|
225
229
|
byIdCallback: byIdCallback,
|
|
226
230
|
byIdParams: byIdParams,
|
|
227
231
|
deleteCallback: deleteCallback,
|
|
@@ -229,26 +233,24 @@ var useBranchState = function () {
|
|
|
229
233
|
listCallback: listCallback,
|
|
230
234
|
listParams: listParams,
|
|
231
235
|
listUrl: constants_1.BRANCH_API_ROUTES.BRANCHES,
|
|
232
|
-
searchQuery:
|
|
236
|
+
searchQuery: debouncedQuery,
|
|
233
237
|
unitByIdUrl: constants_1.BRANCH_API_ROUTES.BRANCH_BY_ID,
|
|
234
238
|
unitUrl: constants_1.BRANCH_API_ROUTES.BRANCH,
|
|
235
239
|
updateCallback: updateCallback,
|
|
236
240
|
updateDeps: [state],
|
|
237
241
|
updateParams: updateParams,
|
|
238
|
-
}), byIdError =
|
|
242
|
+
}), byIdError = _b.byIdError, byIdFetchNow = _b.byIdFetchNow, byIdLoading = _b.byIdLoading, deleteError = _b.deleteError, deleteFetchNow = _b.deleteFetchNow, deleteLoading = _b.deleteLoading, listError = _b.listError, listFetchNow = _b.listFetchNow, listLoading = _b.listLoading, updateError = _b.updateError, updateFetchNow = _b.updateFetchNow, updateLoading = _b.updateLoading;
|
|
239
243
|
// ---------------------------------------------------------------------------
|
|
240
244
|
// EFFECTS (list refresh)
|
|
241
245
|
// ---------------------------------------------------------------------------
|
|
242
246
|
(0, react_1.useEffect)(function () {
|
|
243
|
-
|
|
244
|
-
listFetchNow();
|
|
245
|
-
}
|
|
247
|
+
listFetchNow();
|
|
246
248
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
247
|
-
}, [debouncedQuery, state.currentPage, state.pageLimit
|
|
249
|
+
}, [debouncedQuery, state.currentPage, state.pageLimit]);
|
|
248
250
|
// ---------------------------------------------------------------------------
|
|
249
251
|
// DRAWER & MODAL HANDLERS
|
|
250
252
|
// ---------------------------------------------------------------------------
|
|
251
|
-
var closeDrawer =
|
|
253
|
+
var closeDrawer = function () {
|
|
252
254
|
dispatch({
|
|
253
255
|
type: actions_1.BRANCH_ACTION_TYPES.SET_DRAWER,
|
|
254
256
|
payload: { drawer: null },
|
|
@@ -259,7 +261,7 @@ var useBranchState = function () {
|
|
|
259
261
|
dispatch({
|
|
260
262
|
type: actions_1.BRANCH_ACTION_TYPES.RESET_ERRORS,
|
|
261
263
|
});
|
|
262
|
-
}
|
|
264
|
+
};
|
|
263
265
|
// ---------------------------------------------------------------------------
|
|
264
266
|
// CRUD OPERATION HANDLERS
|
|
265
267
|
// ---------------------------------------------------------------------------
|
|
@@ -283,10 +285,17 @@ var useBranchState = function () {
|
|
|
283
285
|
// FORM HANDLERS
|
|
284
286
|
// ---------------------------------------------------------------------------
|
|
285
287
|
var handleInputChange = (0, react_1.useCallback)(function (key, value) {
|
|
288
|
+
dispatch({
|
|
289
|
+
type: actions_1.BRANCH_ACTION_TYPES.RESET_ERRORS,
|
|
290
|
+
});
|
|
286
291
|
dispatch({
|
|
287
292
|
type: actions_1.BRANCH_ACTION_TYPES.SET_INPUT_FIELD,
|
|
288
293
|
payload: { key: key, value: value },
|
|
289
294
|
});
|
|
295
|
+
dispatch({
|
|
296
|
+
type: actions_1.BRANCH_ACTION_TYPES.SET_DISABLE_SAVE_BUTTON,
|
|
297
|
+
payload: { disableSaveButton: false },
|
|
298
|
+
});
|
|
290
299
|
}, []);
|
|
291
300
|
var handleSubmit = (0, react_1.useCallback)(function () {
|
|
292
301
|
dispatch({
|
|
@@ -306,46 +315,51 @@ var useBranchState = function () {
|
|
|
306
315
|
type: actions_1.BRANCH_ACTION_TYPES.SET_ERRORS,
|
|
307
316
|
payload: { errors: errors },
|
|
308
317
|
});
|
|
318
|
+
dispatch({
|
|
319
|
+
type: actions_1.BRANCH_ACTION_TYPES.SET_DISABLE_SAVE_BUTTON,
|
|
320
|
+
payload: { disableSaveButton: false },
|
|
321
|
+
});
|
|
322
|
+
showErrorToast(tCommon("messagesValidationError"));
|
|
309
323
|
},
|
|
310
324
|
});
|
|
311
|
-
}, [updateFetchNow, updateParams]);
|
|
325
|
+
}, [updateFetchNow, updateParams, showErrorToast, tCommon]);
|
|
312
326
|
// ---------------------------------------------------------------------------
|
|
313
327
|
// PAGINATION HANDLERS
|
|
314
328
|
// ---------------------------------------------------------------------------
|
|
315
|
-
var handleNextClick =
|
|
329
|
+
var handleNextClick = function () {
|
|
316
330
|
dispatch({
|
|
317
331
|
type: actions_1.BRANCH_ACTION_TYPES.SET_CURRENT_PAGE,
|
|
318
332
|
payload: { currentPage: state.currentPage + 1 },
|
|
319
333
|
});
|
|
320
|
-
}
|
|
321
|
-
var handlePreviousClick =
|
|
334
|
+
};
|
|
335
|
+
var handlePreviousClick = function () {
|
|
322
336
|
dispatch({
|
|
323
337
|
type: actions_1.BRANCH_ACTION_TYPES.SET_CURRENT_PAGE,
|
|
324
338
|
payload: { currentPage: state.currentPage - 1 },
|
|
325
339
|
});
|
|
326
|
-
}
|
|
327
|
-
var handlePageLimit =
|
|
340
|
+
};
|
|
341
|
+
var handlePageLimit = function (k, v) {
|
|
328
342
|
var val = __assign({}, v);
|
|
329
343
|
dispatch({
|
|
330
344
|
type: actions_1.BRANCH_ACTION_TYPES.SET_PAGE_LIMIT,
|
|
331
345
|
payload: { pageLimit: Number(val.option) },
|
|
332
346
|
});
|
|
333
|
-
}
|
|
347
|
+
};
|
|
334
348
|
// ---------------------------------------------------------------------------
|
|
335
349
|
// SEARCH HANDLERS
|
|
336
350
|
// ---------------------------------------------------------------------------
|
|
337
|
-
var searchOnChange =
|
|
351
|
+
var searchOnChange = function (k, v) {
|
|
338
352
|
dispatch({
|
|
339
353
|
type: actions_1.BRANCH_ACTION_TYPES.SET_SEARCH_QUERY,
|
|
340
354
|
payload: { searchQuery: v },
|
|
341
355
|
});
|
|
342
|
-
}
|
|
343
|
-
var clearSearch =
|
|
356
|
+
};
|
|
357
|
+
var clearSearch = function () {
|
|
344
358
|
dispatch({
|
|
345
359
|
type: actions_1.BRANCH_ACTION_TYPES.SET_SEARCH_QUERY,
|
|
346
360
|
payload: { searchQuery: "" },
|
|
347
361
|
});
|
|
348
|
-
}
|
|
362
|
+
};
|
|
349
363
|
// ---------------------------------------------------------------------------
|
|
350
364
|
// TABLE ACTIONS (memoized)
|
|
351
365
|
// ---------------------------------------------------------------------------
|
|
@@ -22,10 +22,6 @@ import { FC } from "react";
|
|
|
22
22
|
interface BranchDrawerProps {
|
|
23
23
|
/** Whether the interface is in RTL (Right-to-Left) mode */
|
|
24
24
|
isRTL: boolean;
|
|
25
|
-
/** Translation map for internationalization */
|
|
26
|
-
translationMap: {
|
|
27
|
-
[key: string]: string;
|
|
28
|
-
};
|
|
29
25
|
}
|
|
30
26
|
export declare const BranchDrawer: FC<BranchDrawerProps>;
|
|
31
27
|
export {};
|
|
@@ -30,6 +30,7 @@ var button_1 = require("@appcorp/shadcn/components/button");
|
|
|
30
30
|
var drawer_1 = require("@appcorp/shadcn/components/drawer");
|
|
31
31
|
var context_1 = require("./context");
|
|
32
32
|
var form_1 = require("./form");
|
|
33
|
+
var next_intl_1 = require("next-intl");
|
|
33
34
|
// ============================================================================
|
|
34
35
|
// CONSTANTS
|
|
35
36
|
// ============================================================================
|
|
@@ -43,10 +44,11 @@ var getDrawerDirection = function (isRTL) {
|
|
|
43
44
|
// COMPONENT
|
|
44
45
|
// ============================================================================
|
|
45
46
|
var BranchDrawer = function (_a) {
|
|
47
|
+
var isRTL = _a.isRTL;
|
|
48
|
+
var t = (0, next_intl_1.useTranslations)("branch");
|
|
46
49
|
// ============================================================================
|
|
47
50
|
// HOOKS & STATE
|
|
48
51
|
// ============================================================================
|
|
49
|
-
var isRTL = _a.isRTL, translationMap = _a.translationMap;
|
|
50
52
|
var _b = (0, context_1.useBranchStateContext)(), closeDrawer = _b.closeDrawer, disableSaveButton = _b.disableSaveButton, drawer = _b.drawer, handleSubmit = _b.handleSubmit;
|
|
51
53
|
// ============================================================================
|
|
52
54
|
// COMPUTED VALUES
|
|
@@ -59,17 +61,17 @@ var BranchDrawer = function (_a) {
|
|
|
59
61
|
return (react_1.default.createElement(drawer_1.Drawer, { open: isDrawerOpen, onOpenChange: function (open) { return !open && closeDrawer(); }, direction: drawerDirection },
|
|
60
62
|
react_1.default.createElement(drawer_1.DrawerContent, { className: "h-full ".concat(DRAWER_WIDTH, " ").concat(isRTL ? "rtl" : "ltr"), dir: isRTL ? "rtl" : "ltr" },
|
|
61
63
|
react_1.default.createElement(drawer_1.DrawerHeader, { className: "flex-row items-center justify-between border-b pb-4 ".concat(isRTL ? "flex-row-reverse" : "") },
|
|
62
|
-
react_1.default.createElement(drawer_1.DrawerTitle, { className: "text-xl font-semibold flex items-center ".concat(isRTL ? "flex-row-reverse gap-2" : "gap-2") }, (
|
|
64
|
+
react_1.default.createElement(drawer_1.DrawerTitle, { className: "text-xl font-semibold flex items-center ".concat(isRTL ? "flex-row-reverse gap-2" : "gap-2") }, t("drawerTitleBranch")),
|
|
63
65
|
react_1.default.createElement(drawer_1.DrawerClose, { asChild: true },
|
|
64
66
|
react_1.default.createElement(button_1.Button, { variant: "ghost", size: "icon", className: "h-8 w-8" },
|
|
65
67
|
react_1.default.createElement(lucide_react_1.X, { className: "h-4 w-4" }),
|
|
66
|
-
react_1.default.createElement("span", { className: "sr-only" }, (
|
|
68
|
+
react_1.default.createElement("span", { className: "sr-only" }, t("drawerButtonClose"))))),
|
|
67
69
|
react_1.default.createElement("div", { className: "flex-1 overflow-y-auto px-4 py-6 ".concat(isRTL ? "text-right" : "text-left") },
|
|
68
|
-
react_1.default.createElement(form_1.Form, { isRTL: isRTL
|
|
70
|
+
react_1.default.createElement(form_1.Form, { isRTL: isRTL })),
|
|
69
71
|
react_1.default.createElement(drawer_1.DrawerFooter, { className: "border-t pt-4" },
|
|
70
72
|
react_1.default.createElement("div", { className: "flex gap-2 ".concat(isRTL ? "flex-row-reverse" : "") },
|
|
71
|
-
react_1.default.createElement(button_1.Button, { variant: "outline", onClick: closeDrawer, className: "flex-1", type: "button" }, (
|
|
72
|
-
react_1.default.createElement(button_1.Button, { onClick: handleSubmit, disabled: disableSaveButton, className: "flex-1", type: "button" }, (
|
|
73
|
+
react_1.default.createElement(button_1.Button, { variant: "outline", onClick: closeDrawer, className: "flex-1", type: "button" }, t("drawerButtonCancel")),
|
|
74
|
+
react_1.default.createElement(button_1.Button, { onClick: handleSubmit, disabled: disableSaveButton, className: "flex-1", type: "button" }, t("drawerButtonSave")))))));
|
|
73
75
|
};
|
|
74
76
|
exports.BranchDrawer = BranchDrawer;
|
|
75
77
|
// ============================================================================
|
|
@@ -23,9 +23,8 @@ var input_1 = require("@appcorp/shadcn/components/input");
|
|
|
23
23
|
var switch_1 = require("@appcorp/shadcn/components/switch");
|
|
24
24
|
var context_1 = require("./context");
|
|
25
25
|
var Form = function (_a) {
|
|
26
|
-
var isRTL = _a.isRTL
|
|
27
|
-
var t = (0, next_intl_1.useTranslations)("
|
|
28
|
-
var ui = (0, next_intl_1.useTranslations)("ui");
|
|
26
|
+
var isRTL = _a.isRTL;
|
|
27
|
+
var t = (0, next_intl_1.useTranslations)("branch");
|
|
29
28
|
var _b = (0, context_1.useBranchStateContext)(), branchAddress = _b.branchAddress, branchName = _b.branchName, enabled = _b.enabled, errors = _b.errors, handleInputChange = _b.handleInputChange, isDefault = _b.isDefault, personEmail = _b.personEmail, personName = _b.personName, personPhone = _b.personPhone;
|
|
30
29
|
// Helper function to translate validation error keys
|
|
31
30
|
var getTranslatedError = function (key) {
|
|
@@ -41,22 +40,22 @@ var Form = function (_a) {
|
|
|
41
40
|
react_1.default.createElement("div", { className: "space-y-4" },
|
|
42
41
|
react_1.default.createElement("div", { className: "space-y-4" },
|
|
43
42
|
react_1.default.createElement("div", { className: "space-y-2" },
|
|
44
|
-
react_1.default.createElement(input_1.Input, { id: "branchName", type: "text", label: (
|
|
43
|
+
react_1.default.createElement(input_1.Input, { id: "branchName", type: "text", label: t("formLabelBranchName"), value: branchName || "", onChange: function (e) { return handleInputChange("branchName", e.target.value); }, placeholder: t("formPlaceholderBranchName"), info: t("formInfoBranchName"), error: getTranslatedError("branchName"), required: true })),
|
|
45
44
|
react_1.default.createElement("div", { className: "space-y-2" },
|
|
46
|
-
react_1.default.createElement(input_1.Input, { id: "branchAddress", type: "text", label: (
|
|
45
|
+
react_1.default.createElement(input_1.Input, { id: "branchAddress", type: "text", label: t("formLabelBranchAddress"), value: branchAddress || "", onChange: function (e) {
|
|
47
46
|
return handleInputChange("branchAddress", e.target.value);
|
|
48
|
-
}, placeholder: "
|
|
47
|
+
}, placeholder: t("formPlaceholderBranchAddress"), info: t("formInfoBranchAddress"), error: getTranslatedError("branchAddress"), required: true }))),
|
|
49
48
|
react_1.default.createElement("div", { className: "space-y-4" },
|
|
50
49
|
react_1.default.createElement("div", { className: "space-y-2" },
|
|
51
|
-
react_1.default.createElement(input_1.Input, { id: "personName", type: "text", label: (
|
|
50
|
+
react_1.default.createElement(input_1.Input, { id: "personName", type: "text", label: t("formLabelPersonName"), value: personName || "", onChange: function (e) { return handleInputChange("personName", e.target.value); }, placeholder: t("formPlaceholderPersonName"), info: t("formInfoPersonName"), error: getTranslatedError("personName"), required: true })),
|
|
52
51
|
react_1.default.createElement("div", { className: "space-y-2" },
|
|
53
|
-
react_1.default.createElement(input_1.Input, { id: "personEmail", type: "email", label: (
|
|
52
|
+
react_1.default.createElement(input_1.Input, { id: "personEmail", type: "email", label: t("formLabelPersonEmail"), value: personEmail || "", onChange: function (e) { return handleInputChange("personEmail", e.target.value); }, placeholder: t("formPlaceholderPersonEmail"), info: t("formInfoPersonEmail"), error: getTranslatedError("personEmail"), required: true })),
|
|
54
53
|
react_1.default.createElement("div", { className: "space-y-2" },
|
|
55
|
-
react_1.default.createElement(input_1.Input, { id: "personPhone", type: "tel", label: (
|
|
54
|
+
react_1.default.createElement(input_1.Input, { id: "personPhone", type: "tel", label: t("formLabelPersonPhone"), value: personPhone || "", onChange: function (e) { return handleInputChange("personPhone", e.target.value); }, placeholder: t("formPlaceholderPersonPhone"), info: t("formInfoPersonPhone"), error: getTranslatedError("personPhone"), required: true }))),
|
|
56
55
|
react_1.default.createElement("div", { className: "space-y-4" },
|
|
57
|
-
react_1.default.createElement(switch_1.Switch, { id: "enabled", label: (
|
|
58
|
-
react_1.default.createElement(switch_1.Switch, { id: "isDefault", label: (
|
|
56
|
+
react_1.default.createElement(switch_1.Switch, { id: "enabled", label: t("formLabelEnabled"), checked: enabled || false, onCheckedChange: function (checked) { return handleInputChange("enabled", checked); }, info: t("formInfoEnabled"), error: getTranslatedError("enabled") }),
|
|
57
|
+
react_1.default.createElement(switch_1.Switch, { id: "isDefault", label: t("formLabelIsDefault"), checked: isDefault || false, onCheckedChange: function (checked) {
|
|
59
58
|
return handleInputChange("isDefault", checked);
|
|
60
|
-
}, info:
|
|
59
|
+
}, info: t("formInfoIsDefault"), error: getTranslatedError("isDefault") })))));
|
|
61
60
|
};
|
|
62
61
|
exports.Form = Form;
|
|
@@ -25,6 +25,7 @@
|
|
|
25
25
|
import { Dispatch } from "react";
|
|
26
26
|
import { RowAction, HeaderAction } from "@appcorp/shadcn/components/enhanced-table";
|
|
27
27
|
import { BranchActions } from "./actions";
|
|
28
|
+
import { BankBE as BankTypeBE, BranchBE as BranchTypeBE, CurrencyBE as CurrencyTypeBE, MenuOrderBE as MenuOrderTypeBE, PaymentBE as PaymentTypeBE, PaymentModeBE as PaymentModeTypeBE, PreferenceBE as PreferenceTypeBE, TaxBE as TaxTypeBE } from "@react-pakistan/util-functions/api/stellar-solutions/type";
|
|
28
29
|
/**
|
|
29
30
|
* Branch Context Interface
|
|
30
31
|
*
|
|
@@ -52,46 +53,14 @@ export interface BranchContextType {
|
|
|
52
53
|
headerActions: HeaderAction[];
|
|
53
54
|
rowActions: RowAction[];
|
|
54
55
|
}
|
|
55
|
-
|
|
56
|
-
* Banking Detail Backend Entity
|
|
57
|
-
*
|
|
58
|
-
* Represents banking detail data structure with branch relationship.
|
|
59
|
-
*/
|
|
60
|
-
export interface BankingDetailTypeBE {
|
|
61
|
-
accountNumber: string;
|
|
62
|
-
accountTitle: string;
|
|
63
|
-
bankAddress?: string;
|
|
64
|
-
bankName: string;
|
|
65
|
-
createdAt: string;
|
|
66
|
-
enabled: boolean;
|
|
67
|
-
iban?: string;
|
|
68
|
-
id: string;
|
|
69
|
-
isDefault: boolean;
|
|
70
|
-
preference: PreferenceTypeBE;
|
|
71
|
-
preferenceId: string;
|
|
72
|
-
swiftCode?: string;
|
|
73
|
-
updatedAt: string;
|
|
74
|
-
}
|
|
56
|
+
export type { BankTypeBE };
|
|
75
57
|
/**
|
|
76
58
|
* Branch Backend Entity
|
|
77
59
|
*
|
|
78
60
|
* Represents the complete branch data structure as received from the API.
|
|
79
61
|
* Includes all branch-specific fields, contact person details, and relationships.
|
|
80
62
|
*/
|
|
81
|
-
export
|
|
82
|
-
branchAddress: string;
|
|
83
|
-
branchName: string;
|
|
84
|
-
createdAt: string;
|
|
85
|
-
enabled: boolean;
|
|
86
|
-
id: string;
|
|
87
|
-
isDefault: boolean;
|
|
88
|
-
personEmail: string;
|
|
89
|
-
personName: string;
|
|
90
|
-
personPhone: string;
|
|
91
|
-
preference: PreferenceTypeBE;
|
|
92
|
-
preferenceId: string;
|
|
93
|
-
updatedAt: string;
|
|
94
|
-
}
|
|
63
|
+
export type { BranchTypeBE };
|
|
95
64
|
/**
|
|
96
65
|
* Branch Component State
|
|
97
66
|
*
|
|
@@ -117,26 +86,8 @@ export interface BranchState {
|
|
|
117
86
|
personPhone: string;
|
|
118
87
|
preferenceId: string;
|
|
119
88
|
}
|
|
120
|
-
export
|
|
121
|
-
|
|
122
|
-
createdAt: string;
|
|
123
|
-
enabled: boolean;
|
|
124
|
-
id: string;
|
|
125
|
-
isDefault: boolean;
|
|
126
|
-
label: string;
|
|
127
|
-
preference?: PreferenceTypeBE;
|
|
128
|
-
preferenceId: string;
|
|
129
|
-
updatedAt: string;
|
|
130
|
-
}
|
|
131
|
-
export interface MenuOrderTypeBE {
|
|
132
|
-
createdAt: string;
|
|
133
|
-
id: string;
|
|
134
|
-
label: string;
|
|
135
|
-
order: number;
|
|
136
|
-
preference: PreferenceTypeBE;
|
|
137
|
-
preferenceId: string;
|
|
138
|
-
updatedAt: string;
|
|
139
|
-
}
|
|
89
|
+
export type { CurrencyTypeBE };
|
|
90
|
+
export type { MenuOrderTypeBE };
|
|
140
91
|
/**
|
|
141
92
|
* Fetch Branches API Arguments
|
|
142
93
|
*
|
|
@@ -193,58 +144,10 @@ export declare enum PAYMENT_TYPE {
|
|
|
193
144
|
FULL_PAYMENT = "FULL_PAYMENT",
|
|
194
145
|
PARTIAL_PAYMENT = "PARTIAL_PAYMENT"
|
|
195
146
|
}
|
|
196
|
-
export
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
createdAt: string;
|
|
201
|
-
currency: string;
|
|
202
|
-
date: string;
|
|
203
|
-
description?: string;
|
|
204
|
-
id: string;
|
|
205
|
-
paymentMode?: PaymentModeTypeBE;
|
|
206
|
-
paymentModeId: string;
|
|
207
|
-
paymentType: PAYMENT_TYPE;
|
|
208
|
-
quoteInvoice?: undefined;
|
|
209
|
-
quoteInvoiceId: string;
|
|
210
|
-
ref: string;
|
|
211
|
-
updatedAt: string;
|
|
212
|
-
}
|
|
213
|
-
export interface PaymentModeTypeBE {
|
|
214
|
-
createdAt: string;
|
|
215
|
-
enabled: boolean;
|
|
216
|
-
id: string;
|
|
217
|
-
isDefault: boolean;
|
|
218
|
-
label: string;
|
|
219
|
-
payments?: PaymentTypeBE[];
|
|
220
|
-
preference?: PreferenceTypeBE;
|
|
221
|
-
preferenceId: string;
|
|
222
|
-
updatedAt: string;
|
|
223
|
-
}
|
|
224
|
-
export interface TaxTypeBE {
|
|
225
|
-
createdAt: string;
|
|
226
|
-
description?: string;
|
|
227
|
-
enabled: boolean;
|
|
228
|
-
id: string;
|
|
229
|
-
isDefault: boolean;
|
|
230
|
-
preference: PreferenceTypeBE;
|
|
231
|
-
preferenceId: string;
|
|
232
|
-
taxName: string;
|
|
233
|
-
taxRate: string;
|
|
234
|
-
updatedAt: string;
|
|
235
|
-
}
|
|
236
|
-
export interface PreferenceTypeBE {
|
|
237
|
-
bankingDetails: BankingDetailTypeBE[];
|
|
238
|
-
branches: BranchTypeBE[];
|
|
239
|
-
createdAt: string;
|
|
240
|
-
currencies: CurrencyTypeBE[];
|
|
241
|
-
id: string;
|
|
242
|
-
menuOrder: MenuOrderTypeBE[];
|
|
243
|
-
onboarding: boolean;
|
|
244
|
-
paymentModes: PaymentModeTypeBE[];
|
|
245
|
-
taxes: TaxTypeBE[];
|
|
246
|
-
updatedAt: string;
|
|
247
|
-
}
|
|
147
|
+
export type { PaymentTypeBE };
|
|
148
|
+
export type { PaymentModeTypeBE };
|
|
149
|
+
export type { TaxTypeBE };
|
|
150
|
+
export type { PreferenceTypeBE };
|
|
248
151
|
export interface CreateBankDetailArg {
|
|
249
152
|
id: string;
|
|
250
153
|
accountNumber: string;
|
|
@@ -4,12 +4,12 @@ exports.formValidation = void 0;
|
|
|
4
4
|
var zod_1 = require("zod");
|
|
5
5
|
// Validation error keys for i18n translation
|
|
6
6
|
var VALIDATION_KEYS = {
|
|
7
|
-
branchNameRequired: "
|
|
8
|
-
branchAddressRequired: "
|
|
9
|
-
personNameRequired: "
|
|
10
|
-
personEmailRequired: "
|
|
11
|
-
personPhoneRequired: "
|
|
12
|
-
preferenceIdRequired: "
|
|
7
|
+
branchNameRequired: "validationBranchNameRequired",
|
|
8
|
+
branchAddressRequired: "validationBranchAddressRequired",
|
|
9
|
+
personNameRequired: "validationPersonNameRequired",
|
|
10
|
+
personEmailRequired: "validationPersonEmailRequired",
|
|
11
|
+
personPhoneRequired: "validationPersonPhoneRequired",
|
|
12
|
+
preferenceIdRequired: "validationPreferenceIdRequired",
|
|
13
13
|
};
|
|
14
14
|
exports.formValidation = zod_1.z.object({
|
|
15
15
|
branchAddress: zod_1.z.string().nonempty(VALIDATION_KEYS.branchAddressRequired),
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Currency Actions
|
|
3
|
+
*
|
|
4
|
+
* This module defines all action types and interfaces for the Currency 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, buttons)
|
|
12
|
+
* - List Management Actions (currencies, pagination)
|
|
13
|
+
* - Search Actions (queries)
|
|
14
|
+
* - Union Type Export
|
|
15
|
+
* - Action Creators (helper functions)
|
|
16
|
+
* - Type Utilities (guards and helpers)
|
|
17
|
+
*
|
|
18
|
+
* Naming Convention: Currency{Operation}{Target}Action
|
|
19
|
+
* Examples: CurrencySetInputFieldAction, CurrencyResetFormAction
|
|
20
|
+
*/
|
|
21
|
+
import { CURRENCY_DRAWER, CurrencyForm, CurrencyTypeBE } from "./types";
|
|
22
|
+
export declare enum CURRENCY_ACTION_TYPES {
|
|
23
|
+
RESET_ERRORS = "RESET_ERRORS",
|
|
24
|
+
RESET_FORM = "RESET_FORM",
|
|
25
|
+
SET_INPUT_FIELD = "SET_INPUT_FIELD",
|
|
26
|
+
SET_FORM = "SET_FORM",
|
|
27
|
+
SET_ERRORS = "SET_ERRORS",
|
|
28
|
+
SET_DISABLE_SAVE_BUTTON = "SET_DISABLE_SAVE_BUTTON",
|
|
29
|
+
SET_DRAWER = "SET_DRAWER",
|
|
30
|
+
SET_CURRENCIES = "SET_CURRENCIES",
|
|
31
|
+
SET_COUNT = "SET_COUNT",
|
|
32
|
+
SET_CURRENT_PAGE = "SET_CURRENT_PAGE",
|
|
33
|
+
SET_PAGE_LIMIT = "SET_PAGE_LIMIT",
|
|
34
|
+
SET_SEARCH_QUERY = "SET_SEARCH_QUERY"
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Reset form validation errors
|
|
38
|
+
*/
|
|
39
|
+
export type CurrencyResetErrorsAction = {
|
|
40
|
+
type: CURRENCY_ACTION_TYPES.RESET_ERRORS;
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* Reset entire form to initial state
|
|
44
|
+
*/
|
|
45
|
+
export type CurrencyResetFormAction = {
|
|
46
|
+
type: CURRENCY_ACTION_TYPES.RESET_FORM;
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* Update individual form field dynamically
|
|
50
|
+
*/
|
|
51
|
+
export type CurrencySetInputFieldAction = {
|
|
52
|
+
type: CURRENCY_ACTION_TYPES.SET_INPUT_FIELD;
|
|
53
|
+
payload: {
|
|
54
|
+
key: keyof CurrencyForm;
|
|
55
|
+
value: string | string[] | boolean | number | number[];
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
/**
|
|
59
|
+
* Set entire form data (used when editing existing currency)
|
|
60
|
+
*/
|
|
61
|
+
export type CurrencySetFormAction = {
|
|
62
|
+
type: CURRENCY_ACTION_TYPES.SET_FORM;
|
|
63
|
+
payload: {
|
|
64
|
+
form: CurrencyTypeBE;
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
/**
|
|
68
|
+
* Set form validation errors
|
|
69
|
+
*/
|
|
70
|
+
export type CurrencySetErrorsAction = {
|
|
71
|
+
type: CURRENCY_ACTION_TYPES.SET_ERRORS;
|
|
72
|
+
payload: {
|
|
73
|
+
errors: Record<string, string>;
|
|
74
|
+
};
|
|
75
|
+
};
|
|
76
|
+
/**
|
|
77
|
+
* Control save button state (enabled/disabled)
|
|
78
|
+
*/
|
|
79
|
+
export type CurrencySetDisableSaveButtonAction = {
|
|
80
|
+
type: CURRENCY_ACTION_TYPES.SET_DISABLE_SAVE_BUTTON;
|
|
81
|
+
payload: {
|
|
82
|
+
disableSaveButton: boolean;
|
|
83
|
+
};
|
|
84
|
+
};
|
|
85
|
+
/**
|
|
86
|
+
* Manage drawer state (open/closed with specific drawer type)
|
|
87
|
+
*/
|
|
88
|
+
export type CurrencySetDrawerAction = {
|
|
89
|
+
type: CURRENCY_ACTION_TYPES.SET_DRAWER;
|
|
90
|
+
payload: {
|
|
91
|
+
drawer: null | CURRENCY_DRAWER;
|
|
92
|
+
};
|
|
93
|
+
};
|
|
94
|
+
/**
|
|
95
|
+
* Set currencies list data
|
|
96
|
+
*/
|
|
97
|
+
export type CurrencySetCurrenciesAction = {
|
|
98
|
+
type: CURRENCY_ACTION_TYPES.SET_CURRENCIES;
|
|
99
|
+
payload: {
|
|
100
|
+
currencies: CurrencyTypeBE[];
|
|
101
|
+
};
|
|
102
|
+
};
|
|
103
|
+
/**
|
|
104
|
+
* Set total count of currencies (for pagination)
|
|
105
|
+
*/
|
|
106
|
+
export type CurrencySetCountAction = {
|
|
107
|
+
type: CURRENCY_ACTION_TYPES.SET_COUNT;
|
|
108
|
+
payload: {
|
|
109
|
+
count: number;
|
|
110
|
+
};
|
|
111
|
+
};
|
|
112
|
+
/**
|
|
113
|
+
* Update current page number
|
|
114
|
+
*/
|
|
115
|
+
export type CurrencySetCurrentPageAction = {
|
|
116
|
+
type: CURRENCY_ACTION_TYPES.SET_CURRENT_PAGE;
|
|
117
|
+
payload: {
|
|
118
|
+
currentPage: number;
|
|
119
|
+
};
|
|
120
|
+
};
|
|
121
|
+
/**
|
|
122
|
+
* Update page limit (items per page)
|
|
123
|
+
*/
|
|
124
|
+
export type CurrencySetPageLimitAction = {
|
|
125
|
+
type: CURRENCY_ACTION_TYPES.SET_PAGE_LIMIT;
|
|
126
|
+
payload: {
|
|
127
|
+
pageLimit: number;
|
|
128
|
+
};
|
|
129
|
+
};
|
|
130
|
+
/**
|
|
131
|
+
* Update search query for filtering currencies
|
|
132
|
+
*/
|
|
133
|
+
export type CurrencySetSearchQueryAction = {
|
|
134
|
+
type: CURRENCY_ACTION_TYPES.SET_SEARCH_QUERY;
|
|
135
|
+
payload: {
|
|
136
|
+
searchQuery: string;
|
|
137
|
+
};
|
|
138
|
+
};
|
|
139
|
+
/**
|
|
140
|
+
* Currency Actions Union Type
|
|
141
|
+
*
|
|
142
|
+
* Combines all possible currency actions into a single discriminated union.
|
|
143
|
+
* Used by the reducer to maintain type safety across all action handlers.
|
|
144
|
+
*/
|
|
145
|
+
export type CurrencyActions = CurrencyResetErrorsAction | CurrencyResetFormAction | CurrencySetInputFieldAction | CurrencySetFormAction | CurrencySetErrorsAction | CurrencySetDisableSaveButtonAction | CurrencySetDrawerAction | CurrencySetCurrenciesAction | CurrencySetCountAction | CurrencySetCurrentPageAction | CurrencySetPageLimitAction | CurrencySetSearchQueryAction;
|
|
146
|
+
/**
|
|
147
|
+
* Create a reset errors action
|
|
148
|
+
*/
|
|
149
|
+
export declare const createResetErrorsAction: () => CurrencyResetErrorsAction;
|
|
150
|
+
/**
|
|
151
|
+
* Create a reset form action
|
|
152
|
+
*/
|
|
153
|
+
export declare const createResetFormAction: () => CurrencyResetFormAction;
|
|
154
|
+
/**
|
|
155
|
+
* Create a set input field action
|
|
156
|
+
*/
|
|
157
|
+
export declare const createSetInputFieldAction: (key: keyof CurrencyForm, value: string | string[] | boolean | number | number[]) => CurrencySetInputFieldAction;
|
|
158
|
+
/**
|
|
159
|
+
* Create a set form action
|
|
160
|
+
*/
|
|
161
|
+
export declare const createSetFormAction: (form: CurrencyTypeBE) => CurrencySetFormAction;
|
|
162
|
+
/**
|
|
163
|
+
* Create a set errors action
|
|
164
|
+
*/
|
|
165
|
+
export declare const createSetErrorsAction: (errors: Record<string, string>) => CurrencySetErrorsAction;
|
|
166
|
+
/**
|
|
167
|
+
* Create a set disable save button action
|
|
168
|
+
*/
|
|
169
|
+
export declare const createSetDisableSaveButtonAction: (disableSaveButton: boolean) => CurrencySetDisableSaveButtonAction;
|
|
170
|
+
/**
|
|
171
|
+
* Create a set drawer action
|
|
172
|
+
*/
|
|
173
|
+
export declare const createSetDrawerAction: (drawer: null | CURRENCY_DRAWER) => CurrencySetDrawerAction;
|
|
174
|
+
/**
|
|
175
|
+
* Create a set currencies action
|
|
176
|
+
*/
|
|
177
|
+
export declare const createSetCurrenciesAction: (currencies: CurrencyTypeBE[]) => CurrencySetCurrenciesAction;
|
|
178
|
+
/**
|
|
179
|
+
* Create a set count action
|
|
180
|
+
*/
|
|
181
|
+
export declare const createSetCountAction: (count: number) => CurrencySetCountAction;
|
|
182
|
+
/**
|
|
183
|
+
* Create a set current page action
|
|
184
|
+
*/
|
|
185
|
+
export declare const createSetCurrentPageAction: (currentPage: number) => CurrencySetCurrentPageAction;
|
|
186
|
+
/**
|
|
187
|
+
* Create a set page limit action
|
|
188
|
+
*/
|
|
189
|
+
export declare const createSetPageLimitAction: (pageLimit: number) => CurrencySetPageLimitAction;
|
|
190
|
+
/**
|
|
191
|
+
* Create a set search query action
|
|
192
|
+
*/
|
|
193
|
+
export declare const createSetSearchQueryAction: (searchQuery: string) => CurrencySetSearchQueryAction;
|
|
194
|
+
/**
|
|
195
|
+
* Type guard to check if an action is a Currency action
|
|
196
|
+
*/
|
|
197
|
+
export declare const isCurrencyAction: (action: unknown) => action is CurrencyActions;
|
|
198
|
+
/**
|
|
199
|
+
* Helper to extract action payload type
|
|
200
|
+
*/
|
|
201
|
+
export type CurrencyActionPayload<T extends CurrencyActions> = T extends {
|
|
202
|
+
payload: infer P;
|
|
203
|
+
} ? P : never;
|