@appcorp/stellar-solutions-modules 0.1.34 → 0.1.36

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.
Files changed (181) hide show
  1. package/README.md +128 -19
  2. package/components/theme-provider.d.ts +9 -0
  3. package/components/theme-provider.js +122 -0
  4. package/components/theme-switcher.d.ts +4 -0
  5. package/components/theme-switcher.js +60 -0
  6. package/components/ui/badge.d.ts +9 -0
  7. package/components/ui/badge.js +82 -0
  8. package/components/ui/button.d.ts +10 -0
  9. package/components/ui/button.js +91 -0
  10. package/components/ui/card.d.ts +9 -0
  11. package/components/ui/card.js +94 -0
  12. package/components/ui/checkbox.d.ts +9 -0
  13. package/components/ui/checkbox.js +87 -0
  14. package/components/ui/combobox.d.ts +70 -0
  15. package/components/ui/combobox.js +315 -0
  16. package/components/ui/command.d.ts +18 -0
  17. package/components/ui/command.js +115 -0
  18. package/components/ui/dialog.d.ts +15 -0
  19. package/components/ui/dialog.js +118 -0
  20. package/components/ui/drawer.d.ts +13 -0
  21. package/components/ui/drawer.js +115 -0
  22. package/components/ui/dropdown-menu.d.ts +25 -0
  23. package/components/ui/dropdown-menu.js +148 -0
  24. package/components/ui/enhanced-table-footer-action.d.ts +34 -0
  25. package/components/ui/enhanced-table-footer-action.js +117 -0
  26. package/components/ui/enhanced-table-footer-page.d.ts +32 -0
  27. package/components/ui/enhanced-table-footer-page.js +140 -0
  28. package/components/ui/enhanced-table-footer-pagination.d.ts +36 -0
  29. package/components/ui/enhanced-table-footer-pagination.js +122 -0
  30. package/components/ui/enhanced-table-header-action.d.ts +7 -0
  31. package/components/ui/enhanced-table-header-action.js +21 -0
  32. package/components/ui/enhanced-table-header-search.d.ts +12 -0
  33. package/components/ui/enhanced-table-header-search.js +17 -0
  34. package/components/ui/enhanced-table.d.ts +65 -0
  35. package/components/ui/enhanced-table.js +87 -0
  36. package/components/ui/form.d.ts +24 -0
  37. package/components/ui/form.js +125 -0
  38. package/components/ui/input.d.ts +8 -0
  39. package/components/ui/input.js +86 -0
  40. package/components/ui/label.d.ts +7 -0
  41. package/components/ui/label.js +68 -0
  42. package/components/ui/popover.d.ts +7 -0
  43. package/components/ui/popover.js +82 -0
  44. package/components/ui/select.d.ts +15 -0
  45. package/components/ui/select.js +127 -0
  46. package/components/ui/separator.d.ts +4 -0
  47. package/components/ui/separator.js +66 -0
  48. package/components/ui/sonner.d.ts +4 -0
  49. package/components/ui/sonner.js +54 -0
  50. package/components/ui/switch.d.ts +9 -0
  51. package/components/ui/switch.js +89 -0
  52. package/components/ui/table.d.ts +10 -0
  53. package/components/ui/table.js +101 -0
  54. package/components/ui/textarea.d.ts +8 -0
  55. package/components/ui/textarea.js +86 -0
  56. package/global-modules/bank/actions.d.ts +200 -0
  57. package/global-modules/bank/actions.js +124 -0
  58. package/global-modules/bank/bank.d.ts +2 -0
  59. package/global-modules/bank/bank.js +87 -0
  60. package/global-modules/bank/constants.d.ts +45 -0
  61. package/global-modules/bank/constants.js +98 -0
  62. package/global-modules/bank/context.d.ts +41 -0
  63. package/global-modules/bank/context.js +419 -0
  64. package/global-modules/bank/drawer.d.ts +31 -0
  65. package/global-modules/bank/drawer.js +114 -0
  66. package/global-modules/bank/form.d.ts +22 -0
  67. package/global-modules/bank/form.js +68 -0
  68. package/global-modules/bank/reducer.d.ts +25 -0
  69. package/global-modules/bank/reducer.js +161 -0
  70. package/global-modules/bank/types.d.ts +217 -0
  71. package/global-modules/bank/types.js +81 -0
  72. package/global-modules/bank/validate.d.ts +13 -0
  73. package/global-modules/bank/validate.js +22 -0
  74. package/global-modules/branch/actions.d.ts +154 -37
  75. package/global-modules/branch/actions.js +148 -6
  76. package/global-modules/branch/branch.d.ts +2 -2
  77. package/global-modules/branch/branch.js +46 -32
  78. package/global-modules/branch/constants.d.ts +34 -24
  79. package/global-modules/branch/constants.js +101 -122
  80. package/global-modules/branch/context.d.ts +33 -2
  81. package/global-modules/branch/context.js +195 -164
  82. package/global-modules/branch/drawer.d.ts +26 -3
  83. package/global-modules/branch/drawer.js +101 -6
  84. package/global-modules/branch/form.d.ts +15 -1
  85. package/global-modules/branch/form.js +54 -71
  86. package/global-modules/branch/reducer.d.ts +23 -2
  87. package/global-modules/branch/reducer.js +148 -118
  88. package/global-modules/branch/types.d.ts +196 -69
  89. package/global-modules/branch/types.js +66 -7
  90. package/global-modules/branch/validate.d.ts +1 -1
  91. package/global-modules/branch/validate.js +15 -11
  92. package/global-modules/payment-mode/actions.d.ts +154 -37
  93. package/global-modules/payment-mode/actions.js +148 -6
  94. package/global-modules/payment-mode/constants.d.ts +34 -17
  95. package/global-modules/payment-mode/constants.js +90 -66
  96. package/global-modules/payment-mode/context.d.ts +33 -2
  97. package/global-modules/payment-mode/context.js +185 -163
  98. package/global-modules/payment-mode/drawer.d.ts +26 -3
  99. package/global-modules/payment-mode/drawer.js +104 -9
  100. package/global-modules/payment-mode/form.d.ts +16 -2
  101. package/global-modules/payment-mode/form.js +45 -74
  102. package/global-modules/payment-mode/payment-mode.d.ts +25 -2
  103. package/global-modules/payment-mode/payment-mode.js +90 -23
  104. package/global-modules/payment-mode/reducer.d.ts +23 -2
  105. package/global-modules/payment-mode/reducer.js +140 -114
  106. package/global-modules/payment-mode/types.d.ts +327 -112
  107. package/global-modules/payment-mode/types.js +162 -11
  108. package/global-modules/payment-mode/validate.d.ts +1 -1
  109. package/global-modules/payment-mode/validate.js +7 -5
  110. package/global-modules/preferences/actions.d.ts +126 -27
  111. package/global-modules/preferences/actions.js +128 -4
  112. package/global-modules/preferences/constants.d.ts +46 -31
  113. package/global-modules/preferences/constants.js +129 -66
  114. package/global-modules/preferences/context.d.ts +2 -2
  115. package/global-modules/preferences/context.js +43 -43
  116. package/global-modules/preferences/currency.js +15 -10
  117. package/global-modules/preferences/preferences.d.ts +2 -2
  118. package/global-modules/preferences/preferences.js +3 -5
  119. package/global-modules/preferences/validate.d.ts +1 -1
  120. package/global-modules/preferences/validate.js +7 -7
  121. package/global-modules/tax/actions.d.ts +155 -38
  122. package/global-modules/tax/actions.js +149 -7
  123. package/global-modules/tax/constants.d.ts +31 -39
  124. package/global-modules/tax/constants.js +83 -114
  125. package/global-modules/tax/context.d.ts +33 -2
  126. package/global-modules/tax/context.js +146 -132
  127. package/global-modules/tax/drawer.d.ts +26 -3
  128. package/global-modules/tax/drawer.js +101 -6
  129. package/global-modules/tax/form.d.ts +20 -3
  130. package/global-modules/tax/form.js +101 -74
  131. package/global-modules/tax/reducer.d.ts +23 -2
  132. package/global-modules/tax/reducer.js +143 -24
  133. package/global-modules/tax/tax.d.ts +25 -2
  134. package/global-modules/tax/tax.js +92 -28
  135. package/global-modules/tax/types.d.ts +332 -102
  136. package/global-modules/tax/types.js +179 -11
  137. package/global-modules/tax/validate.d.ts +1 -1
  138. package/global-modules/tax/validate.js +9 -8
  139. package/hooks/use-rtl.d.ts +44 -0
  140. package/hooks/use-rtl.js +75 -0
  141. package/i18n/navigation.d.ts +340 -0
  142. package/i18n/navigation.js +9 -0
  143. package/i18n/request.d.ts +2 -0
  144. package/i18n/request.js +95 -0
  145. package/i18n/routing.d.ts +18 -0
  146. package/i18n/routing.js +9 -0
  147. package/index.d.ts +26 -0
  148. package/index.js +42 -0
  149. package/lib/themes.d.ts +147 -0
  150. package/lib/themes.js +150 -0
  151. package/lib/toast-utils.d.ts +44 -0
  152. package/lib/toast-utils.js +212 -0
  153. package/lib/utils.d.ts +2 -0
  154. package/lib/utils.js +12 -0
  155. package/package.json +21 -3
  156. package/supabase/supabase.d.ts +80 -1
  157. package/supabase/supabase.js +281 -6
  158. package/global-modules/branch/form-elements.d.ts +0 -3
  159. package/global-modules/branch/form-elements.js +0 -41
  160. package/global-modules/payment-mode/form-elements.d.ts +0 -3
  161. package/global-modules/payment-mode/form-elements.js +0 -41
  162. package/global-modules/preferences/bank.d.ts +0 -2
  163. package/global-modules/preferences/bank.js +0 -11
  164. package/global-modules/preferences/branch-drawer.js +0 -36
  165. package/global-modules/preferences/branch-form-elements.js +0 -30
  166. package/global-modules/preferences/branch-form.d.ts +0 -0
  167. package/global-modules/preferences/branch-form.js +0 -33
  168. package/global-modules/preferences/branch.d.ts +0 -0
  169. package/global-modules/preferences/branch.js +0 -106
  170. package/global-modules/preferences/payment-mode-drawer.d.ts +0 -0
  171. package/global-modules/preferences/payment-mode-drawer.js +0 -36
  172. package/global-modules/preferences/payment-mode-form-elements.d.ts +0 -0
  173. package/global-modules/preferences/payment-mode-form-elements.js +0 -30
  174. package/global-modules/preferences/payment-mode-form.d.ts +0 -0
  175. package/global-modules/preferences/payment-mode-form.js +0 -33
  176. package/global-modules/preferences/payment-mode.d.ts +0 -0
  177. package/global-modules/preferences/payment-mode.js +0 -94
  178. package/global-modules/tax/form-elements.d.ts +0 -3
  179. package/global-modules/tax/form-elements.js +0 -41
  180. /package/{global-modules/preferences/branch-drawer.d.ts → constants.d.ts} +0 -0
  181. /package/{global-modules/preferences/branch-form-elements.d.ts → constants.js} +0 -0
