@appcorp/stellar-solutions-modules 0.1.69 → 0.1.70
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/constants.d.ts +8 -0
- package/constants.js +11 -0
- package/global-modules/bank/cache.d.ts +23 -0
- package/global-modules/bank/cache.js +45 -0
- package/global-modules/bank/context.js +21 -37
- package/global-modules/branch/cache.d.ts +23 -0
- package/global-modules/branch/cache.js +45 -0
- package/global-modules/branch/context.js +21 -38
- package/global-modules/currency/cache.d.ts +23 -0
- package/global-modules/currency/cache.js +47 -0
- package/global-modules/currency/context.js +21 -35
- package/global-modules/payment-mode/cache.d.ts +23 -0
- package/global-modules/payment-mode/cache.js +49 -0
- package/global-modules/payment-mode/context.js +21 -31
- package/global-modules/preferences/cache.d.ts +23 -0
- package/global-modules/preferences/cache.js +47 -0
- package/global-modules/preferences/context.js +5 -4
- package/global-modules/tax/cache.d.ts +23 -0
- package/global-modules/tax/cache.js +45 -0
- package/global-modules/tax/context.js +37 -36
- package/i18n/routing.d.ts +1 -1
- package/package.json +6 -6
package/constants.d.ts
CHANGED
package/constants.js
CHANGED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LS_KEYS = void 0;
|
|
4
|
+
exports.LS_KEYS = {
|
|
5
|
+
BANKS: "banks_cache",
|
|
6
|
+
CURRENCIES: "currencies_cache",
|
|
7
|
+
PAYMENT_MODES: "payment_modes_cache",
|
|
8
|
+
PREFERENCES: "preferences_cache",
|
|
9
|
+
BRANCHES: "branches_cache",
|
|
10
|
+
TAXES: "taxes_cache",
|
|
11
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bank Module Cache Utilities
|
|
3
|
+
*
|
|
4
|
+
* Provides localStorage-based caching for banks using generic cache system.
|
|
5
|
+
*/
|
|
6
|
+
import { BankTypeBE } from "./types";
|
|
7
|
+
export declare const getCachedBanksSync: () => {
|
|
8
|
+
count: number;
|
|
9
|
+
items: BankTypeBE[];
|
|
10
|
+
};
|
|
11
|
+
export declare const getCachedBanks: ({ params, }?: {
|
|
12
|
+
params?: Record<string, unknown>;
|
|
13
|
+
}) => Promise<{
|
|
14
|
+
count: number;
|
|
15
|
+
items: BankTypeBE[];
|
|
16
|
+
}>;
|
|
17
|
+
export declare const getCachedBankById: (bankId: string) => BankTypeBE | null;
|
|
18
|
+
export declare const invalidateBanksCache: () => void;
|
|
19
|
+
export declare const preloadBanks: () => Promise<{
|
|
20
|
+
count: number;
|
|
21
|
+
items: BankTypeBE[];
|
|
22
|
+
}>;
|
|
23
|
+
export declare const isBanksCacheStale: () => boolean;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Bank Module Cache Utilities
|
|
4
|
+
*
|
|
5
|
+
* Provides localStorage-based caching for banks using generic cache system.
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.isBanksCacheStale = exports.preloadBanks = exports.invalidateBanksCache = exports.getCachedBankById = exports.getCachedBanks = exports.getCachedBanksSync = void 0;
|
|
9
|
+
var constants_1 = require("@/constants");
|
|
10
|
+
var util_functions_1 = require("@react-pakistan/util-functions");
|
|
11
|
+
var constants_2 = require("./constants");
|
|
12
|
+
// ============================================================================
|
|
13
|
+
// CACHE CONFIGURATION
|
|
14
|
+
// ============================================================================
|
|
15
|
+
var BANK_CACHE_CONFIG = {
|
|
16
|
+
apiUrl: constants_2.BANK_API_ROUTES.BANKS,
|
|
17
|
+
cacheKey: constants_1.LS_KEYS.BANKS,
|
|
18
|
+
};
|
|
19
|
+
// ============================================================================
|
|
20
|
+
// BANK-SPECIFIC CACHE FUNCTIONS
|
|
21
|
+
// ============================================================================
|
|
22
|
+
var getCachedBanksSync = function () {
|
|
23
|
+
return (0, util_functions_1.getCachedDataSync)(constants_1.LS_KEYS.BANKS);
|
|
24
|
+
};
|
|
25
|
+
exports.getCachedBanksSync = getCachedBanksSync;
|
|
26
|
+
var getCachedBanks = function (_a) {
|
|
27
|
+
var _b = _a === void 0 ? {} : _a, params = _b.params;
|
|
28
|
+
return (0, util_functions_1.getCachedData)({
|
|
29
|
+
config: BANK_CACHE_CONFIG,
|
|
30
|
+
params: params,
|
|
31
|
+
});
|
|
32
|
+
};
|
|
33
|
+
exports.getCachedBanks = getCachedBanks;
|
|
34
|
+
var getCachedBankById = function (bankId) {
|
|
35
|
+
return (0, util_functions_1.getCachedItemById)(constants_1.LS_KEYS.BANKS, bankId);
|
|
36
|
+
};
|
|
37
|
+
exports.getCachedBankById = getCachedBankById;
|
|
38
|
+
var invalidateBanksCache = function () { return (0, util_functions_1.invalidateCache)(constants_1.LS_KEYS.BANKS); };
|
|
39
|
+
exports.invalidateBanksCache = invalidateBanksCache;
|
|
40
|
+
var preloadBanks = function () {
|
|
41
|
+
return (0, util_functions_1.preloadCache)(BANK_CACHE_CONFIG);
|
|
42
|
+
};
|
|
43
|
+
exports.preloadBanks = preloadBanks;
|
|
44
|
+
var isBanksCacheStale = function () { return (0, util_functions_1.isCacheStale)(constants_1.LS_KEYS.BANKS); };
|
|
45
|
+
exports.isBanksCacheStale = isBanksCacheStale;
|
|
@@ -123,6 +123,7 @@ var reducer_1 = require("./reducer");
|
|
|
123
123
|
var toast_utils_1 = require("@appcorp/shadcn/lib/toast-utils");
|
|
124
124
|
var types_1 = require("./types");
|
|
125
125
|
var validate_1 = require("./validate");
|
|
126
|
+
var cache_1 = require("./cache");
|
|
126
127
|
// ============================================================================
|
|
127
128
|
// MAIN HOOK
|
|
128
129
|
// ============================================================================
|
|
@@ -216,7 +217,7 @@ var useBankState = function () {
|
|
|
216
217
|
if (data) {
|
|
217
218
|
showSuccessToast(t("messagesBankUpdated"));
|
|
218
219
|
// Invalidate cache to force fresh data on next fetch
|
|
219
|
-
(0,
|
|
220
|
+
(0, cache_1.invalidateBanksCache)();
|
|
220
221
|
dispatch({
|
|
221
222
|
type: actions_1.BANK_ACTION_TYPES.RESET_FORM,
|
|
222
223
|
});
|
|
@@ -238,7 +239,7 @@ var useBankState = function () {
|
|
|
238
239
|
if (data) {
|
|
239
240
|
showSuccessToast(t("messagesBankDeleted"));
|
|
240
241
|
// Invalidate cache to force fresh data on next fetch
|
|
241
|
-
(0,
|
|
242
|
+
(0, cache_1.invalidateBanksCache)();
|
|
242
243
|
dispatch({
|
|
243
244
|
type: actions_1.BANK_ACTION_TYPES.RESET_FORM,
|
|
244
245
|
});
|
|
@@ -297,50 +298,33 @@ var useBankState = function () {
|
|
|
297
298
|
*/
|
|
298
299
|
(0, react_1.useEffect)(function () {
|
|
299
300
|
(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
300
|
-
var
|
|
301
|
-
return __generator(this, function (
|
|
302
|
-
switch (
|
|
301
|
+
var _a, count, items, error_1;
|
|
302
|
+
return __generator(this, function (_b) {
|
|
303
|
+
switch (_b.label) {
|
|
303
304
|
case 0:
|
|
304
|
-
|
|
305
|
-
return [4 /*yield*/, (0,
|
|
305
|
+
_b.trys.push([0, 2, , 3]);
|
|
306
|
+
return [4 /*yield*/, (0, cache_1.getCachedBanks)({
|
|
307
|
+
params: listParams,
|
|
308
|
+
})];
|
|
306
309
|
case 1:
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
((_c = bank.accountNumber) === null || _c === void 0 ? void 0 : _c.toLowerCase().includes(query_1)) ||
|
|
317
|
-
((_d = bank.iban) === null || _d === void 0 ? void 0 : _d.toLowerCase().includes(query_1));
|
|
318
|
-
});
|
|
319
|
-
}
|
|
320
|
-
startIndex = (state.currentPage - 1) * state.pageLimit;
|
|
321
|
-
endIndex = startIndex + state.pageLimit;
|
|
322
|
-
paginatedItems = filteredItems.slice(startIndex, endIndex);
|
|
323
|
-
dispatch({
|
|
324
|
-
type: actions_1.BANK_ACTION_TYPES.SET_BANKS,
|
|
325
|
-
payload: { banks: paginatedItems },
|
|
326
|
-
});
|
|
327
|
-
dispatch({
|
|
328
|
-
type: actions_1.BANK_ACTION_TYPES.SET_COUNT,
|
|
329
|
-
payload: { count: filteredItems.length },
|
|
330
|
-
});
|
|
331
|
-
}
|
|
310
|
+
_a = _b.sent(), count = _a.count, items = _a.items;
|
|
311
|
+
dispatch({
|
|
312
|
+
type: actions_1.BANK_ACTION_TYPES.SET_BANKS,
|
|
313
|
+
payload: { banks: items },
|
|
314
|
+
});
|
|
315
|
+
dispatch({
|
|
316
|
+
type: actions_1.BANK_ACTION_TYPES.SET_COUNT,
|
|
317
|
+
payload: { count: count },
|
|
318
|
+
});
|
|
332
319
|
return [3 /*break*/, 3];
|
|
333
320
|
case 2:
|
|
334
|
-
error_1 =
|
|
335
|
-
console.error("Error loading banks from cache:", error_1);
|
|
336
|
-
showErrorToast(t("messagesNetworkError"));
|
|
321
|
+
error_1 = _b.sent();
|
|
337
322
|
return [3 /*break*/, 3];
|
|
338
323
|
case 3: return [2 /*return*/];
|
|
339
324
|
}
|
|
340
325
|
});
|
|
341
326
|
}); })();
|
|
342
|
-
|
|
343
|
-
}, [debouncedQuery, state.currentPage, state.pageLimit]);
|
|
327
|
+
}, [listParams]);
|
|
344
328
|
// ---------------------------------------------------------------------------
|
|
345
329
|
// DRAWER & MODAL HANDLERS
|
|
346
330
|
// ---------------------------------------------------------------------------
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Branch Module Cache Utilities
|
|
3
|
+
*
|
|
4
|
+
* Provides localStorage-based caching for branches using generic cache system.
|
|
5
|
+
*/
|
|
6
|
+
import { BranchTypeBE } from "./types";
|
|
7
|
+
export declare const getCachedBranchesSync: () => {
|
|
8
|
+
count: number;
|
|
9
|
+
items: BranchTypeBE[];
|
|
10
|
+
};
|
|
11
|
+
export declare const getCachedBranches: ({ params, }?: {
|
|
12
|
+
params?: Record<string, unknown>;
|
|
13
|
+
}) => Promise<{
|
|
14
|
+
count: number;
|
|
15
|
+
items: BranchTypeBE[];
|
|
16
|
+
}>;
|
|
17
|
+
export declare const getCachedBranchById: (branchId: string) => BranchTypeBE | null;
|
|
18
|
+
export declare const invalidateBranchesCache: () => void;
|
|
19
|
+
export declare const preloadBranches: () => Promise<{
|
|
20
|
+
count: number;
|
|
21
|
+
items: BranchTypeBE[];
|
|
22
|
+
}>;
|
|
23
|
+
export declare const isBranchesCacheStale: () => boolean;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Branch Module Cache Utilities
|
|
4
|
+
*
|
|
5
|
+
* Provides localStorage-based caching for branches using generic cache system.
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.isBranchesCacheStale = exports.preloadBranches = exports.invalidateBranchesCache = exports.getCachedBranchById = exports.getCachedBranches = exports.getCachedBranchesSync = void 0;
|
|
9
|
+
var constants_1 = require("@/constants");
|
|
10
|
+
var util_functions_1 = require("@react-pakistan/util-functions");
|
|
11
|
+
var constants_2 = require("./constants");
|
|
12
|
+
// ============================================================================
|
|
13
|
+
// CACHE CONFIGURATION
|
|
14
|
+
// ============================================================================
|
|
15
|
+
var BRANCH_CACHE_CONFIG = {
|
|
16
|
+
apiUrl: constants_2.BRANCH_API_ROUTES.BRANCHES,
|
|
17
|
+
cacheKey: constants_1.LS_KEYS.BRANCHES,
|
|
18
|
+
};
|
|
19
|
+
// ============================================================================
|
|
20
|
+
// BRANCH-SPECIFIC CACHE FUNCTIONS
|
|
21
|
+
// ============================================================================
|
|
22
|
+
var getCachedBranchesSync = function () {
|
|
23
|
+
return (0, util_functions_1.getCachedDataSync)(constants_1.LS_KEYS.BRANCHES);
|
|
24
|
+
};
|
|
25
|
+
exports.getCachedBranchesSync = getCachedBranchesSync;
|
|
26
|
+
var getCachedBranches = function (_a) {
|
|
27
|
+
var _b = _a === void 0 ? {} : _a, params = _b.params;
|
|
28
|
+
return (0, util_functions_1.getCachedData)({
|
|
29
|
+
config: BRANCH_CACHE_CONFIG,
|
|
30
|
+
params: params,
|
|
31
|
+
});
|
|
32
|
+
};
|
|
33
|
+
exports.getCachedBranches = getCachedBranches;
|
|
34
|
+
var getCachedBranchById = function (branchId) {
|
|
35
|
+
return (0, util_functions_1.getCachedItemById)(constants_1.LS_KEYS.BRANCHES, branchId);
|
|
36
|
+
};
|
|
37
|
+
exports.getCachedBranchById = getCachedBranchById;
|
|
38
|
+
var invalidateBranchesCache = function () { return (0, util_functions_1.invalidateCache)(constants_1.LS_KEYS.BRANCHES); };
|
|
39
|
+
exports.invalidateBranchesCache = invalidateBranchesCache;
|
|
40
|
+
var preloadBranches = function () {
|
|
41
|
+
return (0, util_functions_1.preloadCache)(BRANCH_CACHE_CONFIG);
|
|
42
|
+
};
|
|
43
|
+
exports.preloadBranches = preloadBranches;
|
|
44
|
+
var isBranchesCacheStale = function () { return (0, util_functions_1.isCacheStale)(constants_1.LS_KEYS.BRANCHES); };
|
|
45
|
+
exports.isBranchesCacheStale = isBranchesCacheStale;
|
|
@@ -124,6 +124,7 @@ var toast_utils_1 = require("@appcorp/shadcn/lib/toast-utils");
|
|
|
124
124
|
var types_1 = require("./types");
|
|
125
125
|
var validate_1 = require("./validate");
|
|
126
126
|
var context_1 = require("../preferences/context");
|
|
127
|
+
var cache_1 = require("./cache");
|
|
127
128
|
// ============================================================================
|
|
128
129
|
// MAIN HOOK
|
|
129
130
|
// ============================================================================
|
|
@@ -219,7 +220,7 @@ var useBranchState = function () {
|
|
|
219
220
|
if (data) {
|
|
220
221
|
showSuccessToast(t("messagesBranchUpdated"));
|
|
221
222
|
// Invalidate cache to force fresh data on next fetch
|
|
222
|
-
(0,
|
|
223
|
+
(0, cache_1.invalidateBranchesCache)();
|
|
223
224
|
dispatch({
|
|
224
225
|
type: actions_1.BRANCH_ACTION_TYPES.RESET_FORM,
|
|
225
226
|
});
|
|
@@ -256,7 +257,7 @@ var useBranchState = function () {
|
|
|
256
257
|
if (data) {
|
|
257
258
|
showSuccessToast(t("messagesBranchDeleted"));
|
|
258
259
|
// Invalidate cache to force fresh data on next fetch
|
|
259
|
-
(0,
|
|
260
|
+
(0, cache_1.invalidateBranchesCache)();
|
|
260
261
|
dispatch({
|
|
261
262
|
type: actions_1.BRANCH_ACTION_TYPES.RESET_FORM,
|
|
262
263
|
});
|
|
@@ -303,51 +304,33 @@ var useBranchState = function () {
|
|
|
303
304
|
*/
|
|
304
305
|
(0, react_1.useEffect)(function () {
|
|
305
306
|
(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
306
|
-
var
|
|
307
|
-
return __generator(this, function (
|
|
308
|
-
switch (
|
|
307
|
+
var _a, count, items, error_1;
|
|
308
|
+
return __generator(this, function (_b) {
|
|
309
|
+
switch (_b.label) {
|
|
309
310
|
case 0:
|
|
310
|
-
|
|
311
|
-
return [4 /*yield*/, (0,
|
|
311
|
+
_b.trys.push([0, 2, , 3]);
|
|
312
|
+
return [4 /*yield*/, (0, cache_1.getCachedBranches)({
|
|
313
|
+
params: listParams,
|
|
314
|
+
})];
|
|
312
315
|
case 1:
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
((_c = branch.personName) === null || _c === void 0 ? void 0 : _c.toLowerCase().includes(query_1)) ||
|
|
323
|
-
((_d = branch.personEmail) === null || _d === void 0 ? void 0 : _d.toLowerCase().includes(query_1)) ||
|
|
324
|
-
((_e = branch.personPhone) === null || _e === void 0 ? void 0 : _e.toLowerCase().includes(query_1));
|
|
325
|
-
});
|
|
326
|
-
}
|
|
327
|
-
startIndex = (state.currentPage - 1) * state.pageLimit;
|
|
328
|
-
endIndex = startIndex + state.pageLimit;
|
|
329
|
-
paginatedItems = filteredItems.slice(startIndex, endIndex);
|
|
330
|
-
dispatch({
|
|
331
|
-
type: actions_1.BRANCH_ACTION_TYPES.SET_BRANCHES,
|
|
332
|
-
payload: { branches: paginatedItems },
|
|
333
|
-
});
|
|
334
|
-
dispatch({
|
|
335
|
-
type: actions_1.BRANCH_ACTION_TYPES.SET_COUNT,
|
|
336
|
-
payload: { count: filteredItems.length },
|
|
337
|
-
});
|
|
338
|
-
}
|
|
316
|
+
_a = _b.sent(), count = _a.count, items = _a.items;
|
|
317
|
+
dispatch({
|
|
318
|
+
type: actions_1.BRANCH_ACTION_TYPES.SET_BRANCHES,
|
|
319
|
+
payload: { branches: items },
|
|
320
|
+
});
|
|
321
|
+
dispatch({
|
|
322
|
+
type: actions_1.BRANCH_ACTION_TYPES.SET_COUNT,
|
|
323
|
+
payload: { count: count },
|
|
324
|
+
});
|
|
339
325
|
return [3 /*break*/, 3];
|
|
340
326
|
case 2:
|
|
341
|
-
error_1 =
|
|
342
|
-
console.error("Error loading branches from cache:", error_1);
|
|
343
|
-
showErrorToast(tCommon("messagesNetworkError"));
|
|
327
|
+
error_1 = _b.sent();
|
|
344
328
|
return [3 /*break*/, 3];
|
|
345
329
|
case 3: return [2 /*return*/];
|
|
346
330
|
}
|
|
347
331
|
});
|
|
348
332
|
}); })();
|
|
349
|
-
|
|
350
|
-
}, [debouncedQuery, state.currentPage, state.pageLimit]);
|
|
333
|
+
}, [listParams]);
|
|
351
334
|
// ---------------------------------------------------------------------------
|
|
352
335
|
// DRAWER & MODAL HANDLERS
|
|
353
336
|
// ---------------------------------------------------------------------------
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Currency Module Cache Utilities
|
|
3
|
+
*
|
|
4
|
+
* Provides localStorage-based caching for currencies using generic cache system.
|
|
5
|
+
*/
|
|
6
|
+
import { CurrencyTypeBE } from "./types";
|
|
7
|
+
export declare const getCachedCurrenciesSync: () => {
|
|
8
|
+
count: number;
|
|
9
|
+
items: CurrencyTypeBE[];
|
|
10
|
+
};
|
|
11
|
+
export declare const getCachedCurrencies: ({ params, }?: {
|
|
12
|
+
params?: Record<string, unknown>;
|
|
13
|
+
}) => Promise<{
|
|
14
|
+
count: number;
|
|
15
|
+
items: CurrencyTypeBE[];
|
|
16
|
+
}>;
|
|
17
|
+
export declare const getCachedCurrencyById: (currencyId: string) => CurrencyTypeBE | null;
|
|
18
|
+
export declare const invalidateCurrenciesCache: () => void;
|
|
19
|
+
export declare const preloadCurrencies: () => Promise<{
|
|
20
|
+
count: number;
|
|
21
|
+
items: CurrencyTypeBE[];
|
|
22
|
+
}>;
|
|
23
|
+
export declare const isCurrenciesCacheStale: () => boolean;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Currency Module Cache Utilities
|
|
4
|
+
*
|
|
5
|
+
* Provides localStorage-based caching for currencies using generic cache system.
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.isCurrenciesCacheStale = exports.preloadCurrencies = exports.invalidateCurrenciesCache = exports.getCachedCurrencyById = exports.getCachedCurrencies = exports.getCachedCurrenciesSync = void 0;
|
|
9
|
+
var constants_1 = require("@/constants");
|
|
10
|
+
var util_functions_1 = require("@react-pakistan/util-functions");
|
|
11
|
+
var constants_2 = require("./constants");
|
|
12
|
+
// ============================================================================
|
|
13
|
+
// CACHE CONFIGURATION
|
|
14
|
+
// ============================================================================
|
|
15
|
+
var CURRENCY_CACHE_CONFIG = {
|
|
16
|
+
apiUrl: constants_2.CURRENCY_API_ROUTES.CURRENCIES,
|
|
17
|
+
cacheKey: constants_1.LS_KEYS.CURRENCIES,
|
|
18
|
+
};
|
|
19
|
+
// ============================================================================
|
|
20
|
+
// CURRENCY-SPECIFIC CACHE FUNCTIONS
|
|
21
|
+
// ============================================================================
|
|
22
|
+
var getCachedCurrenciesSync = function () {
|
|
23
|
+
return (0, util_functions_1.getCachedDataSync)(constants_1.LS_KEYS.CURRENCIES);
|
|
24
|
+
};
|
|
25
|
+
exports.getCachedCurrenciesSync = getCachedCurrenciesSync;
|
|
26
|
+
var getCachedCurrencies = function (_a) {
|
|
27
|
+
var _b = _a === void 0 ? {} : _a, params = _b.params;
|
|
28
|
+
return (0, util_functions_1.getCachedData)({
|
|
29
|
+
config: CURRENCY_CACHE_CONFIG,
|
|
30
|
+
params: params,
|
|
31
|
+
});
|
|
32
|
+
};
|
|
33
|
+
exports.getCachedCurrencies = getCachedCurrencies;
|
|
34
|
+
var getCachedCurrencyById = function (currencyId) {
|
|
35
|
+
return (0, util_functions_1.getCachedItemById)(constants_1.LS_KEYS.CURRENCIES, currencyId);
|
|
36
|
+
};
|
|
37
|
+
exports.getCachedCurrencyById = getCachedCurrencyById;
|
|
38
|
+
var invalidateCurrenciesCache = function () {
|
|
39
|
+
return (0, util_functions_1.invalidateCache)(constants_1.LS_KEYS.CURRENCIES);
|
|
40
|
+
};
|
|
41
|
+
exports.invalidateCurrenciesCache = invalidateCurrenciesCache;
|
|
42
|
+
var preloadCurrencies = function () {
|
|
43
|
+
return (0, util_functions_1.preloadCache)(CURRENCY_CACHE_CONFIG);
|
|
44
|
+
};
|
|
45
|
+
exports.preloadCurrencies = preloadCurrencies;
|
|
46
|
+
var isCurrenciesCacheStale = function () { return (0, util_functions_1.isCacheStale)(constants_1.LS_KEYS.CURRENCIES); };
|
|
47
|
+
exports.isCurrenciesCacheStale = isCurrenciesCacheStale;
|
|
@@ -123,6 +123,7 @@ var reducer_1 = require("./reducer");
|
|
|
123
123
|
var toast_utils_1 = require("@appcorp/shadcn/lib/toast-utils");
|
|
124
124
|
var types_1 = require("./types");
|
|
125
125
|
var validate_1 = require("./validate");
|
|
126
|
+
var cache_1 = require("./cache");
|
|
126
127
|
// ============================================================================
|
|
127
128
|
// MAIN HOOK
|
|
128
129
|
// ============================================================================
|
|
@@ -205,7 +206,7 @@ var useCurrencyState = function () {
|
|
|
205
206
|
if (data) {
|
|
206
207
|
showSuccessToast(t("messagesCurrencyUpdated"));
|
|
207
208
|
// Invalidate cache to force fresh data on next fetch
|
|
208
|
-
(0,
|
|
209
|
+
(0, cache_1.invalidateCurrenciesCache)();
|
|
209
210
|
dispatch({
|
|
210
211
|
type: actions_1.CURRENCY_ACTION_TYPES.RESET_FORM,
|
|
211
212
|
});
|
|
@@ -227,7 +228,7 @@ var useCurrencyState = function () {
|
|
|
227
228
|
if (data) {
|
|
228
229
|
showSuccessToast(t("messagesCurrencyDeleted"));
|
|
229
230
|
// Invalidate cache to force fresh data on next fetch
|
|
230
|
-
(0,
|
|
231
|
+
(0, cache_1.invalidateCurrenciesCache)();
|
|
231
232
|
dispatch({
|
|
232
233
|
type: actions_1.CURRENCY_ACTION_TYPES.RESET_FORM,
|
|
233
234
|
});
|
|
@@ -287,48 +288,33 @@ var useCurrencyState = function () {
|
|
|
287
288
|
*/
|
|
288
289
|
(0, react_1.useEffect)(function () {
|
|
289
290
|
(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
290
|
-
var
|
|
291
|
-
return __generator(this, function (
|
|
292
|
-
switch (
|
|
291
|
+
var _a, count, items, error_1;
|
|
292
|
+
return __generator(this, function (_b) {
|
|
293
|
+
switch (_b.label) {
|
|
293
294
|
case 0:
|
|
294
|
-
|
|
295
|
-
return [4 /*yield*/, (0,
|
|
295
|
+
_b.trys.push([0, 2, , 3]);
|
|
296
|
+
return [4 /*yield*/, (0, cache_1.getCachedCurrencies)({
|
|
297
|
+
params: listParams,
|
|
298
|
+
})];
|
|
296
299
|
case 1:
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
});
|
|
307
|
-
}
|
|
308
|
-
startIndex = (state.currentPage - 1) * state.pageLimit;
|
|
309
|
-
endIndex = startIndex + state.pageLimit;
|
|
310
|
-
paginatedItems = filteredItems.slice(startIndex, endIndex);
|
|
311
|
-
dispatch({
|
|
312
|
-
type: actions_1.CURRENCY_ACTION_TYPES.SET_CURRENCIES,
|
|
313
|
-
payload: { currencies: paginatedItems },
|
|
314
|
-
});
|
|
315
|
-
dispatch({
|
|
316
|
-
type: actions_1.CURRENCY_ACTION_TYPES.SET_COUNT,
|
|
317
|
-
payload: { count: filteredItems.length },
|
|
318
|
-
});
|
|
319
|
-
}
|
|
300
|
+
_a = _b.sent(), count = _a.count, items = _a.items;
|
|
301
|
+
dispatch({
|
|
302
|
+
type: actions_1.CURRENCY_ACTION_TYPES.SET_CURRENCIES,
|
|
303
|
+
payload: { currencies: items },
|
|
304
|
+
});
|
|
305
|
+
dispatch({
|
|
306
|
+
type: actions_1.CURRENCY_ACTION_TYPES.SET_COUNT,
|
|
307
|
+
payload: { count: count },
|
|
308
|
+
});
|
|
320
309
|
return [3 /*break*/, 3];
|
|
321
310
|
case 2:
|
|
322
|
-
error_1 =
|
|
323
|
-
console.error("Error loading currencies from cache:", error_1);
|
|
324
|
-
showErrorToast(tCommon("messagesNetworkError"));
|
|
311
|
+
error_1 = _b.sent();
|
|
325
312
|
return [3 /*break*/, 3];
|
|
326
313
|
case 3: return [2 /*return*/];
|
|
327
314
|
}
|
|
328
315
|
});
|
|
329
316
|
}); })();
|
|
330
|
-
|
|
331
|
-
}, [debouncedQuery, state.currentPage, state.pageLimit]);
|
|
317
|
+
}, [listParams]);
|
|
332
318
|
// ---------------------------------------------------------------------------
|
|
333
319
|
// DRAWER & MODAL HANDLERS
|
|
334
320
|
// ---------------------------------------------------------------------------
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Payment Mode Module Cache Utilities
|
|
3
|
+
*
|
|
4
|
+
* Provides localStorage-based caching for payment modes using generic cache system.
|
|
5
|
+
*/
|
|
6
|
+
import { PaymentModeTypeBE } from "./types";
|
|
7
|
+
export declare const getCachedPaymentModesSync: () => {
|
|
8
|
+
count: number;
|
|
9
|
+
items: PaymentModeTypeBE[];
|
|
10
|
+
};
|
|
11
|
+
export declare const getCachedPaymentModes: ({ params, }?: {
|
|
12
|
+
params?: Record<string, unknown>;
|
|
13
|
+
}) => Promise<{
|
|
14
|
+
count: number;
|
|
15
|
+
items: PaymentModeTypeBE[];
|
|
16
|
+
}>;
|
|
17
|
+
export declare const getCachedPaymentModeById: (paymentModeId: string) => PaymentModeTypeBE | null;
|
|
18
|
+
export declare const invalidatePaymentModesCache: () => void;
|
|
19
|
+
export declare const preloadPaymentModes: () => Promise<{
|
|
20
|
+
count: number;
|
|
21
|
+
items: PaymentModeTypeBE[];
|
|
22
|
+
}>;
|
|
23
|
+
export declare const isPaymentModesCacheStale: () => boolean;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Payment Mode Module Cache Utilities
|
|
4
|
+
*
|
|
5
|
+
* Provides localStorage-based caching for payment modes using generic cache system.
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.isPaymentModesCacheStale = exports.preloadPaymentModes = exports.invalidatePaymentModesCache = exports.getCachedPaymentModeById = exports.getCachedPaymentModes = exports.getCachedPaymentModesSync = void 0;
|
|
9
|
+
var constants_1 = require("@/constants");
|
|
10
|
+
var util_functions_1 = require("@react-pakistan/util-functions");
|
|
11
|
+
var constants_2 = require("./constants");
|
|
12
|
+
// ============================================================================
|
|
13
|
+
// CACHE CONFIGURATION
|
|
14
|
+
// ============================================================================
|
|
15
|
+
var PAYMENT_MODE_CACHE_CONFIG = {
|
|
16
|
+
apiUrl: constants_2.PAYMENT_MODE_API_ROUTES.PAYMENT_MODES,
|
|
17
|
+
cacheKey: constants_1.LS_KEYS.PAYMENT_MODES,
|
|
18
|
+
};
|
|
19
|
+
// ============================================================================
|
|
20
|
+
// PAYMENT MODE-SPECIFIC CACHE FUNCTIONS
|
|
21
|
+
// ============================================================================
|
|
22
|
+
var getCachedPaymentModesSync = function () {
|
|
23
|
+
return (0, util_functions_1.getCachedDataSync)(constants_1.LS_KEYS.PAYMENT_MODES);
|
|
24
|
+
};
|
|
25
|
+
exports.getCachedPaymentModesSync = getCachedPaymentModesSync;
|
|
26
|
+
var getCachedPaymentModes = function (_a) {
|
|
27
|
+
var _b = _a === void 0 ? {} : _a, params = _b.params;
|
|
28
|
+
return (0, util_functions_1.getCachedData)({
|
|
29
|
+
config: PAYMENT_MODE_CACHE_CONFIG,
|
|
30
|
+
params: params,
|
|
31
|
+
});
|
|
32
|
+
};
|
|
33
|
+
exports.getCachedPaymentModes = getCachedPaymentModes;
|
|
34
|
+
var getCachedPaymentModeById = function (paymentModeId) {
|
|
35
|
+
return (0, util_functions_1.getCachedItemById)(constants_1.LS_KEYS.PAYMENT_MODES, paymentModeId);
|
|
36
|
+
};
|
|
37
|
+
exports.getCachedPaymentModeById = getCachedPaymentModeById;
|
|
38
|
+
var invalidatePaymentModesCache = function () {
|
|
39
|
+
return (0, util_functions_1.invalidateCache)(constants_1.LS_KEYS.PAYMENT_MODES);
|
|
40
|
+
};
|
|
41
|
+
exports.invalidatePaymentModesCache = invalidatePaymentModesCache;
|
|
42
|
+
var preloadPaymentModes = function () {
|
|
43
|
+
return (0, util_functions_1.preloadCache)(PAYMENT_MODE_CACHE_CONFIG);
|
|
44
|
+
};
|
|
45
|
+
exports.preloadPaymentModes = preloadPaymentModes;
|
|
46
|
+
var isPaymentModesCacheStale = function () {
|
|
47
|
+
return (0, util_functions_1.isCacheStale)(constants_1.LS_KEYS.PAYMENT_MODES);
|
|
48
|
+
};
|
|
49
|
+
exports.isPaymentModesCacheStale = isPaymentModesCacheStale;
|
|
@@ -124,6 +124,7 @@ var toast_utils_1 = require("@appcorp/shadcn/lib/toast-utils");
|
|
|
124
124
|
var types_1 = require("./types");
|
|
125
125
|
var validate_1 = require("./validate");
|
|
126
126
|
var context_1 = require("../preferences/context");
|
|
127
|
+
var cache_1 = require("./cache");
|
|
127
128
|
// ============================================================================
|
|
128
129
|
// MAIN HOOK
|
|
129
130
|
// ============================================================================
|
|
@@ -201,7 +202,7 @@ var usePaymentModeState = function () {
|
|
|
201
202
|
if (data) {
|
|
202
203
|
showSuccessToast(t("messagesPaymentModeUpdated"));
|
|
203
204
|
// Invalidate cache to force fresh data on next fetch
|
|
204
|
-
(0,
|
|
205
|
+
(0, cache_1.invalidatePaymentModesCache)();
|
|
205
206
|
dispatch({
|
|
206
207
|
type: actions_1.PAYMENT_MODE_ACTION_TYPES.RESET_FORM,
|
|
207
208
|
});
|
|
@@ -238,7 +239,7 @@ var usePaymentModeState = function () {
|
|
|
238
239
|
if (data) {
|
|
239
240
|
showSuccessToast(t("messagesPaymentModeDeleted"));
|
|
240
241
|
// Invalidate cache to force fresh data on next fetch
|
|
241
|
-
(0,
|
|
242
|
+
(0, cache_1.invalidatePaymentModesCache)();
|
|
242
243
|
dispatch({
|
|
243
244
|
type: actions_1.PAYMENT_MODE_ACTION_TYPES.RESET_FORM,
|
|
244
245
|
});
|
|
@@ -285,44 +286,33 @@ var usePaymentModeState = function () {
|
|
|
285
286
|
*/
|
|
286
287
|
(0, react_1.useEffect)(function () {
|
|
287
288
|
(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
288
|
-
var
|
|
289
|
-
return __generator(this, function (
|
|
290
|
-
switch (
|
|
289
|
+
var _a, count, items, error_1;
|
|
290
|
+
return __generator(this, function (_b) {
|
|
291
|
+
switch (_b.label) {
|
|
291
292
|
case 0:
|
|
292
|
-
|
|
293
|
-
return [4 /*yield*/, (0,
|
|
293
|
+
_b.trys.push([0, 2, , 3]);
|
|
294
|
+
return [4 /*yield*/, (0, cache_1.getCachedPaymentModes)({
|
|
295
|
+
params: listParams,
|
|
296
|
+
})];
|
|
294
297
|
case 1:
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
paginatedItems = filteredItems.slice(startIndex, endIndex);
|
|
305
|
-
dispatch({
|
|
306
|
-
type: actions_1.PAYMENT_MODE_ACTION_TYPES.SET_PAYMENT_MODES,
|
|
307
|
-
payload: { paymentModes: paginatedItems },
|
|
308
|
-
});
|
|
309
|
-
dispatch({
|
|
310
|
-
type: actions_1.PAYMENT_MODE_ACTION_TYPES.SET_COUNT,
|
|
311
|
-
payload: { count: filteredItems.length },
|
|
312
|
-
});
|
|
313
|
-
}
|
|
298
|
+
_a = _b.sent(), count = _a.count, items = _a.items;
|
|
299
|
+
dispatch({
|
|
300
|
+
type: actions_1.PAYMENT_MODE_ACTION_TYPES.SET_PAYMENT_MODES,
|
|
301
|
+
payload: { paymentModes: items },
|
|
302
|
+
});
|
|
303
|
+
dispatch({
|
|
304
|
+
type: actions_1.PAYMENT_MODE_ACTION_TYPES.SET_COUNT,
|
|
305
|
+
payload: { count: count },
|
|
306
|
+
});
|
|
314
307
|
return [3 /*break*/, 3];
|
|
315
308
|
case 2:
|
|
316
|
-
error_1 =
|
|
317
|
-
console.error("Error loading payment modes from cache:", error_1);
|
|
318
|
-
showErrorToast(tCommon("messagesNetworkError"));
|
|
309
|
+
error_1 = _b.sent();
|
|
319
310
|
return [3 /*break*/, 3];
|
|
320
311
|
case 3: return [2 /*return*/];
|
|
321
312
|
}
|
|
322
313
|
});
|
|
323
314
|
}); })();
|
|
324
|
-
|
|
325
|
-
}, [debouncedQuery, state.currentPage, state.pageLimit]);
|
|
315
|
+
}, [listParams]);
|
|
326
316
|
// ---------------------------------------------------------------------------
|
|
327
317
|
// DRAWER & MODAL HANDLERS
|
|
328
318
|
// ---------------------------------------------------------------------------
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Preferences Module Cache Utilities
|
|
3
|
+
*
|
|
4
|
+
* Provides localStorage-based caching for preferences using generic cache system.
|
|
5
|
+
*/
|
|
6
|
+
import { PreferenceTypeBE } from "./types";
|
|
7
|
+
export declare const getCachedPreferencesSync: () => {
|
|
8
|
+
count: number;
|
|
9
|
+
items: PreferenceTypeBE[];
|
|
10
|
+
};
|
|
11
|
+
export declare const getCachedPreferences: ({ params, }?: {
|
|
12
|
+
params?: Record<string, unknown>;
|
|
13
|
+
}) => Promise<{
|
|
14
|
+
count: number;
|
|
15
|
+
items: PreferenceTypeBE[];
|
|
16
|
+
}>;
|
|
17
|
+
export declare const getCachedPreferenceById: (preferenceId: string) => PreferenceTypeBE | null;
|
|
18
|
+
export declare const invalidatePreferencesCache: () => void;
|
|
19
|
+
export declare const preloadPreferences: () => Promise<{
|
|
20
|
+
count: number;
|
|
21
|
+
items: PreferenceTypeBE[];
|
|
22
|
+
}>;
|
|
23
|
+
export declare const isPreferencesCacheStale: () => boolean;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Preferences Module Cache Utilities
|
|
4
|
+
*
|
|
5
|
+
* Provides localStorage-based caching for preferences using generic cache system.
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.isPreferencesCacheStale = exports.preloadPreferences = exports.invalidatePreferencesCache = exports.getCachedPreferenceById = exports.getCachedPreferences = exports.getCachedPreferencesSync = void 0;
|
|
9
|
+
var constants_1 = require("@/constants");
|
|
10
|
+
var util_functions_1 = require("@react-pakistan/util-functions");
|
|
11
|
+
var constants_2 = require("./constants");
|
|
12
|
+
// ============================================================================
|
|
13
|
+
// CACHE CONFIGURATION
|
|
14
|
+
// ============================================================================
|
|
15
|
+
var PREFERENCE_CACHE_CONFIG = {
|
|
16
|
+
apiUrl: constants_2.PREFERENCE_API_ROUTES.PREFERENCES,
|
|
17
|
+
cacheKey: constants_1.LS_KEYS.PREFERENCES,
|
|
18
|
+
};
|
|
19
|
+
// ============================================================================
|
|
20
|
+
// PREFERENCE-SPECIFIC CACHE FUNCTIONS
|
|
21
|
+
// ============================================================================
|
|
22
|
+
var getCachedPreferencesSync = function () {
|
|
23
|
+
return (0, util_functions_1.getCachedDataSync)(constants_1.LS_KEYS.PREFERENCES);
|
|
24
|
+
};
|
|
25
|
+
exports.getCachedPreferencesSync = getCachedPreferencesSync;
|
|
26
|
+
var getCachedPreferences = function (_a) {
|
|
27
|
+
var _b = _a === void 0 ? {} : _a, params = _b.params;
|
|
28
|
+
return (0, util_functions_1.getCachedData)({
|
|
29
|
+
config: PREFERENCE_CACHE_CONFIG,
|
|
30
|
+
params: params,
|
|
31
|
+
});
|
|
32
|
+
};
|
|
33
|
+
exports.getCachedPreferences = getCachedPreferences;
|
|
34
|
+
var getCachedPreferenceById = function (preferenceId) {
|
|
35
|
+
return (0, util_functions_1.getCachedItemById)(constants_1.LS_KEYS.PREFERENCES, preferenceId);
|
|
36
|
+
};
|
|
37
|
+
exports.getCachedPreferenceById = getCachedPreferenceById;
|
|
38
|
+
var invalidatePreferencesCache = function () {
|
|
39
|
+
return (0, util_functions_1.invalidateCache)(constants_1.LS_KEYS.PREFERENCES);
|
|
40
|
+
};
|
|
41
|
+
exports.invalidatePreferencesCache = invalidatePreferencesCache;
|
|
42
|
+
var preloadPreferences = function () {
|
|
43
|
+
return (0, util_functions_1.preloadCache)(PREFERENCE_CACHE_CONFIG);
|
|
44
|
+
};
|
|
45
|
+
exports.preloadPreferences = preloadPreferences;
|
|
46
|
+
var isPreferencesCacheStale = function () { return (0, util_functions_1.isCacheStale)(constants_1.LS_KEYS.PREFERENCES); };
|
|
47
|
+
exports.isPreferencesCacheStale = isPreferencesCacheStale;
|
|
@@ -84,6 +84,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
84
84
|
exports.usePreferenceStateContext = exports.PreferenceStateContextProvider = exports.PreferenceStateContext = void 0;
|
|
85
85
|
var react_1 = __importStar(require("react"));
|
|
86
86
|
var util_functions_1 = require("@react-pakistan/util-functions");
|
|
87
|
+
var cache_1 = require("./cache");
|
|
87
88
|
var next_intl_1 = require("next-intl");
|
|
88
89
|
var actions_1 = require("./actions");
|
|
89
90
|
var constants_1 = require("./constants");
|
|
@@ -135,7 +136,7 @@ var usePreferenceState = function () {
|
|
|
135
136
|
if (data) {
|
|
136
137
|
(0, toast_utils_1.showSuccessToast)(t("messagesPreferenceUpdated"));
|
|
137
138
|
// Invalidate cache to force fresh data on next fetch
|
|
138
|
-
(0,
|
|
139
|
+
(0, cache_1.invalidatePreferencesCache)();
|
|
139
140
|
dispatch({
|
|
140
141
|
type: actions_1.PREFERENCE_ACTION_TYPES.RESET_FORM,
|
|
141
142
|
});
|
|
@@ -175,7 +176,7 @@ var usePreferenceState = function () {
|
|
|
175
176
|
if (data) {
|
|
176
177
|
(0, toast_utils_1.showSuccessToast)(t("messagesPreferenceDeleted"));
|
|
177
178
|
// Invalidate cache to force fresh data on next fetch
|
|
178
|
-
(0,
|
|
179
|
+
(0, cache_1.invalidatePreferencesCache)();
|
|
179
180
|
dispatch({
|
|
180
181
|
type: actions_1.PREFERENCE_ACTION_TYPES.RESET_FORM,
|
|
181
182
|
});
|
|
@@ -280,7 +281,7 @@ var usePreferenceState = function () {
|
|
|
280
281
|
if (data) {
|
|
281
282
|
(0, toast_utils_1.showSuccessToast)(t("messagesPreferenceDeleted"));
|
|
282
283
|
// Invalidate cache to force fresh data on next fetch
|
|
283
|
-
(0,
|
|
284
|
+
(0, cache_1.invalidatePreferencesCache)();
|
|
284
285
|
dispatch({
|
|
285
286
|
type: actions_1.PREFERENCE_ACTION_TYPES.RESET_FORM,
|
|
286
287
|
});
|
|
@@ -323,7 +324,7 @@ var usePreferenceState = function () {
|
|
|
323
324
|
switch (_a.label) {
|
|
324
325
|
case 0:
|
|
325
326
|
_a.trys.push([0, 2, , 3]);
|
|
326
|
-
return [4 /*yield*/, (0,
|
|
327
|
+
return [4 /*yield*/, (0, cache_1.getCachedPreferences)()];
|
|
327
328
|
case 1:
|
|
328
329
|
cachedData = _a.sent();
|
|
329
330
|
if (cachedData === null || cachedData === void 0 ? void 0 : cachedData.items) {
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Attendance Module Cache Utilities
|
|
3
|
+
*
|
|
4
|
+
* Provides localStorage-based caching for attendances using generic cache system.
|
|
5
|
+
*/
|
|
6
|
+
import { TaxTypeBE } from "./types";
|
|
7
|
+
export declare const getCachedTaxesSync: () => {
|
|
8
|
+
count: number;
|
|
9
|
+
items: TaxTypeBE[];
|
|
10
|
+
};
|
|
11
|
+
export declare const getCachedTaxes: ({ params, }?: {
|
|
12
|
+
params?: Record<string, unknown>;
|
|
13
|
+
}) => Promise<{
|
|
14
|
+
count: number;
|
|
15
|
+
items: TaxTypeBE[];
|
|
16
|
+
}>;
|
|
17
|
+
export declare const getCachedTaxById: (taxId: string) => TaxTypeBE | null;
|
|
18
|
+
export declare const invalidateTaxesCache: () => void;
|
|
19
|
+
export declare const preloadTaxes: () => Promise<{
|
|
20
|
+
count: number;
|
|
21
|
+
items: TaxTypeBE[];
|
|
22
|
+
}>;
|
|
23
|
+
export declare const isTaxesCacheStale: () => boolean;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Attendance Module Cache Utilities
|
|
4
|
+
*
|
|
5
|
+
* Provides localStorage-based caching for attendances using generic cache system.
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.isTaxesCacheStale = exports.preloadTaxes = exports.invalidateTaxesCache = exports.getCachedTaxById = exports.getCachedTaxes = exports.getCachedTaxesSync = void 0;
|
|
9
|
+
var constants_1 = require("@/constants");
|
|
10
|
+
var constants_2 = require("./constants");
|
|
11
|
+
var util_functions_1 = require("@react-pakistan/util-functions");
|
|
12
|
+
// ============================================================================
|
|
13
|
+
// CACHE CONFIGURATION
|
|
14
|
+
// ============================================================================
|
|
15
|
+
var TAX_CACHE_CONFIG = {
|
|
16
|
+
cacheKey: constants_1.LS_KEYS.TAXES,
|
|
17
|
+
apiUrl: constants_2.TAX_API_ROUTES.TAXES,
|
|
18
|
+
};
|
|
19
|
+
// ============================================================================
|
|
20
|
+
// ATTENDANCE-SPECIFIC CACHE FUNCTIONS
|
|
21
|
+
// ============================================================================
|
|
22
|
+
var getCachedTaxesSync = function () {
|
|
23
|
+
return (0, util_functions_1.getCachedDataSync)(constants_1.LS_KEYS.TAXES);
|
|
24
|
+
};
|
|
25
|
+
exports.getCachedTaxesSync = getCachedTaxesSync;
|
|
26
|
+
var getCachedTaxes = function (_a) {
|
|
27
|
+
var _b = _a === void 0 ? {} : _a, params = _b.params;
|
|
28
|
+
return (0, util_functions_1.getCachedData)({
|
|
29
|
+
config: TAX_CACHE_CONFIG,
|
|
30
|
+
params: params,
|
|
31
|
+
});
|
|
32
|
+
};
|
|
33
|
+
exports.getCachedTaxes = getCachedTaxes;
|
|
34
|
+
var getCachedTaxById = function (taxId) {
|
|
35
|
+
return (0, util_functions_1.getCachedItemById)(constants_1.LS_KEYS.TAXES, taxId);
|
|
36
|
+
};
|
|
37
|
+
exports.getCachedTaxById = getCachedTaxById;
|
|
38
|
+
var invalidateTaxesCache = function () { return (0, util_functions_1.invalidateCache)(constants_1.LS_KEYS.TAXES); };
|
|
39
|
+
exports.invalidateTaxesCache = invalidateTaxesCache;
|
|
40
|
+
var preloadTaxes = function () {
|
|
41
|
+
return (0, util_functions_1.preloadCache)(TAX_CACHE_CONFIG);
|
|
42
|
+
};
|
|
43
|
+
exports.preloadTaxes = preloadTaxes;
|
|
44
|
+
var isTaxesCacheStale = function () { return (0, util_functions_1.isCacheStale)(constants_1.LS_KEYS.TAXES); };
|
|
45
|
+
exports.isTaxesCacheStale = isTaxesCacheStale;
|
|
@@ -124,6 +124,7 @@ var types_1 = require("./types");
|
|
|
124
124
|
var toast_utils_1 = require("@appcorp/shadcn/lib/toast-utils");
|
|
125
125
|
var validate_1 = require("./validate");
|
|
126
126
|
var context_1 = require("../preferences/context");
|
|
127
|
+
var cache_1 = require("./cache");
|
|
127
128
|
// ============================================================================
|
|
128
129
|
// MAIN HOOK
|
|
129
130
|
// ============================================================================
|
|
@@ -207,7 +208,7 @@ var useTaxState = function () {
|
|
|
207
208
|
if (data) {
|
|
208
209
|
showSuccessToast(t("messagesTaxUpdated"));
|
|
209
210
|
// Invalidate cache to force fresh data on next fetch
|
|
210
|
-
(0,
|
|
211
|
+
(0, cache_1.invalidateTaxesCache)();
|
|
211
212
|
dispatch({
|
|
212
213
|
type: actions_1.TAX_ACTION_TYPES.RESET_FORM,
|
|
213
214
|
});
|
|
@@ -246,7 +247,7 @@ var useTaxState = function () {
|
|
|
246
247
|
if (data) {
|
|
247
248
|
showSuccessToast(t("messagesTaxDeleted"));
|
|
248
249
|
// Invalidate cache to force fresh data on next fetch
|
|
249
|
-
(0,
|
|
250
|
+
(0, cache_1.invalidateTaxesCache)();
|
|
250
251
|
dispatch({
|
|
251
252
|
type: actions_1.TAX_ACTION_TYPES.RESET_FORM,
|
|
252
253
|
});
|
|
@@ -273,6 +274,22 @@ var useTaxState = function () {
|
|
|
273
274
|
// ---------------------------------------------------------------------------
|
|
274
275
|
// EFFECTS
|
|
275
276
|
// ---------------------------------------------------------------------------
|
|
277
|
+
// useEffect(() => {
|
|
278
|
+
// if (!workspace?.id) return;
|
|
279
|
+
// (async () => {
|
|
280
|
+
// try {
|
|
281
|
+
// const { count, items } = await getCachedAttendances({
|
|
282
|
+
// params: listParams,
|
|
283
|
+
// });
|
|
284
|
+
// dispatch({
|
|
285
|
+
// type: ATTENDANCE_ACTION_TYPES.SET_ATTENDANCES,
|
|
286
|
+
// payload: { attendances: items, count },
|
|
287
|
+
// });
|
|
288
|
+
// } catch {
|
|
289
|
+
// toastNetworkError();
|
|
290
|
+
// }
|
|
291
|
+
// })();
|
|
292
|
+
// }, [listParams, toastNetworkError, workspace?.id]);
|
|
276
293
|
/**
|
|
277
294
|
* Cache loading effect
|
|
278
295
|
*
|
|
@@ -293,49 +310,33 @@ var useTaxState = function () {
|
|
|
293
310
|
*/
|
|
294
311
|
(0, react_1.useEffect)(function () {
|
|
295
312
|
(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
296
|
-
var
|
|
297
|
-
return __generator(this, function (
|
|
298
|
-
switch (
|
|
313
|
+
var _a, count, items, error_1;
|
|
314
|
+
return __generator(this, function (_b) {
|
|
315
|
+
switch (_b.label) {
|
|
299
316
|
case 0:
|
|
300
|
-
|
|
301
|
-
return [4 /*yield*/, (0,
|
|
317
|
+
_b.trys.push([0, 2, , 3]);
|
|
318
|
+
return [4 /*yield*/, (0, cache_1.getCachedTaxes)({
|
|
319
|
+
params: listParams,
|
|
320
|
+
})];
|
|
302
321
|
case 1:
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
((_c = tax.description) === null || _c === void 0 ? void 0 : _c.toLowerCase().includes(query_1));
|
|
313
|
-
});
|
|
314
|
-
}
|
|
315
|
-
startIndex = (state.currentPage - 1) * state.pageLimit;
|
|
316
|
-
endIndex = startIndex + state.pageLimit;
|
|
317
|
-
paginatedItems = filteredItems.slice(startIndex, endIndex);
|
|
318
|
-
dispatch({
|
|
319
|
-
type: actions_1.TAX_ACTION_TYPES.SET_TAXES,
|
|
320
|
-
payload: { taxes: paginatedItems },
|
|
321
|
-
});
|
|
322
|
-
dispatch({
|
|
323
|
-
type: actions_1.TAX_ACTION_TYPES.SET_COUNT,
|
|
324
|
-
payload: { count: filteredItems.length },
|
|
325
|
-
});
|
|
326
|
-
}
|
|
322
|
+
_a = _b.sent(), count = _a.count, items = _a.items;
|
|
323
|
+
dispatch({
|
|
324
|
+
type: actions_1.TAX_ACTION_TYPES.SET_TAXES,
|
|
325
|
+
payload: { taxes: items },
|
|
326
|
+
});
|
|
327
|
+
dispatch({
|
|
328
|
+
type: actions_1.TAX_ACTION_TYPES.SET_COUNT,
|
|
329
|
+
payload: { count: count },
|
|
330
|
+
});
|
|
327
331
|
return [3 /*break*/, 3];
|
|
328
332
|
case 2:
|
|
329
|
-
error_1 =
|
|
330
|
-
console.error("Error loading taxes from cache:", error_1);
|
|
331
|
-
showErrorToast(tCommon("messagesNetworkError"));
|
|
333
|
+
error_1 = _b.sent();
|
|
332
334
|
return [3 /*break*/, 3];
|
|
333
335
|
case 3: return [2 /*return*/];
|
|
334
336
|
}
|
|
335
337
|
});
|
|
336
338
|
}); })();
|
|
337
|
-
|
|
338
|
-
}, [debouncedQuery, state.currentPage, state.pageLimit]);
|
|
339
|
+
}, [listParams]);
|
|
339
340
|
// ---------------------------------------------------------------------------
|
|
340
341
|
// DRAWER & MODAL HANDLERS
|
|
341
342
|
// ---------------------------------------------------------------------------
|
package/i18n/routing.d.ts
CHANGED
|
@@ -6,8 +6,8 @@ export declare const routing: {
|
|
|
6
6
|
localeCookie?: boolean | {
|
|
7
7
|
name?: string | undefined;
|
|
8
8
|
path?: string | undefined | undefined;
|
|
9
|
-
maxAge?: number | undefined | undefined;
|
|
10
9
|
priority?: "low" | "medium" | "high" | undefined | undefined;
|
|
10
|
+
maxAge?: number | undefined | undefined;
|
|
11
11
|
domain?: string | undefined | undefined;
|
|
12
12
|
secure?: boolean | undefined | undefined;
|
|
13
13
|
sameSite?: true | false | "lax" | "strict" | "none" | undefined | undefined;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@appcorp/stellar-solutions-modules",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.70",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"automate": "./automate.sh",
|
|
6
6
|
"build": "yarn clean && yarn build:ts && cp package.json lib && cp README.md lib && cp yarn.lock lib",
|
|
@@ -19,8 +19,8 @@
|
|
|
19
19
|
"upgrade:own": "ncu -f '@appcorp/app-corp-vista, @appcorp/shadcn, @react-pakistan/util-functions' -u"
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
22
|
-
"@appcorp/app-corp-vista": "^0.3.
|
|
23
|
-
"@appcorp/shadcn": "^1.1.
|
|
22
|
+
"@appcorp/app-corp-vista": "^0.3.89",
|
|
23
|
+
"@appcorp/shadcn": "^1.1.31",
|
|
24
24
|
"@dnd-kit/core": "^6.3.1",
|
|
25
25
|
"@dnd-kit/modifiers": "^9.0.0",
|
|
26
26
|
"@eslint/eslintrc": "^3",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"@radix-ui/react-separator": "^1.1.7",
|
|
36
36
|
"@radix-ui/react-slot": "^1.2.3",
|
|
37
37
|
"@radix-ui/react-switch": "^1.2.6",
|
|
38
|
-
"@react-pakistan/util-functions": "^1.25.
|
|
38
|
+
"@react-pakistan/util-functions": "^1.25.18",
|
|
39
39
|
"@supabase/supabase-js": "^2",
|
|
40
40
|
"@tailwindcss/forms": "^0",
|
|
41
41
|
"@tailwindcss/postcss": "^4",
|
|
@@ -54,14 +54,14 @@
|
|
|
54
54
|
"dayjs": "^1",
|
|
55
55
|
"embla-carousel-react": "^8.6.0",
|
|
56
56
|
"eslint": "^9",
|
|
57
|
-
"eslint-config-next": "^
|
|
57
|
+
"eslint-config-next": "^16",
|
|
58
58
|
"husky": "^9",
|
|
59
59
|
"jotai": "^2.15.0",
|
|
60
60
|
"libphonenumber-js": "^1",
|
|
61
61
|
"lodash.throttle": "^4.1.1",
|
|
62
62
|
"lucide-react": "^0.545.0",
|
|
63
63
|
"motion": "^12.23.22",
|
|
64
|
-
"next": "^
|
|
64
|
+
"next": "^16",
|
|
65
65
|
"next-intl": "^4",
|
|
66
66
|
"next-themes": "^0.4.6",
|
|
67
67
|
"radix-ui": "^1.4.3",
|