@appcorp/fusion-storybook 0.1.18 → 0.1.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/base-modules/discount-code/context.d.ts +19 -19
- package/base-modules/discount-code/context.js +62 -58
- package/base-modules/discount-code/page.d.ts +17 -2
- package/base-modules/discount-code/page.js +55 -34
- package/base-modules/family/context.d.ts +21 -21
- package/base-modules/family/context.js +69 -65
- package/base-modules/family/page.d.ts +17 -2
- package/base-modules/family/page.js +57 -36
- package/base-modules/family-member/context.js +38 -37
- package/base-modules/family-member/page.d.ts +18 -2
- package/base-modules/family-member/page.js +58 -35
- package/base-modules/student-profile/context.js +44 -43
- package/base-modules/student-profile/page.d.ts +19 -1
- package/base-modules/student-profile/page.js +50 -28
- package/base-modules/workspace/context.d.ts +11 -8
- package/base-modules/workspace/context.js +86 -82
- package/base-modules/workspace/page.d.ts +19 -1
- package/base-modules/workspace/page.js +3 -10
- package/base-modules/workspace/view.js +8 -7
- package/package.json +1 -1
- package/tsconfig.build.tsbuildinfo +1 -1
|
@@ -107,6 +107,25 @@ export declare const DISCOUNT_CODE_ACTION_TYPES: {
|
|
|
107
107
|
id: string;
|
|
108
108
|
}>;
|
|
109
109
|
export declare const useDiscountCodeModule: () => {
|
|
110
|
+
state: {
|
|
111
|
+
items: DiscountCodeBE[];
|
|
112
|
+
count: number;
|
|
113
|
+
currentPage: number;
|
|
114
|
+
pageLimit: number;
|
|
115
|
+
searchQuery: string;
|
|
116
|
+
disableSaveButton: boolean;
|
|
117
|
+
drawer: null;
|
|
118
|
+
modal: null;
|
|
119
|
+
code: string;
|
|
120
|
+
description: string;
|
|
121
|
+
discountType: string;
|
|
122
|
+
discountValue: number;
|
|
123
|
+
enabled: boolean;
|
|
124
|
+
errors: Record<string, string>;
|
|
125
|
+
filterEnabled: boolean | undefined;
|
|
126
|
+
id: string;
|
|
127
|
+
};
|
|
128
|
+
dispatch: import("react").Dispatch<any>;
|
|
110
129
|
applyFilters: () => void;
|
|
111
130
|
byIdLoading: boolean;
|
|
112
131
|
clearFilters: () => void;
|
|
@@ -132,23 +151,4 @@ export declare const useDiscountCodeModule: () => {
|
|
|
132
151
|
listLoading: boolean;
|
|
133
152
|
rowActions: RowAction[];
|
|
134
153
|
updateLoading: boolean;
|
|
135
|
-
state: {
|
|
136
|
-
items: DiscountCodeBE[];
|
|
137
|
-
count: number;
|
|
138
|
-
currentPage: number;
|
|
139
|
-
pageLimit: number;
|
|
140
|
-
searchQuery: string;
|
|
141
|
-
disableSaveButton: boolean;
|
|
142
|
-
drawer: null;
|
|
143
|
-
modal: null;
|
|
144
|
-
code: string;
|
|
145
|
-
description: string;
|
|
146
|
-
discountType: string;
|
|
147
|
-
discountValue: number;
|
|
148
|
-
enabled: boolean;
|
|
149
|
-
errors: Record<string, string>;
|
|
150
|
-
filterEnabled: boolean | undefined;
|
|
151
|
-
id: string;
|
|
152
|
-
};
|
|
153
|
-
dispatch: React.Dispatch<any>;
|
|
154
154
|
};
|
|
@@ -76,42 +76,42 @@ export const { actionTypes: DISCOUNT_CODE_ACTION_TYPES, config: discountCodeModu
|
|
|
76
76
|
// ============================================================================
|
|
77
77
|
export const useDiscountCodeModule = () => {
|
|
78
78
|
var _a;
|
|
79
|
-
const
|
|
79
|
+
const { state, dispatch } = useDiscountCodeStateContext();
|
|
80
80
|
const t = useTranslations("discountCode");
|
|
81
81
|
const workspace = getCachedWorkspaceSync();
|
|
82
82
|
const schoolId = ((_a = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _a === void 0 ? void 0 : _a.id) || "";
|
|
83
|
-
const debouncedQuery = useDebounce(
|
|
83
|
+
const debouncedQuery = useDebounce(state.searchQuery, 800);
|
|
84
84
|
// ============================================================================
|
|
85
85
|
// API PARAMETERS
|
|
86
86
|
// ============================================================================
|
|
87
|
-
const listParams = useMemo(() => (Object.assign(Object.assign({ currentPage:
|
|
88
|
-
? { filterEnabled: String(
|
|
87
|
+
const listParams = useMemo(() => (Object.assign(Object.assign({ currentPage: state.currentPage, pageLimit: state.pageLimit, schoolId }, (debouncedQuery ? { searchQuery: debouncedQuery } : {})), (state.filterEnabled !== undefined
|
|
88
|
+
? { filterEnabled: String(state.filterEnabled) }
|
|
89
89
|
: {}))), [
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
90
|
+
state.currentPage,
|
|
91
|
+
state.pageLimit,
|
|
92
|
+
state.filterEnabled,
|
|
93
93
|
debouncedQuery,
|
|
94
94
|
schoolId,
|
|
95
95
|
]);
|
|
96
96
|
const updateParams = useMemo(() => ({
|
|
97
|
-
code:
|
|
98
|
-
description:
|
|
99
|
-
discountType:
|
|
100
|
-
discountValue:
|
|
101
|
-
enabled:
|
|
102
|
-
id:
|
|
97
|
+
code: state.code,
|
|
98
|
+
description: state.description,
|
|
99
|
+
discountType: state.discountType,
|
|
100
|
+
discountValue: state.discountValue,
|
|
101
|
+
enabled: state.enabled,
|
|
102
|
+
id: state.id,
|
|
103
103
|
schoolId,
|
|
104
104
|
}), [
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
105
|
+
state.code,
|
|
106
|
+
state.description,
|
|
107
|
+
state.discountType,
|
|
108
|
+
state.discountValue,
|
|
109
|
+
state.enabled,
|
|
110
|
+
state.id,
|
|
111
111
|
schoolId,
|
|
112
112
|
]);
|
|
113
|
-
const byIdParams = useMemo(() => ({ id:
|
|
114
|
-
const deleteParams = useMemo(() => ({ id:
|
|
113
|
+
const byIdParams = useMemo(() => ({ id: state.id }), [state.id]);
|
|
114
|
+
const deleteParams = useMemo(() => ({ id: state.id }), [state.id]);
|
|
115
115
|
// ============================================================================
|
|
116
116
|
// API CALLBACKS
|
|
117
117
|
// ============================================================================
|
|
@@ -121,7 +121,7 @@ export const useDiscountCodeModule = () => {
|
|
|
121
121
|
return;
|
|
122
122
|
}
|
|
123
123
|
if (data) {
|
|
124
|
-
|
|
124
|
+
dispatch({
|
|
125
125
|
type: DISCOUNT_CODE_ACTION_TYPES.SET_ITEMS,
|
|
126
126
|
payload: { items: data.items || [], count: data.count || 0 },
|
|
127
127
|
});
|
|
@@ -200,62 +200,62 @@ export const useDiscountCodeModule = () => {
|
|
|
200
200
|
generateThemeToast({ description: message, variant });
|
|
201
201
|
}, []);
|
|
202
202
|
const resetFormAndCloseDrawer = useCallback(() => {
|
|
203
|
-
|
|
203
|
+
dispatch({
|
|
204
204
|
type: DISCOUNT_CODE_ACTION_TYPES.SET_ERRORS,
|
|
205
205
|
payload: { errors: {} },
|
|
206
206
|
});
|
|
207
|
-
|
|
207
|
+
dispatch({
|
|
208
208
|
type: DISCOUNT_CODE_ACTION_TYPES.SET_DISABLE_SAVE_BUTTON,
|
|
209
209
|
payload: { disabled: false },
|
|
210
210
|
});
|
|
211
|
-
|
|
211
|
+
dispatch({
|
|
212
212
|
type: DISCOUNT_CODE_ACTION_TYPES.SET_DRAWER,
|
|
213
213
|
payload: { drawer: null },
|
|
214
214
|
});
|
|
215
|
-
}, [
|
|
215
|
+
}, [dispatch]);
|
|
216
216
|
const setField = useCallback((key, value) => {
|
|
217
|
-
|
|
217
|
+
dispatch({
|
|
218
218
|
type: DISCOUNT_CODE_ACTION_TYPES.SET_INPUT_FIELD,
|
|
219
219
|
payload: { field: key, value },
|
|
220
220
|
});
|
|
221
|
-
}, [
|
|
221
|
+
}, [dispatch]);
|
|
222
222
|
// ============================================================================
|
|
223
223
|
// HANDLERS
|
|
224
224
|
// ============================================================================
|
|
225
225
|
const handleChange = useCallback((field, value) => {
|
|
226
|
-
|
|
226
|
+
dispatch({
|
|
227
227
|
type: DISCOUNT_CODE_ACTION_TYPES.SET_ERRORS,
|
|
228
228
|
payload: { errors: {} },
|
|
229
229
|
});
|
|
230
|
-
|
|
230
|
+
dispatch({
|
|
231
231
|
type: DISCOUNT_CODE_ACTION_TYPES.SET_DISABLE_SAVE_BUTTON,
|
|
232
232
|
payload: { disabled: false },
|
|
233
233
|
});
|
|
234
234
|
setField(field, value);
|
|
235
|
-
}, [setField,
|
|
235
|
+
}, [setField, dispatch]);
|
|
236
236
|
const handleCloseDrawer = useCallback(() => {
|
|
237
237
|
resetFormAndCloseDrawer();
|
|
238
238
|
}, [resetFormAndCloseDrawer]);
|
|
239
239
|
const handleCreate = useCallback(() => {
|
|
240
|
-
|
|
240
|
+
dispatch({
|
|
241
241
|
type: DISCOUNT_CODE_ACTION_TYPES.SET_DRAWER,
|
|
242
242
|
payload: { drawer: DISCOUNT_CODE_DRAWER.FORM_DRAWER },
|
|
243
243
|
});
|
|
244
|
-
}, [
|
|
244
|
+
}, [dispatch]);
|
|
245
245
|
const handleView = useCallback((row) => {
|
|
246
246
|
byIdFetchNow === null || byIdFetchNow === void 0 ? void 0 : byIdFetchNow(undefined, { params: { id: row === null || row === void 0 ? void 0 : row.id } });
|
|
247
|
-
|
|
247
|
+
dispatch({
|
|
248
248
|
type: DISCOUNT_CODE_ACTION_TYPES.SET_DRAWER,
|
|
249
249
|
payload: { drawer: DISCOUNT_CODE_DRAWER.VIEW_DRAWER },
|
|
250
250
|
});
|
|
251
|
-
}, [
|
|
251
|
+
}, [byIdFetchNow, dispatch]);
|
|
252
252
|
const handleEdit = useCallback((row) => {
|
|
253
253
|
byIdFetchNow === null || byIdFetchNow === void 0 ? void 0 : byIdFetchNow(undefined, { params: { id: row === null || row === void 0 ? void 0 : row.id } });
|
|
254
|
-
|
|
254
|
+
dispatch({
|
|
255
255
|
type: DISCOUNT_CODE_ACTION_TYPES.SET_DRAWER,
|
|
256
256
|
payload: { drawer: DISCOUNT_CODE_DRAWER.FORM_DRAWER },
|
|
257
257
|
});
|
|
258
|
-
}, [
|
|
258
|
+
}, [byIdFetchNow, dispatch]);
|
|
259
259
|
const handleDelete = useCallback((row) => {
|
|
260
260
|
if (confirm(t("confirmDelete"))) {
|
|
261
261
|
deleteFetchNow === null || deleteFetchNow === void 0 ? void 0 : deleteFetchNow(undefined, {
|
|
@@ -264,41 +264,41 @@ export const useDiscountCodeModule = () => {
|
|
|
264
264
|
}
|
|
265
265
|
}, [t, deleteFetchNow]);
|
|
266
266
|
const handleFilters = useCallback(() => {
|
|
267
|
-
|
|
267
|
+
dispatch({
|
|
268
268
|
type: DISCOUNT_CODE_ACTION_TYPES.SET_DRAWER,
|
|
269
269
|
payload: { drawer: DISCOUNT_CODE_DRAWER.FILTER_DRAWER },
|
|
270
270
|
});
|
|
271
|
-
}, [
|
|
271
|
+
}, [dispatch]);
|
|
272
272
|
const handlePageChange = useCallback((page) => {
|
|
273
|
-
|
|
273
|
+
dispatch({
|
|
274
274
|
type: DISCOUNT_CODE_ACTION_TYPES.SET_CURRENT_PAGE,
|
|
275
275
|
payload: { currentPage: page },
|
|
276
276
|
});
|
|
277
|
-
}, [
|
|
277
|
+
}, [dispatch]);
|
|
278
278
|
const handlePageLimitChange = useCallback((limit) => {
|
|
279
|
-
|
|
279
|
+
dispatch({
|
|
280
280
|
type: DISCOUNT_CODE_ACTION_TYPES.SET_PAGE_LIMIT,
|
|
281
281
|
payload: { pageLimit: limit },
|
|
282
282
|
});
|
|
283
|
-
}, [
|
|
283
|
+
}, [dispatch]);
|
|
284
284
|
const handleSearch = useCallback((query) => {
|
|
285
|
-
|
|
285
|
+
dispatch({
|
|
286
286
|
type: DISCOUNT_CODE_ACTION_TYPES.SET_SEARCH_QUERY,
|
|
287
287
|
payload: { searchQuery: query },
|
|
288
288
|
});
|
|
289
|
-
}, [
|
|
289
|
+
}, [dispatch]);
|
|
290
290
|
const clearFilters = useCallback(() => {
|
|
291
|
-
|
|
291
|
+
dispatch({
|
|
292
292
|
type: DISCOUNT_CODE_ACTION_TYPES.SET_FILTERS,
|
|
293
293
|
payload: { filters: { filterEnabled: undefined } },
|
|
294
294
|
});
|
|
295
|
-
|
|
295
|
+
dispatch({
|
|
296
296
|
type: DISCOUNT_CODE_ACTION_TYPES.SET_CURRENT_PAGE,
|
|
297
297
|
payload: { currentPage: 1 },
|
|
298
298
|
});
|
|
299
|
-
}, [
|
|
299
|
+
}, [dispatch]);
|
|
300
300
|
const handleSubmit = useCallback(() => {
|
|
301
|
-
|
|
301
|
+
dispatch({
|
|
302
302
|
type: DISCOUNT_CODE_ACTION_TYPES.SET_DISABLE_SAVE_BUTTON,
|
|
303
303
|
payload: { disabled: true },
|
|
304
304
|
});
|
|
@@ -311,18 +311,18 @@ export const useDiscountCodeModule = () => {
|
|
|
311
311
|
});
|
|
312
312
|
},
|
|
313
313
|
errorCallback: (errors) => {
|
|
314
|
-
|
|
314
|
+
dispatch({
|
|
315
315
|
type: DISCOUNT_CODE_ACTION_TYPES.SET_ERRORS,
|
|
316
316
|
payload: { errors },
|
|
317
317
|
});
|
|
318
|
-
|
|
318
|
+
dispatch({
|
|
319
319
|
type: DISCOUNT_CODE_ACTION_TYPES.SET_DISABLE_SAVE_BUTTON,
|
|
320
320
|
payload: { disabled: false },
|
|
321
321
|
});
|
|
322
322
|
showToast(t("messagesFormErrors"), TOAST_VARIANT.ERROR);
|
|
323
323
|
},
|
|
324
324
|
});
|
|
325
|
-
}, [
|
|
325
|
+
}, [dispatch, updateParams, t, showToast, updateFetchNow]);
|
|
326
326
|
// ============================================================================
|
|
327
327
|
// HEADER & ROW ACTIONS
|
|
328
328
|
// ============================================================================
|
|
@@ -363,13 +363,13 @@ export const useDiscountCodeModule = () => {
|
|
|
363
363
|
},
|
|
364
364
|
], [handleView, handleEdit, handleDelete, t]);
|
|
365
365
|
const applyFilters = useCallback(() => {
|
|
366
|
-
|
|
366
|
+
dispatch({
|
|
367
367
|
type: DISCOUNT_CODE_ACTION_TYPES.SET_CURRENT_PAGE,
|
|
368
368
|
payload: { currentPage: 1 },
|
|
369
369
|
});
|
|
370
370
|
listFetchNow();
|
|
371
371
|
handleCloseDrawer();
|
|
372
|
-
}, [
|
|
372
|
+
}, [dispatch, listFetchNow, handleCloseDrawer]);
|
|
373
373
|
// ============================================================================
|
|
374
374
|
// EFFECTS
|
|
375
375
|
// ============================================================================
|
|
@@ -381,7 +381,7 @@ export const useDiscountCodeModule = () => {
|
|
|
381
381
|
const { count, items } = await getCachedDiscountCodes({
|
|
382
382
|
params: listParams,
|
|
383
383
|
});
|
|
384
|
-
|
|
384
|
+
dispatch({
|
|
385
385
|
type: DISCOUNT_CODE_ACTION_TYPES.SET_ITEMS,
|
|
386
386
|
payload: { items: items || [], count: count || 0 },
|
|
387
387
|
});
|
|
@@ -390,11 +390,14 @@ export const useDiscountCodeModule = () => {
|
|
|
390
390
|
showToast(t("messagesFetchFailed"), TOAST_VARIANT.ERROR);
|
|
391
391
|
}
|
|
392
392
|
})();
|
|
393
|
-
}, [listParams, showToast, t, workspace === null || workspace === void 0 ? void 0 : workspace.id,
|
|
393
|
+
}, [listParams, showToast, t, workspace === null || workspace === void 0 ? void 0 : workspace.id, dispatch]);
|
|
394
394
|
// ============================================================================
|
|
395
395
|
// RETURN
|
|
396
396
|
// ============================================================================
|
|
397
|
-
return
|
|
397
|
+
return {
|
|
398
|
+
state,
|
|
399
|
+
dispatch,
|
|
400
|
+
applyFilters,
|
|
398
401
|
byIdLoading,
|
|
399
402
|
clearFilters,
|
|
400
403
|
deleteLoading,
|
|
@@ -412,5 +415,6 @@ export const useDiscountCodeModule = () => {
|
|
|
412
415
|
headerActions,
|
|
413
416
|
listLoading,
|
|
414
417
|
rowActions,
|
|
415
|
-
updateLoading
|
|
418
|
+
updateLoading,
|
|
419
|
+
};
|
|
416
420
|
};
|
|
@@ -11,6 +11,21 @@
|
|
|
11
11
|
*/
|
|
12
12
|
import { FC } from "react";
|
|
13
13
|
import { USER_ROLE } from "@/type";
|
|
14
|
-
|
|
14
|
+
interface Props {
|
|
15
|
+
cancelLabel: string;
|
|
16
|
+
drawerTitle: string;
|
|
17
|
+
labelActions: string;
|
|
18
|
+
labelCode: string;
|
|
19
|
+
labelDescription: string;
|
|
20
|
+
labelDiscountType: string;
|
|
21
|
+
labelDiscountValue: string;
|
|
22
|
+
labelEnabled: string;
|
|
23
|
+
labelId: string;
|
|
24
|
+
saveLabel: string;
|
|
25
|
+
searchPlaceholder: string;
|
|
26
|
+
tableDescription: string;
|
|
27
|
+
tableTitle: string;
|
|
15
28
|
userRole: USER_ROLE;
|
|
16
|
-
}
|
|
29
|
+
}
|
|
30
|
+
export declare const DiscountCodePage: FC<Props>;
|
|
31
|
+
export {};
|
|
@@ -19,10 +19,8 @@ import { DiscountCodeFilter } from "./filter";
|
|
|
19
19
|
import { DiscountCodeForm } from "./form";
|
|
20
20
|
import { DiscountCodeMoreActions } from "./more-actions";
|
|
21
21
|
import { DiscountCodeView } from "./view";
|
|
22
|
-
// import { useAuthStateContext } from "@/contexts/auth-context";
|
|
23
22
|
import { resolveRbacPermissions } from "@/utils/resolve-rbac-permissions";
|
|
24
23
|
import { RbacNoAccess } from "@/components/rbac-no-access";
|
|
25
|
-
import { useTranslations } from "next-intl";
|
|
26
24
|
// ============================================================================
|
|
27
25
|
// TABLE COLUMN CONFIGURATION (static — no runtime deps)
|
|
28
26
|
// ============================================================================
|
|
@@ -35,19 +33,6 @@ const tableBodyCols = [
|
|
|
35
33
|
{ componentType: COMPONENT_TYPE.BOOLEAN, key: "enabled" },
|
|
36
34
|
{ componentType: COMPONENT_TYPE.ACTIONS },
|
|
37
35
|
];
|
|
38
|
-
const tableColumns = [
|
|
39
|
-
{ label: "id", width: "5%" },
|
|
40
|
-
{ label: "code", width: "15%" },
|
|
41
|
-
{ label: "description", width: "25%" },
|
|
42
|
-
{ label: "discountType", width: "15%" },
|
|
43
|
-
{ label: "discountValue", width: "15%" },
|
|
44
|
-
{ label: "status", width: "15%" },
|
|
45
|
-
{ label: "actions", width: "10%" },
|
|
46
|
-
];
|
|
47
|
-
// ============================================================================
|
|
48
|
-
// TRANSLATED COLUMNS HELPER
|
|
49
|
-
// ============================================================================
|
|
50
|
-
const getTranslatedColumns = (t) => tableColumns.map((col) => (Object.assign(Object.assign({}, col), { label: t(col.label) })));
|
|
51
36
|
// ============================================================================
|
|
52
37
|
// COMPONENT FACTORY (creates JSX elements when config is created, not during render)
|
|
53
38
|
// ============================================================================
|
|
@@ -57,23 +42,28 @@ const createComponentInstances = () => ({
|
|
|
57
42
|
moreActions: _jsx(DiscountCodeMoreActions, {}),
|
|
58
43
|
view: _jsx(DiscountCodeView, {}),
|
|
59
44
|
});
|
|
60
|
-
|
|
61
|
-
// CONFIG CREATION HELPER
|
|
62
|
-
// ============================================================================
|
|
63
|
-
const createDiscountCodeConfig = (t, drawer, dispatch) => {
|
|
45
|
+
const createDiscountCodeConfig = ({ cancelLabel, drawer, dispatch, drawerTitle, labelActions, labelCode, labelDescription, labelDiscountType, labelDiscountValue, labelEnabled, labelId, saveLabel, searchPlaceholder, tableDescription, tableTitle, }) => {
|
|
64
46
|
const components = createComponentInstances();
|
|
65
47
|
return {
|
|
66
48
|
moduleName: "discountCode",
|
|
67
|
-
tableColumns:
|
|
68
|
-
|
|
69
|
-
|
|
49
|
+
tableColumns: [
|
|
50
|
+
{ label: labelId, width: "5%" },
|
|
51
|
+
{ label: labelCode, width: "15%" },
|
|
52
|
+
{ label: labelDescription, width: "25%" },
|
|
53
|
+
{ label: labelDiscountType, width: "15%" },
|
|
54
|
+
{ label: labelDiscountValue, width: "15%" },
|
|
55
|
+
{ label: labelEnabled, width: "15%" },
|
|
56
|
+
{ label: labelActions, width: "10%" },
|
|
57
|
+
],
|
|
58
|
+
cancelLabel,
|
|
59
|
+
drawerTitle,
|
|
70
60
|
filterContent: components.filter,
|
|
71
61
|
formContent: components.form,
|
|
72
62
|
moreActionsContent: components.moreActions,
|
|
73
|
-
saveLabel
|
|
74
|
-
searchPlaceholder
|
|
75
|
-
tableDescription
|
|
76
|
-
tableTitle
|
|
63
|
+
saveLabel,
|
|
64
|
+
searchPlaceholder,
|
|
65
|
+
tableDescription,
|
|
66
|
+
tableTitle,
|
|
77
67
|
viewContent: components.view,
|
|
78
68
|
size: drawer === DISCOUNT_CODE_DRAWER.FORM_DRAWER ? "full" : "small",
|
|
79
69
|
onClearFilters: () => {
|
|
@@ -88,18 +78,49 @@ const GenericDiscountCodePage = createGenericModulePage();
|
|
|
88
78
|
// ============================================================================
|
|
89
79
|
// INNER PAGE (requires DiscountCodeProvider context)
|
|
90
80
|
// ============================================================================
|
|
91
|
-
const DiscountCodePageInner = (
|
|
92
|
-
const t = useTranslations("discountCode");
|
|
81
|
+
const DiscountCodePageInner = (props) => {
|
|
93
82
|
const context = useDiscountCodeModule();
|
|
94
|
-
|
|
95
|
-
|
|
83
|
+
// Memoize config creation - destructure props to avoid object reference changes
|
|
84
|
+
const discountCodeConfig = useMemo(() => createDiscountCodeConfig({
|
|
85
|
+
dispatch: context.dispatch,
|
|
86
|
+
drawer: context.state.drawer,
|
|
87
|
+
cancelLabel: props.cancelLabel,
|
|
88
|
+
drawerTitle: props.drawerTitle,
|
|
89
|
+
labelActions: props.labelActions,
|
|
90
|
+
labelCode: props.labelCode,
|
|
91
|
+
labelDescription: props.labelDescription,
|
|
92
|
+
labelDiscountType: props.labelDiscountType,
|
|
93
|
+
labelDiscountValue: props.labelDiscountValue,
|
|
94
|
+
labelEnabled: props.labelEnabled,
|
|
95
|
+
labelId: props.labelId,
|
|
96
|
+
saveLabel: props.saveLabel,
|
|
97
|
+
searchPlaceholder: props.searchPlaceholder,
|
|
98
|
+
tableDescription: props.tableDescription,
|
|
99
|
+
tableTitle: props.tableTitle,
|
|
100
|
+
}), [
|
|
101
|
+
context.dispatch,
|
|
102
|
+
context.state.drawer,
|
|
103
|
+
props.cancelLabel,
|
|
104
|
+
props.drawerTitle,
|
|
105
|
+
props.labelActions,
|
|
106
|
+
props.labelCode,
|
|
107
|
+
props.labelDescription,
|
|
108
|
+
props.labelDiscountType,
|
|
109
|
+
props.labelDiscountValue,
|
|
110
|
+
props.labelEnabled,
|
|
111
|
+
props.labelId,
|
|
112
|
+
props.saveLabel,
|
|
113
|
+
props.searchPlaceholder,
|
|
114
|
+
props.tableDescription,
|
|
115
|
+
props.tableTitle,
|
|
116
|
+
]);
|
|
117
|
+
const hasPermission = resolveRbacPermissions({
|
|
118
|
+
userRole: props.userRole,
|
|
96
119
|
moduleName: "DiscountCode",
|
|
97
|
-
})
|
|
98
|
-
// Memoize config creation
|
|
99
|
-
const discountCodeConfig = useMemo(() => createDiscountCodeConfig(t, context.state.drawer, context.dispatch), [t, context.state.drawer, context.dispatch]);
|
|
120
|
+
});
|
|
100
121
|
if (!hasPermission) {
|
|
101
122
|
return _jsx(RbacNoAccess, { moduleName: "DiscountCode" });
|
|
102
123
|
}
|
|
103
124
|
return (_jsx("div", { className: "p-4", children: _jsx(GenericDiscountCodePage, { overrideConfig: discountCodeConfig, context: context, tableBodyCols: tableBodyCols }) }));
|
|
104
125
|
};
|
|
105
|
-
export const DiscountCodePage = (
|
|
126
|
+
export const DiscountCodePage = (props) => (_jsx(DiscountCodeProvider, { children: _jsx(DiscountCodePageInner, Object.assign({}, props)) }));
|
|
@@ -123,6 +123,27 @@ export declare const FamilyStateContextProvider: import("react").FC<{
|
|
|
123
123
|
children: React.ReactNode;
|
|
124
124
|
}>;
|
|
125
125
|
export declare const useFamilyModule: () => {
|
|
126
|
+
state: {
|
|
127
|
+
items: FamilyBE[];
|
|
128
|
+
count: number;
|
|
129
|
+
currentPage: number;
|
|
130
|
+
pageLimit: number;
|
|
131
|
+
searchQuery: string;
|
|
132
|
+
disableSaveButton: boolean;
|
|
133
|
+
drawer: string | null;
|
|
134
|
+
address: string;
|
|
135
|
+
city: string;
|
|
136
|
+
country: string;
|
|
137
|
+
enabled: boolean;
|
|
138
|
+
errors: Record<string, string>;
|
|
139
|
+
familyCode: string;
|
|
140
|
+
filterEnabled: boolean | undefined;
|
|
141
|
+
id: string;
|
|
142
|
+
postalCode: string;
|
|
143
|
+
stateProvince: string;
|
|
144
|
+
userId: string;
|
|
145
|
+
};
|
|
146
|
+
dispatch: import("react").Dispatch<any>;
|
|
126
147
|
applyFilters: () => void;
|
|
127
148
|
byIdLoading: boolean;
|
|
128
149
|
clearFilters: () => void;
|
|
@@ -149,25 +170,4 @@ export declare const useFamilyModule: () => {
|
|
|
149
170
|
listLoading: boolean;
|
|
150
171
|
rowActions: RowAction[];
|
|
151
172
|
updateLoading: boolean;
|
|
152
|
-
state: {
|
|
153
|
-
items: FamilyBE[];
|
|
154
|
-
count: number;
|
|
155
|
-
currentPage: number;
|
|
156
|
-
pageLimit: number;
|
|
157
|
-
searchQuery: string;
|
|
158
|
-
disableSaveButton: boolean;
|
|
159
|
-
drawer: string | null;
|
|
160
|
-
address: string;
|
|
161
|
-
city: string;
|
|
162
|
-
country: string;
|
|
163
|
-
enabled: boolean;
|
|
164
|
-
errors: Record<string, string>;
|
|
165
|
-
familyCode: string;
|
|
166
|
-
filterEnabled: boolean | undefined;
|
|
167
|
-
id: string;
|
|
168
|
-
postalCode: string;
|
|
169
|
-
stateProvince: string;
|
|
170
|
-
userId: string;
|
|
171
|
-
};
|
|
172
|
-
dispatch: React.Dispatch<any>;
|
|
173
173
|
};
|