@@ -1,99 +1,162 @@
1
1
  "use strict";
2
+ /**
3
+ * Preferences Constants
4
+ *
5
+ * This module defines all constants used throughout the Preferences module.
6
+ * Constants are organized by functionality and follow consistent naming patterns.
7
+ *
8
+ * Organization:
9
+ * - Page Configuration (pagination, limits)
10
+ * - API Routes (backend endpoints)
11
+ * - Dashboard Configuration (tabs, menu items)
12
+ * - Component Mapping (dashboard tabs map)
13
+ *
14
+ * Naming Convention: Descriptive names with clear purpose
15
+ */
2
16
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
17
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
18
  };
5
19
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.taxValidationError = exports.dashboardTabsMap = exports.toastErrors = exports.PREFERENCE_API_ROUTES = exports.initialMenuItems = exports.pageLimit = void 0;
20
+ exports.dashboardTabsMap = exports.initialMenuItems = exports.PREFERENCE_API_ROUTES = exports.pageLimit = void 0;
7
21
  var react_1 = __importDefault(require("react"));
8
22
  var currency_1 = require("./currency");
9
23
  var payment_mode_1 = require("../payment-mode/payment-mode");
10
24
  var branch_1 = require("../branch/branch");
11
25
  var tax_1 = require("../tax/tax");
12
- var bank_1 = require("./bank");
26
+ var bank_1 = require("../bank/bank");
27
+ // ============================================================================
28
+ // PAGE CONFIGURATION
29
+ // ============================================================================
30
+ /**
31
+ * Default page limit for pagination
32
+ */
13
33
  exports.pageLimit = Number(process.env.NEXT_PUBLIC_PAGE_LIMIT);
34
+ // ============================================================================
35
+ // API ROUTES
36
+ // ============================================================================
37
+ /**
38
+ * API endpoints for preferences and related module operations
39
+ */
40
+ exports.PREFERENCE_API_ROUTES = {
41
+ BRANCH: "/api/branch",
42
+ BRANCHES: "/api/branches",
43
+ BRANCH_BY_ID: "/api/branch/branch-by-id",
44
+ CURRENCIES: "/api/currencies",
45
+ CURRENCY: "/api/currency",
46
+ CURRENCY_BY_ID: "/api/currency/currency-by-id",
47
+ PAYMENT_MODE: "/api/payment-mode",
48
+ PAYMENT_MODES: "/api/payment-modes",
49
+ PAYMENT_MODE_BY_ID: "/api/payment-mode/payment-mode-by-id",
50
+ PREFERENCE: "/api/preference",
51
+ PREFERENCES: "/api/preferences",
52
+ PREFERENCE_BY_ID: "/api/preference/preference-by-id",
53
+ TAX: "/api/tax",
54
+ TAXES: "/api/taxes",
55
+ TAX_BY_ID: "/api/tax/tax-by-id",
56
+ };
57
+ // ============================================================================
58
+ // DASHBOARD CONFIGURATION
59
+ // ============================================================================
60
+ /**
61
+ * Initial menu items for dashboard navigation
62
+ * These represent the default menu structure for the application
63
+ */
14
64
  exports.initialMenuItems = [
15
- { id: 'item-1', label: 'Dashboard', order: 1, preferenceId: 'preference-1' },
16
- { id: 'item-2', label: 'Product', order: 3, preferenceId: 'preference-1' },
17
- { id: 'item-3', label: 'Company', order: 4, preferenceId: 'preference-1' },
65
+ { id: "item-1", label: "Dashboard", order: 1, preferenceId: "preference-1" },
66
+ { id: "item-2", label: "Product", order: 3, preferenceId: "preference-1" },
67
+ { id: "item-3", label: "Company", order: 4, preferenceId: "preference-1" },
18
68
  {
19
- id: 'item-4',
20
- label: 'Product Category',
69
+ id: "item-4",
70
+ label: "Product Category",
21
71
  order: 2,
22
- preferenceId: 'preference-1',
72
+ preferenceId: "preference-1",
23
73
  },
24
- { id: 'item-5', label: 'Contact', order: 5, preferenceId: 'preference-1' },
25
- { id: 'item-6', label: 'Lead', order: 6, preferenceId: 'preference-1' },
26
- { id: 'item-7', label: 'Expense', order: 8, preferenceId: 'preference-1' },
74
+ { id: "item-5", label: "Contact", order: 5, preferenceId: "preference-1" },
75
+ { id: "item-6", label: "Lead", order: 6, preferenceId: "preference-1" },
76
+ { id: "item-7", label: "Expense", order: 8, preferenceId: "preference-1" },
27
77
  {
28
- id: 'item-8',
29
- label: 'Expense Category',
78
+ id: "item-8",
79
+ label: "Expense Category",
30
80
  order: 7,
31
- preferenceId: 'preference-1',
81
+ preferenceId: "preference-1",
32
82
  },
33
- { id: 'item-9', label: 'Quote', order: 9, preferenceId: 'preference-1' },
34
- { id: 'item-10', label: 'Invoice', order: 10, preferenceId: 'preference-1' },
35
- { id: 'item-11', label: 'Payment', order: 11, preferenceId: 'preference-1' },
83
+ { id: "item-9", label: "Quote", order: 9, preferenceId: "preference-1" },
84
+ { id: "item-10", label: "Invoice", order: 10, preferenceId: "preference-1" },
85
+ { id: "item-11", label: "Payment", order: 11, preferenceId: "preference-1" },
36
86
  {
37
- id: 'item-12',
38
- label: 'Customers',
87
+ id: "item-12",
88
+ label: "Customers",
39
89
  order: 12,
40
- preferenceId: 'preference-1',
90
+ preferenceId: "preference-1",
41
91
  },
42
92
  {
43
- id: 'item-13',
44
- label: 'Inventory',
93
+ id: "item-13",
94
+ label: "Inventory",
45
95
  order: 13,
46
- preferenceId: 'preference-1',
96
+ preferenceId: "preference-1",
47
97
  },
48
- { id: 'item-14', label: 'Template', order: 14, preferenceId: 'preference-1' },
98
+ { id: "item-14", label: "Template", order: 14, preferenceId: "preference-1" },
49
99
  {
50
- id: 'item-15',
51
- label: 'Business Contact',
100
+ id: "item-15",
101
+ label: "Business Contact",
52
102
  order: 15,
53
- preferenceId: 'preference-1',
103
+ preferenceId: "preference-1",
54
104
  },
55
105
  {
56
- id: 'item-16',
57
- label: 'Reports',
106
+ id: "item-16",
107
+ label: "Reports",
58
108
  order: 16,
59
- preferenceId: 'preference-1',
109
+ preferenceId: "preference-1",
60
110
  },
61
- { id: 'item-17', label: 'Log out', order: 17, preferenceId: 'preference-1' },
111
+ { id: "item-17", label: "Log out", order: 17, preferenceId: "preference-1" },
62
112
  ];
63
- exports.PREFERENCE_API_ROUTES = {
64
- BRANCH: '/api/branch',
65
- BRANCHES: '/api/branches',
66
- BRANCH_BY_ID: '/api/branch/branch-by-id',
67
- CURRENCIES: '/api/currencies',
68
- CURRENCY: '/api/currency',
69
- CURRENCY_BY_ID: '/api/currency/currency-by-id',
70
- PAYMENT_MODE: '/api/payment-mode',
71
- PAYMENT_MODES: '/api/payment-modes',
72
- PAYMENT_MODE_BY_ID: '/api/payment-mode/payment-mode-by-id',
73
- PREFERENCE: '/api/preference',
74
- PREFERENCES: '/api/preferences',
75
- PREFERENCE_BY_ID: '/api/preference/preference-by-id',
76
- TAX: '/api/tax',
77
- TAXES: '/api/taxes',
78
- TAX_BY_ID: '/api/tax/tax-by-id',
79
- };
80
- exports.toastErrors = {
81
- fetchInvoiceError: 'Error Fetching Invoice',
82
- formSubmittedSuccess: 'Form Submitted Successfully',
83
- genericError: 'Something Went Wrong',
84
- networkError: 'Network Error Occurred',
85
- submitFormError: 'Error Submitting Form',
86
- validationError: 'Validation Failed',
87
- };
113
+ // ============================================================================
114
+ // COMPONENT MAPPING
115
+ // ============================================================================
116
+ /**
117
+ * Mapping of dashboard tab names to their corresponding React components
118
+ * Used for dynamic rendering of preference management sections
119
+ */
88
120
  exports.dashboardTabsMap = {
89
- 'Currency': react_1.default.createElement(currency_1.Currency, null),
90
- 'Payment Mode': react_1.default.createElement(payment_mode_1.PaymentMode, null),
91
- 'Branch': react_1.default.createElement(branch_1.Branch, null),
92
- 'Tax': react_1.default.createElement(tax_1.Tax, null),
93
- 'Bank': react_1.default.createElement(bank_1.Bank, null),
94
- };
95
- exports.taxValidationError = {
96
- taxName: 'Tax name is required',
97
- taxRate: 'Operation successful!',
98
- description: '',
121
+ Currency: react_1.default.createElement(currency_1.Currency, null),
122
+ "Payment Mode": react_1.default.createElement(payment_mode_1.PaymentMode, null),
123
+ Branch: react_1.default.createElement(branch_1.Branch, null),
124
+ Tax: react_1.default.createElement(tax_1.Tax, null),
125
+ Bank: react_1.default.createElement(bank_1.Bank, null),
99
126
  };
127
+ // ============================================================================
128
+ // OPTIMIZATION SUMMARY
129
+ // ============================================================================
130
+ /*
131
+ * Constants File Optimizations Applied:
132
+ *
133
+ * 1. **Structural Organization**
134
+ * - Grouped constants by functionality with clear section headers
135
+ * - Added comprehensive JSDoc documentation for each section
136
+ * - Organized imports alphabetically and logically
137
+ *
138
+ * 2. **Internationalization**
139
+ * - Moved toast error messages to messages/en.json and messages/ur.json for i18n support
140
+ * - Moved tax validation error messages to existing taxPage.validation section
141
+ * - Kept only technical constants in this file
142
+ *
143
+ * 3. **Type Safety Improvements**
144
+ * - Added 'as const' assertion to API routes for better type inference
145
+ * - Used descriptive naming conventions
146
+ * - Maintained type safety for all exported constants
147
+ *
148
+ * 4. **Code Quality**
149
+ * - Logical grouping of related constants
150
+ * - Consistent formatting and structure
151
+ * - Self-documenting code with clear purpose
152
+ *
153
+ * 5. **Maintainability**
154
+ * - Easy to locate specific constants by section
155
+ * - Clear relationship between constants and their purposes
156
+ * - Modular structure for future extensions
157
+ *
158
+ * 6. **Performance Benefits**
159
+ * - Constants are evaluated once at module load time
160
+ * - No runtime overhead for constant access
161
+ * - Better tree-shaking potential with organized exports
162
+ */
@@ -1,5 +1,5 @@
1
- import React, { FC, ReactNode } from 'react';
2
- import { PreferenceContextType, PreferenceState } from './types';
1
+ import React, { FC, ReactNode } from "react";
2
+ import { PreferenceContextType, PreferenceState } from "./types";
3
3
  type State = PreferenceContextType & PreferenceState;
4
4
  interface StateProviderProps {
5
5
  children: ReactNode;
@@ -1,4 +1,4 @@
1
- 'use client';
1
+ "use client";
2
2
  "use strict";
3
3
  var __assign = (this && this.__assign) || function () {
4
4
  __assign = Object.assign || function(t) {
@@ -49,12 +49,14 @@ exports.usePreferenceStateContext = exports.PreferenceStateContextProvider = exp
49
49
  var react_1 = __importStar(require("react"));
50
50
  var util_functions_1 = require("@react-pakistan/util-functions");
51
51
  var vista_notification_type_1 = require("@appcorp/app-corp-vista/type/vista-notification-type");
52
+ var next_intl_1 = require("next-intl");
52
53
  var actions_1 = require("./actions");
53
54
  var constants_1 = require("./constants");
54
55
  var reducer_1 = require("./reducer");
55
56
  var generate_toast_1 = require("@appcorp/app-corp-vista/utils/generate-toast");
56
57
  var usePreferenceState = function () {
57
58
  var _a = (0, react_1.useReducer)(reducer_1.preferenceReducer, reducer_1.initialPreferenceState), state = _a[0], dispatch = _a[1];
59
+ var t = (0, next_intl_1.useTranslations)("toastMessages");
58
60
  // const { products } = useProductStateContext();
59
61
  // const { companies } = useCompanyStateContext();
60
62
  // const debouncedQuery = useDebounce(state.searchQuery, 800);
@@ -64,7 +66,7 @@ var usePreferenceState = function () {
64
66
  if (error) {
65
67
  (0, generate_toast_1.generateToast)({
66
68
  variant: vista_notification_type_1.VISTA_NOTIFICATION_V1_VARIANT.ERROR,
67
- description: constants_1.toastErrors.fetchInvoiceError,
69
+ description: t("fetchInvoiceError"),
68
70
  });
69
71
  }
70
72
  if (data === null || data === void 0 ? void 0 : data.items) {
@@ -82,7 +84,7 @@ var usePreferenceState = function () {
82
84
  currencies: [],
83
85
  bankingDetails: [],
84
86
  branches: [],
85
- id: '',
87
+ id: "",
86
88
  menuOrder: [],
87
89
  onboarding: false,
88
90
  paymentModes: [],
@@ -92,13 +94,13 @@ var usePreferenceState = function () {
92
94
  var data = _a.data, error = _a.error;
93
95
  if (error) {
94
96
  (0, generate_toast_1.generateToast)({
95
- description: constants_1.toastErrors.networkError,
97
+ description: t("networkError"),
96
98
  variant: vista_notification_type_1.VISTA_NOTIFICATION_V1_VARIANT.ERROR,
97
99
  });
98
100
  }
99
101
  if (data) {
100
102
  (0, generate_toast_1.generateToast)({
101
- description: constants_1.toastErrors.networkError,
103
+ description: t("formSubmittedSuccess"),
102
104
  variant: vista_notification_type_1.VISTA_NOTIFICATION_V1_VARIANT.SUCCESS,
103
105
  });
104
106
  dispatch({
@@ -121,7 +123,7 @@ var usePreferenceState = function () {
121
123
  var data = _a.data, error = _a.error;
122
124
  if (error) {
123
125
  (0, generate_toast_1.generateToast)({
124
- description: constants_1.toastErrors.networkError,
126
+ description: t("networkError"),
125
127
  variant: vista_notification_type_1.VISTA_NOTIFICATION_V1_VARIANT.ERROR,
126
128
  });
127
129
  }
@@ -143,13 +145,13 @@ var usePreferenceState = function () {
143
145
  var data = _a.data, error = _a.error;
144
146
  if (error) {
145
147
  (0, generate_toast_1.generateToast)({
146
- description: constants_1.toastErrors.networkError,
148
+ description: t("networkError"),
147
149
  variant: vista_notification_type_1.VISTA_NOTIFICATION_V1_VARIANT.ERROR,
148
150
  });
149
151
  }
150
152
  if (data) {
151
153
  (0, generate_toast_1.generateToast)({
152
- description: constants_1.toastErrors.networkError,
154
+ description: t("genericError"),
153
155
  variant: vista_notification_type_1.VISTA_NOTIFICATION_V1_VARIANT.SUCCESS,
154
156
  });
155
157
  dispatch({
@@ -166,7 +168,7 @@ var usePreferenceState = function () {
166
168
  listCallback: listCallback,
167
169
  listParams: listParams,
168
170
  listUrl: constants_1.PREFERENCE_API_ROUTES.PREFERENCES,
169
- searchQuery: '',
171
+ searchQuery: "",
170
172
  unitByIdUrl: constants_1.PREFERENCE_API_ROUTES.PREFERENCE_BY_ID,
171
173
  unitUrl: constants_1.PREFERENCE_API_ROUTES.PREFERENCE,
172
174
  updateCallback: updateCallback,
@@ -185,7 +187,7 @@ var usePreferenceState = function () {
185
187
  if (error) {
186
188
  (0, generate_toast_1.generateToast)({
187
189
  variant: vista_notification_type_1.VISTA_NOTIFICATION_V1_VARIANT.ERROR,
188
- description: constants_1.toastErrors.fetchInvoiceError,
190
+ description: t("fetchInvoiceError"),
189
191
  });
190
192
  }
191
193
  if (data === null || data === void 0 ? void 0 : data.items) {
@@ -200,29 +202,29 @@ var usePreferenceState = function () {
200
202
  }
201
203
  };
202
204
  var currencyUpdateParams = (0, react_1.useMemo)(function () { return ({
203
- code: '',
205
+ code: "",
204
206
  enabled: false,
205
- id: '',
207
+ id: "",
206
208
  isDefault: false,
207
- label: '',
208
- preferenceId: '',
209
+ label: "",
210
+ preferenceId: "",
209
211
  }); }, []);
210
212
  var currencyUpdateCallback = function (_a) {
211
213
  var data = _a.data, error = _a.error;
212
214
  if (error) {
213
215
  (0, generate_toast_1.generateToast)({
214
- description: constants_1.toastErrors.networkError,
216
+ description: t("networkError"),
215
217
  variant: vista_notification_type_1.VISTA_NOTIFICATION_V1_VARIANT.ERROR,
216
218
  });
217
219
  }
218
220
  if (data) {
219
221
  (0, generate_toast_1.generateToast)({
220
- description: constants_1.toastErrors.networkError,
222
+ description: t("formSubmittedSuccess"),
221
223
  variant: vista_notification_type_1.VISTA_NOTIFICATION_V1_VARIANT.SUCCESS,
222
224
  });
223
225
  dispatch({
224
226
  type: actions_1.PREFERENCE_ACTION_TYPES.SET_CURRENCY_UPDATE_ID,
225
- payload: { currencyUpdateId: '' },
227
+ payload: { currencyUpdateId: "" },
226
228
  });
227
229
  // dispatch({
228
230
  // type: PREFERENCE_ACTION_TYPES.RESET_STATE,
@@ -237,7 +239,7 @@ var usePreferenceState = function () {
237
239
  var data = _a.data, error = _a.error;
238
240
  if (error) {
239
241
  (0, generate_toast_1.generateToast)({
240
- description: constants_1.toastErrors.networkError,
242
+ description: t("networkError"),
241
243
  variant: vista_notification_type_1.VISTA_NOTIFICATION_V1_VARIANT.ERROR,
242
244
  });
243
245
  }
@@ -259,13 +261,13 @@ var usePreferenceState = function () {
259
261
  var data = _a.data, error = _a.error;
260
262
  if (error) {
261
263
  (0, generate_toast_1.generateToast)({
262
- description: constants_1.toastErrors.networkError,
264
+ description: t("networkError"),
263
265
  variant: vista_notification_type_1.VISTA_NOTIFICATION_V1_VARIANT.ERROR,
264
266
  });
265
267
  }
266
268
  if (data) {
267
269
  (0, generate_toast_1.generateToast)({
268
- description: constants_1.toastErrors.networkError,
270
+ description: t("genericError"),
269
271
  variant: vista_notification_type_1.VISTA_NOTIFICATION_V1_VARIANT.SUCCESS,
270
272
  });
271
273
  dispatch({
@@ -282,7 +284,7 @@ var usePreferenceState = function () {
282
284
  listCallback: currencyListCallback,
283
285
  listParams: currencyListParams,
284
286
  listUrl: constants_1.PREFERENCE_API_ROUTES.CURRENCIES,
285
- searchQuery: '',
287
+ searchQuery: "",
286
288
  unitByIdUrl: constants_1.PREFERENCE_API_ROUTES.CURRENCY_BY_ID,
287
289
  unitUrl: constants_1.PREFERENCE_API_ROUTES.CURRENCY,
288
290
  updateCallback: currencyUpdateCallback,
@@ -295,13 +297,11 @@ var usePreferenceState = function () {
295
297
  currencyDeleteLoading = _c.deleteLoading, currencyListError = _c.listError, currencyListFetchNow = _c.listFetchNow, currencyListLoading = _c.listLoading, currencyUpdateError = _c.updateError, currencyUpdateFetchNow = _c.updateFetchNow, currencyUpdateLoading = _c.updateLoading;
296
298
  (0, react_1.useEffect)(function () {
297
299
  listFetchNow();
298
- if (state.activeTab === 'Currency') {
300
+ if (state.activeTab === "Currency") {
299
301
  currencyListFetchNow();
300
302
  }
301
303
  // eslint-disable-next-line
302
- }, [
303
- state.activeTab,
304
- ]);
304
+ }, [state.activeTab]);
305
305
  var handleCreateCurrency = (0, react_1.useCallback)(function (currency) {
306
306
  dispatch({
307
307
  type: actions_1.PREFERENCE_ACTION_TYPES.SET_CURRENCY_UPDATE_ID,
@@ -311,8 +311,8 @@ var usePreferenceState = function () {
311
311
  body: JSON.stringify({
312
312
  isDefault: false,
313
313
  enabled: false,
314
- preferenceId: '',
315
- id: '',
314
+ preferenceId: "",
315
+ id: "",
316
316
  code: currency.code,
317
317
  label: currency.name,
318
318
  }),
@@ -328,7 +328,7 @@ var usePreferenceState = function () {
328
328
  type: actions_1.PREFERENCE_ACTION_TYPES.SET_CURRENCY_UPDATE_ID,
329
329
  payload: { currencyUpdateId: id },
330
330
  });
331
- if (route === 'isDefault') {
331
+ if (route === "isDefault") {
332
332
  var alreadyIsDefault = (_b = state.currencies.filter(function (_a) {
333
333
  var isDefault = _a.isDefault;
334
334
  return !!isDefault;
@@ -338,9 +338,9 @@ var usePreferenceState = function () {
338
338
  });
339
339
  }
340
340
  currencyUpdateFetchNow(undefined, {
341
- body: JSON.stringify(__assign(__assign(__assign(__assign(__assign({}, currencyUpdateParams), filteredCurrency), (route === 'enabled' && {
341
+ body: JSON.stringify(__assign(__assign(__assign(__assign(__assign({}, currencyUpdateParams), filteredCurrency), (route === "enabled" && {
342
342
  enabled: !filteredCurrency.enabled,
343
- })), (route === 'isDefault' && {
343
+ })), (route === "isDefault" && {
344
344
  isDefault: !filteredCurrency.isDefault,
345
345
  })), { id: id })),
346
346
  });
@@ -376,48 +376,48 @@ var usePreferenceState = function () {
376
376
  // type: INVOICE_ACTION_TYPES.CLEAR_ERRORS,
377
377
  // });
378
378
  };
379
- var headerTabs = (0, react_1.useMemo)(function () { return ([
379
+ var headerTabs = (0, react_1.useMemo)(function () { return [
380
380
  {
381
381
  enabled: true,
382
- handleOnClick: function () { return updateDashboardTab('Currency'); },
383
- isActive: state.activeTab === 'Currency',
382
+ handleOnClick: function () { return updateDashboardTab("Currency"); },
383
+ isActive: state.activeTab === "Currency",
384
384
  name: "Currency",
385
385
  order: 1,
386
386
  type: "",
387
387
  },
388
388
  {
389
389
  enabled: true,
390
- handleOnClick: function () { return updateDashboardTab('Payment Mode'); },
391
- isActive: state.activeTab === 'Payment Mode',
390
+ handleOnClick: function () { return updateDashboardTab("Payment Mode"); },
391
+ isActive: state.activeTab === "Payment Mode",
392
392
  name: "Payment Mode",
393
393
  order: 2,
394
394
  type: "",
395
395
  },
396
396
  {
397
397
  enabled: true,
398
- handleOnClick: function () { return updateDashboardTab('Branch'); },
399
- isActive: state.activeTab === 'Branch',
398
+ handleOnClick: function () { return updateDashboardTab("Branch"); },
399
+ isActive: state.activeTab === "Branch",
400
400
  name: "Branch",
401
401
  order: 3,
402
402
  type: "",
403
403
  },
404
404
  {
405
405
  enabled: true,
406
- handleOnClick: function () { return updateDashboardTab('Tax'); },
407
- isActive: state.activeTab === 'Tax',
406
+ handleOnClick: function () { return updateDashboardTab("Tax"); },
407
+ isActive: state.activeTab === "Tax",
408
408
  name: "Tax",
409
409
  order: 4,
410
410
  type: "",
411
411
  },
412
412
  {
413
413
  enabled: true,
414
- handleOnClick: function () { return updateDashboardTab('Bank'); },
415
- isActive: state.activeTab === 'Bank',
414
+ handleOnClick: function () { return updateDashboardTab("Bank"); },
415
+ isActive: state.activeTab === "Bank",
416
416
  name: "Bank",
417
417
  order: 5,
418
418
  type: "",
419
419
  },
420
- ]); }, [state.activeTab]);
420
+ ]; }, [state.activeTab]);
421
421
  return __assign(__assign({}, state), { byIdError: byIdError, byIdLoading: byIdLoading, clearSearch: clearSearch, closeDrawer: closeDrawer, currencyByIdError: currencyByIdError, currencyByIdLoading: currencyByIdLoading, currencyDeleteError: currencyDeleteError, currencyDeleteLoading: currencyDeleteLoading, currencyListError: currencyListError, currencyListLoading: currencyListLoading, currencyUpdateError: currencyUpdateError, currencyUpdateLoading: currencyUpdateLoading, deleteError: deleteError, deleteLoading: deleteLoading, dispatch: dispatch, handleCreateCurrency: handleCreateCurrency, handleUpdateCurrency: handleUpdateCurrency, headerTabs: headerTabs, listError: listError, listFetchNow: listFetchNow, listLoading: listLoading, searchOnChange: searchOnChange, updateError: updateError, updateLoading: updateLoading });
422
422
  };
423
423
  exports.PreferenceStateContext = (0, react_1.createContext)(__assign(__assign({}, reducer_1.initialPreferenceState), { byIdError: undefined, byIdLoading: false, clearSearch: function () { return void 0; }, closeDrawer: function () { return void 0; }, deleteError: undefined, deleteLoading: false, dispatch: function () { return void 0; }, listError: undefined, listFetchNow: function () { return void 0; }, listLoading: false, searchOnChange: function () { return void 0; }, updateError: undefined, updateLoading: false, headerTabs: [], currencyByIdError: undefined, currencyByIdLoading: false, currencyDeleteError: undefined, currencyDeleteLoading: false, currencyListError: undefined, currencyListLoading: false, currencyUpdateError: undefined, currencyUpdateLoading: false, handleUpdateCurrency: function () { return void 0; }, handleCreateCurrency: function () { return void 0; } }));
@@ -430,7 +430,7 @@ exports.PreferenceStateContextProvider = PreferenceStateContextProvider;
430
430
  var usePreferenceStateContext = function () {
431
431
  var state = (0, react_1.useContext)(exports.PreferenceStateContext);
432
432
  if (state === undefined) {
433
- throw new Error('usePreferenceStateContext must be used within an PreferenceContextProvider');
433
+ throw new Error("usePreferenceStateContext must be used within an PreferenceContextProvider");
434
434
  }
435
435
  return state;
436
436
  };
@@ -6,28 +6,31 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.Currency = void 0;
7
7
  var react_1 = __importDefault(require("react"));
8
8
  var util_functions_1 = require("@react-pakistan/util-functions");
9
- var vista_checkbox_v1_1 = require("@appcorp/app-corp-vista/molecules/vista-checkbox-v1/vista-checkbox-v1");
9
+ var checkbox_1 = require("@/components/ui/checkbox");
10
+ var button_1 = require("@/components/ui/button");
10
11
  var context_1 = require("./context");
11
12
  var outline_1 = require("@heroicons/react/24/outline");
12
- var vista_button_type_1 = require("@appcorp/app-corp-vista/type/vista-button-type");
13
- var vista_button_v1_1 = require("@appcorp/app-corp-vista/molecules/vista-button-v1/vista-button-v1");
14
13
  var Currency = function () {
15
14
  var _a = (0, context_1.usePreferenceStateContext)(), currencies = _a.currencies, handleUpdateCurrency = _a.handleUpdateCurrency, handleCreateCurrency = _a.handleCreateCurrency, currencyUpdateLoading = _a.currencyUpdateLoading, currencyUpdateId = _a.currencyUpdateId;
16
15
  return (react_1.default.createElement("div", { className: "grid grid-cols-4 p-4 gap-4" },
17
16
  react_1.default.createElement("div", { className: "col-span-1" },
18
17
  react_1.default.createElement("p", { className: "font-bold text-2xl pb-4" }, "Selected Currencies"),
19
- react_1.default.createElement("div", { className: "flex flex-col gap-4" }, currencies.sort(function (a, b) { return a.code.localeCompare(b.code); }).map(function (item) { return (react_1.default.createElement("div", { key: item.id, className: "flex flex-row justify-between items-center gap-4 p-2 rounded-lg bg-gray-200 hover:bg-gray-300 ".concat(item.id === currencyUpdateId && currencyUpdateLoading && 'animate-pulse') },
18
+ react_1.default.createElement("div", { className: "flex flex-col gap-4" }, currencies
19
+ .sort(function (a, b) { return a.code.localeCompare(b.code); })
20
+ .map(function (item) { return (react_1.default.createElement("div", { key: item.id, className: "flex flex-row justify-between items-center gap-4 p-2 rounded-lg bg-gray-200 hover:bg-gray-300 ".concat(item.id === currencyUpdateId &&
21
+ currencyUpdateLoading &&
22
+ "animate-pulse") },
20
23
  react_1.default.createElement("p", { className: "text-bold" },
21
24
  item.label,
22
25
  " - ",
23
26
  item.code),
24
27
  react_1.default.createElement("div", { className: "flex flex-row font-bold gap-2" },
25
- react_1.default.createElement(vista_button_v1_1.VistaButtonV1, { handleOnClick: function () { return handleUpdateCurrency(item.id, 'enabled'); }, icon: react_1.default.createElement(react_1.default.Fragment, null, item.enabled ? react_1.default.createElement(outline_1.MinusIcon, { className: "size-5" }) : react_1.default.createElement(outline_1.PlusIcon, { className: "size-5" })), variant: vista_button_type_1.VISTA_BUTTON_VARIANT.ICON }),
26
- react_1.default.createElement(vista_button_v1_1.VistaButtonV1, { handleOnClick: function () { return handleUpdateCurrency(item.id, 'isDefault'); }, icon: react_1.default.createElement(outline_1.StarIcon, { className: "size-5 ".concat(item.isDefault ? 'fill-amber-300' : 'fill-gray-400') }), variant: vista_button_type_1.VISTA_BUTTON_VARIANT.ICON })))); }))),
28
+ react_1.default.createElement(button_1.Button, { onClick: function () { return handleUpdateCurrency(item.id, "enabled"); }, variant: "ghost", size: "icon" }, item.enabled ? (react_1.default.createElement(outline_1.MinusIcon, { className: "size-5" })) : (react_1.default.createElement(outline_1.PlusIcon, { className: "size-5" }))),
29
+ react_1.default.createElement(button_1.Button, { onClick: function () { return handleUpdateCurrency(item.id, "isDefault"); }, variant: "ghost", size: "icon" },
30
+ react_1.default.createElement(outline_1.StarIcon, { className: "size-5 ".concat(item.isDefault ? "fill-amber-300" : "fill-gray-400") }))))); }))),
27
31
  react_1.default.createElement("div", { className: "col-span-3" },
28
32
  react_1.default.createElement("p", { className: "font-bold text-2xl pb-4" }, "All Currencies"),
29
- react_1.default.createElement("div", { className: "grid grid-cols-6 gap-4" }, Object
30
- .entries(util_functions_1.currencies)
33
+ react_1.default.createElement("div", { className: "grid grid-cols-6 gap-4" }, Object.entries(util_functions_1.currencies)
31
34
  .sort(function (_a, _b) {
32
35
  var keyA = _a[0];
33
36
  var keyB = _b[0];
@@ -42,8 +45,10 @@ var Currency = function () {
42
45
  })
43
46
  .map(function (_a) {
44
47
  var key = _a[0], val = _a[1];
45
- return (react_1.default.createElement("div", { className: "bg-gray-200 hover:bg-gray-300 p-2 rounded-lg ".concat(val.code === currencyUpdateId && currencyUpdateLoading && 'animate-pulse'), key: key },
46
- react_1.default.createElement(vista_checkbox_v1_1.VistaCheckboxV1, { checked: false, description: "".concat(val.name, " - ").concat(val.symbol), handleOnChange: function () { return handleCreateCurrency(val); }, heading: key, id: key })));
48
+ return (react_1.default.createElement("div", { className: "bg-gray-300 hover:bg-gray-400 p-2 rounded-lg ".concat(val.code === currencyUpdateId &&
49
+ currencyUpdateLoading &&
50
+ "animate-pulse"), key: key },
51
+ react_1.default.createElement(checkbox_1.Checkbox, { id: key, label: "".concat(key, " - ").concat(val.name, " (").concat(val.symbol, ")"), checked: false, onCheckedChange: function () { return handleCreateCurrency(val); } })));
47
52
  })))));
48
53
  };
49
54
  exports.Currency = Currency;
@@ -1,7 +1,7 @@
1
- import { FC } from 'react';
1
+ import { FC } from "react";
2
2
  interface Props {
3
3
  params: Promise<{
4
- locale: 'en' | 'ur';
4
+ locale: "en" | "ur";
5
5
  }>;
6
6
  }
7
7
  export declare const PreferencesPage: FC<Props>;
@@ -1,4 +1,4 @@
1
- 'use client';
1
+ "use client";
2
2
  "use strict";
3
3
  var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  return (mod && mod.__esModule) ? mod : { "default": mod };
@@ -9,14 +9,12 @@ var react_1 = __importDefault(require("react"));
9
9
  var context_1 = require("./context");
10
10
  var generate_toast_1 = require("@appcorp/app-corp-vista/utils/generate-toast");
11
11
  var vista_dashboard_tabs_v1_1 = require("@appcorp/app-corp-vista/molecules/vista-dashboard-tabs-v1/vista-dashboard-tabs-v1");
12
- // import "slick-carousel/slick/slick.css";
13
- // import "slick-carousel/slick/slick-theme.css";
14
12
  var constants_1 = require("./constants");
15
13
  var PreferencesPage = function () {
16
14
  var _a = (0, context_1.usePreferenceStateContext)(), headerTabs = _a.headerTabs, activeTab = _a.activeTab;
17
15
  return (react_1.default.createElement(react_1.default.Fragment, null,
18
- react_1.default.createElement(vista_dashboard_tabs_v1_1.VistaDashboardTabsV1, { headerTabs: headerTabs, heading: 'Heading' },
19
- react_1.default.createElement("div", { className: 'pt-4' }, constants_1.dashboardTabsMap[activeTab])),
16
+ react_1.default.createElement(vista_dashboard_tabs_v1_1.VistaDashboardTabsV1, { headerTabs: headerTabs, heading: "Heading" },
17
+ react_1.default.createElement("div", { className: "pt-4" }, constants_1.dashboardTabsMap[activeTab])),
20
18
  react_1.default.createElement(generate_toast_1.VistaToaster, null)));
21
19
  };
22
20
  exports.PreferencesPage = PreferencesPage;
@@ -1,4 +1,4 @@
1
- import { z } from 'zod';
1
+ import { z } from "zod";
2
2
  export declare const formValidation: z.ZodObject<{
3
3
  taxName: z.ZodString;
4
4
  taxRate: z.ZodString;
@@ -2,14 +2,14 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.formValidation = void 0;
4
4
  var zod_1 = require("zod");
5
- var constants_1 = require("./constants");
5
+ // Validation error messages (matching i18n keys from taxPage.validation)
6
+ var validationMessages = {
7
+ taxName: "Tax name is required",
8
+ taxRate: "Tax rate is required",
9
+ };
6
10
  exports.formValidation = zod_1.z.object({
7
- taxName: zod_1.z
8
- .string()
9
- .nonempty(constants_1.taxValidationError.taxName),
10
- taxRate: zod_1.z
11
- .string()
12
- .nonempty(constants_1.taxValidationError.taxRate),
11
+ taxName: zod_1.z.string().nonempty(validationMessages.taxName),
12
+ taxRate: zod_1.z.string().nonempty(validationMessages.taxRate),
13
13
  enabled: zod_1.z.boolean(),
14
14
  isDefault: zod_1.z.boolean(),
15
15
  description: zod_1.z.string().optional(),