@appcorp/fusion-storybook 0.5.17 → 0.5.19
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/family/context.d.ts +13 -9
- package/base-modules/family/context.js +69 -75
- package/base-modules/family/page.js +11 -4
- package/base-modules/family/view.js +3 -2
- package/base-modules/family-member/constants.d.ts +8 -0
- package/base-modules/family-member/constants.js +12 -0
- package/base-modules/family-member/context.d.ts +12 -2
- package/base-modules/family-member/context.js +78 -81
- package/base-modules/family-member/date.d.ts +6 -0
- package/base-modules/family-member/date.js +13 -0
- package/base-modules/family-member/filter.js +1 -1
- package/base-modules/family-member/form.js +25 -2
- package/base-modules/family-member/page.js +12 -4
- package/constants.d.ts +0 -4
- package/constants.js +0 -4
- package/package.json +1 -1
- package/tsconfig.build.tsbuildinfo +1 -1
- package/base-modules/family/more-actions.d.ts +0 -1
- package/base-modules/family/more-actions.js +0 -255
- package/base-modules/family-member/more-actions.d.ts +0 -1
- package/base-modules/family-member/more-actions.js +0 -261
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FamilyBE } from "../../type";
|
|
1
|
+
import { FamilyBE, FamilyMemberBE } from "../../type";
|
|
2
2
|
import { TableRow, type RowAction } from "@appcorp/shadcn/components/enhanced-table";
|
|
3
3
|
export declare const FAMILY_DRAWER: {
|
|
4
4
|
readonly FILTER_DRAWER: string;
|
|
@@ -33,10 +33,11 @@ export declare const FAMILY_ACTION_TYPES: {
|
|
|
33
33
|
errors: Record<string, string>;
|
|
34
34
|
familyCode: string;
|
|
35
35
|
filterEnabled: boolean | undefined;
|
|
36
|
+
appliedFilterEnabled: boolean | undefined;
|
|
36
37
|
id: string;
|
|
38
|
+
members: FamilyMemberBE[];
|
|
37
39
|
postalCode: string;
|
|
38
40
|
stateProvince: string;
|
|
39
|
-
userId: string;
|
|
40
41
|
}>, initialFamilyState: {
|
|
41
42
|
items: FamilyBE[];
|
|
42
43
|
count: number;
|
|
@@ -52,10 +53,11 @@ export declare const FAMILY_ACTION_TYPES: {
|
|
|
52
53
|
errors: Record<string, string>;
|
|
53
54
|
familyCode: string;
|
|
54
55
|
filterEnabled: boolean | undefined;
|
|
56
|
+
appliedFilterEnabled: boolean | undefined;
|
|
55
57
|
id: string;
|
|
58
|
+
members: FamilyMemberBE[];
|
|
56
59
|
postalCode: string;
|
|
57
60
|
stateProvince: string;
|
|
58
|
-
userId: string;
|
|
59
61
|
}, FamilyProvider: import("react").FC<{
|
|
60
62
|
children: React.ReactNode;
|
|
61
63
|
}>, familyReducer: (state: {
|
|
@@ -73,10 +75,11 @@ export declare const FAMILY_ACTION_TYPES: {
|
|
|
73
75
|
errors: Record<string, string>;
|
|
74
76
|
familyCode: string;
|
|
75
77
|
filterEnabled: boolean | undefined;
|
|
78
|
+
appliedFilterEnabled: boolean | undefined;
|
|
76
79
|
id: string;
|
|
80
|
+
members: FamilyMemberBE[];
|
|
77
81
|
postalCode: string;
|
|
78
82
|
stateProvince: string;
|
|
79
|
-
userId: string;
|
|
80
83
|
}, action: any) => {
|
|
81
84
|
items: FamilyBE[];
|
|
82
85
|
count: number;
|
|
@@ -92,10 +95,11 @@ export declare const FAMILY_ACTION_TYPES: {
|
|
|
92
95
|
errors: Record<string, string>;
|
|
93
96
|
familyCode: string;
|
|
94
97
|
filterEnabled: boolean | undefined;
|
|
98
|
+
appliedFilterEnabled: boolean | undefined;
|
|
95
99
|
id: string;
|
|
100
|
+
members: FamilyMemberBE[];
|
|
96
101
|
postalCode: string;
|
|
97
102
|
stateProvince: string;
|
|
98
|
-
userId: string;
|
|
99
103
|
}, useFamilyContext: () => import("@react-pakistan/util-functions/factory/generic-module-factory").GenericModuleContextWithHandlers<{
|
|
100
104
|
items: FamilyBE[];
|
|
101
105
|
count: number;
|
|
@@ -111,10 +115,11 @@ export declare const FAMILY_ACTION_TYPES: {
|
|
|
111
115
|
errors: Record<string, string>;
|
|
112
116
|
familyCode: string;
|
|
113
117
|
filterEnabled: boolean | undefined;
|
|
118
|
+
appliedFilterEnabled: boolean | undefined;
|
|
114
119
|
id: string;
|
|
120
|
+
members: FamilyMemberBE[];
|
|
115
121
|
postalCode: string;
|
|
116
122
|
stateProvince: string;
|
|
117
|
-
userId: string;
|
|
118
123
|
}>;
|
|
119
124
|
/**
|
|
120
125
|
* Backward-compatible alias used by dashboard-providers.tsx
|
|
@@ -130,11 +135,9 @@ export declare const useFamilyModule: () => {
|
|
|
130
135
|
deleteLoading: boolean;
|
|
131
136
|
handleChange: (field: string, value: string | number | boolean | undefined | null) => void;
|
|
132
137
|
handleCloseDrawer: () => void;
|
|
133
|
-
handleCreate: () => void;
|
|
134
138
|
handleDelete: (row?: TableRow) => void;
|
|
135
139
|
handleEdit: (row?: TableRow) => void;
|
|
136
140
|
handleFilters: () => void;
|
|
137
|
-
handleMoreActions: () => void;
|
|
138
141
|
handlePageChange: (page: number | unknown) => void;
|
|
139
142
|
handlePageLimitChange: (_k: string, value: object) => void;
|
|
140
143
|
handleSearch: (query: string) => void;
|
|
@@ -166,10 +169,11 @@ export declare const useFamilyModule: () => {
|
|
|
166
169
|
errors: Record<string, string>;
|
|
167
170
|
familyCode: string;
|
|
168
171
|
filterEnabled: boolean | undefined;
|
|
172
|
+
appliedFilterEnabled: boolean | undefined;
|
|
169
173
|
id: string;
|
|
174
|
+
members: FamilyMemberBE[];
|
|
170
175
|
postalCode: string;
|
|
171
176
|
stateProvince: string;
|
|
172
|
-
userId: string;
|
|
173
177
|
};
|
|
174
178
|
dispatch: React.Dispatch<any>;
|
|
175
179
|
};
|
|
@@ -31,7 +31,7 @@ import { familyFormValidation } from "./validate";
|
|
|
31
31
|
import { generateThemeToast, TOAST_VARIANT, } from "@appcorp/shadcn/lib/toast-utils";
|
|
32
32
|
import { useTranslations } from "next-intl";
|
|
33
33
|
import { getCachedWorkspaceSync } from "../workspace/cache";
|
|
34
|
-
import { Eye, Filter,
|
|
34
|
+
import { Eye, Filter, Pencil } from "lucide-react";
|
|
35
35
|
import { useTheme } from "next-themes";
|
|
36
36
|
// ============================================================================
|
|
37
37
|
// 1.1 DRAWER TYPES
|
|
@@ -66,11 +66,14 @@ const familyConfig = {
|
|
|
66
66
|
enabled: true,
|
|
67
67
|
errors: {},
|
|
68
68
|
familyCode: "",
|
|
69
|
-
|
|
69
|
+
// Staged filter: the drawer edits `filterEnabled`; Apply copies it to
|
|
70
|
+
// `appliedFilterEnabled`.
|
|
71
|
+
filterEnabled: true,
|
|
72
|
+
appliedFilterEnabled: true,
|
|
70
73
|
id: "",
|
|
74
|
+
members: [],
|
|
71
75
|
postalCode: "",
|
|
72
76
|
stateProvince: "", // renamed from 'state' to avoid conflict with factory state object
|
|
73
|
-
userId: "",
|
|
74
77
|
},
|
|
75
78
|
drawerTypes: DRAWER_TYPES,
|
|
76
79
|
};
|
|
@@ -89,7 +92,7 @@ export const useFamilyModule = () => {
|
|
|
89
92
|
// ==========================================================================
|
|
90
93
|
// 1.4.1 STATE & CORE HOOKS
|
|
91
94
|
// ==========================================================================
|
|
92
|
-
var _a, _b;
|
|
95
|
+
var _a, _b, _c, _d, _e, _f;
|
|
93
96
|
const context = useFamilyContext();
|
|
94
97
|
const { dispatch } = context;
|
|
95
98
|
const state = context.state;
|
|
@@ -103,37 +106,42 @@ export const useFamilyModule = () => {
|
|
|
103
106
|
// ==========================================================================
|
|
104
107
|
const listParams = useMemo(() => {
|
|
105
108
|
var _a;
|
|
106
|
-
return (Object.assign(Object.assign({ currentPage: state.currentPage, pageLimit: state.pageLimit, schoolId: ((_a = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _a === void 0 ? void 0 : _a.id) || "" }, (debouncedQuery ? { searchQuery: debouncedQuery } : {})), (state.
|
|
107
|
-
? { filterEnabled: String(state.
|
|
109
|
+
return (Object.assign(Object.assign({ currentPage: state.currentPage, pageLimit: state.pageLimit, schoolId: ((_a = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _a === void 0 ? void 0 : _a.id) || "" }, (debouncedQuery ? { searchQuery: debouncedQuery } : {})), (state.appliedFilterEnabled !== undefined
|
|
110
|
+
? { filterEnabled: String(state.appliedFilterEnabled) }
|
|
108
111
|
: {})));
|
|
109
112
|
}, [
|
|
113
|
+
state.appliedFilterEnabled,
|
|
110
114
|
state.currentPage,
|
|
111
|
-
state.filterEnabled,
|
|
112
115
|
state.pageLimit,
|
|
113
116
|
debouncedQuery,
|
|
114
117
|
(_a = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _a === void 0 ? void 0 : _a.id,
|
|
115
118
|
]);
|
|
116
|
-
const updateParams = useMemo(() =>
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
119
|
+
const updateParams = useMemo(() => {
|
|
120
|
+
var _a;
|
|
121
|
+
return ({
|
|
122
|
+
address: state.address,
|
|
123
|
+
city: state.city,
|
|
124
|
+
country: state.country,
|
|
125
|
+
enabled: state.enabled,
|
|
126
|
+
id: state.id,
|
|
127
|
+
postalCode: state.postalCode,
|
|
128
|
+
schoolId: ((_a = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _a === void 0 ? void 0 : _a.id) || "",
|
|
129
|
+
// The API column is `state`; the form key avoids colliding with the
|
|
130
|
+
// module's `state` object.
|
|
131
|
+
state: state.stateProvince,
|
|
132
|
+
});
|
|
133
|
+
}, [
|
|
126
134
|
state.address,
|
|
127
135
|
state.city,
|
|
128
136
|
state.country,
|
|
129
137
|
state.enabled,
|
|
130
|
-
state.familyCode,
|
|
131
138
|
state.id,
|
|
132
139
|
state.postalCode,
|
|
133
140
|
state.stateProvince,
|
|
141
|
+
(_b = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _b === void 0 ? void 0 : _b.id,
|
|
134
142
|
]);
|
|
135
|
-
const byIdParams = useMemo(() => ({ id: state.id }), [state.id]);
|
|
136
|
-
const deleteParams = useMemo(() => ({ id: state.id }), [state.id]);
|
|
143
|
+
const byIdParams = useMemo(() => { var _a; return ({ id: state.id, schoolId: (_a = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _a === void 0 ? void 0 : _a.id }); }, [state.id, (_c = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _c === void 0 ? void 0 : _c.id]);
|
|
144
|
+
const deleteParams = useMemo(() => { var _a; return ({ id: state.id, schoolId: (_a = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _a === void 0 ? void 0 : _a.id }); }, [state.id, (_d = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _d === void 0 ? void 0 : _d.id]);
|
|
137
145
|
// ==========================================================================
|
|
138
146
|
// 1.4.3 UTILITIES
|
|
139
147
|
// ==========================================================================
|
|
@@ -181,52 +189,52 @@ export const useFamilyModule = () => {
|
|
|
181
189
|
}
|
|
182
190
|
}, [dispatch, showToast, t]);
|
|
183
191
|
const updateCallback = useCallback(({ data, error }) => {
|
|
184
|
-
var _a;
|
|
185
192
|
const isCreated = isCreatedOrUpdated(data);
|
|
186
193
|
if (error) {
|
|
187
|
-
|
|
194
|
+
const message = data === null || data === void 0 ? void 0 : data.error;
|
|
195
|
+
showToast(message !== null && message !== void 0 ? message : (isCreated ? t("messagesCreateFailed") : t("messagesUpdateFailed")), TOAST_VARIANT.ERROR);
|
|
188
196
|
return;
|
|
189
197
|
}
|
|
190
198
|
if (data) {
|
|
191
199
|
showToast(t("messagesSaveSuccess"), TOAST_VARIANT.SUCCESS);
|
|
192
|
-
|
|
200
|
+
// `useModuleEntityV2` schedules the list refresh.
|
|
193
201
|
resetFormAndCloseDrawer();
|
|
194
202
|
}
|
|
195
203
|
}, [showToast, t, resetFormAndCloseDrawer]);
|
|
196
204
|
const byIdCallback = useCallback(({ data, error }) => {
|
|
205
|
+
var _a, _b, _c, _d, _e, _f;
|
|
197
206
|
if (error) {
|
|
198
207
|
showToast(t("messagesDetailsFetchFailed"), TOAST_VARIANT.ERROR);
|
|
199
208
|
return;
|
|
200
209
|
}
|
|
201
210
|
if (data) {
|
|
202
211
|
const family = data;
|
|
203
|
-
setField("id", family.id);
|
|
204
|
-
setField("address", family.address);
|
|
205
|
-
setField("city", family.city);
|
|
206
|
-
setField("country", family.country);
|
|
207
|
-
setField("enabled", family.enabled);
|
|
208
|
-
setField("familyCode", family.familyCode);
|
|
209
|
-
setField("postalCode", family.postalCode);
|
|
210
|
-
setField("stateProvince", family.state);
|
|
211
212
|
dispatch({
|
|
212
213
|
type: FAMILY_ACTION_TYPES.SET_FORM_DATA,
|
|
213
214
|
payload: {
|
|
214
215
|
form: {
|
|
215
|
-
|
|
216
|
+
address: (_a = family.address) !== null && _a !== void 0 ? _a : "",
|
|
217
|
+
city: (_b = family.city) !== null && _b !== void 0 ? _b : "",
|
|
218
|
+
country: (_c = family.country) !== null && _c !== void 0 ? _c : "",
|
|
219
|
+
enabled: family.enabled,
|
|
220
|
+
familyCode: family.familyCode,
|
|
221
|
+
id: family.id,
|
|
222
|
+
members: (_d = family.members) !== null && _d !== void 0 ? _d : [],
|
|
223
|
+
postalCode: (_e = family.postalCode) !== null && _e !== void 0 ? _e : "",
|
|
224
|
+
stateProvince: (_f = family.state) !== null && _f !== void 0 ? _f : "",
|
|
216
225
|
},
|
|
217
226
|
},
|
|
218
227
|
});
|
|
219
228
|
}
|
|
220
|
-
}, [dispatch, showToast, t
|
|
229
|
+
}, [dispatch, showToast, t]);
|
|
221
230
|
const deleteCallback = useCallback(({ data, error }) => {
|
|
222
|
-
var _a;
|
|
223
231
|
if (error) {
|
|
224
|
-
|
|
232
|
+
const message = data === null || data === void 0 ? void 0 : data.error;
|
|
233
|
+
showToast(message !== null && message !== void 0 ? message : t("messagesDeleteFailed"), TOAST_VARIANT.ERROR);
|
|
225
234
|
return;
|
|
226
235
|
}
|
|
227
236
|
if (data) {
|
|
228
237
|
showToast(t("messagesDeleteSuccess"), TOAST_VARIANT.SUCCESS);
|
|
229
|
-
(_a = listFetchNowRef.current) === null || _a === void 0 ? void 0 : _a.call(listFetchNowRef);
|
|
230
238
|
}
|
|
231
239
|
}, [showToast, t]);
|
|
232
240
|
// ==========================================================================
|
|
@@ -267,12 +275,6 @@ export const useFamilyModule = () => {
|
|
|
267
275
|
const handleCloseDrawer = useCallback(() => {
|
|
268
276
|
resetFormAndCloseDrawer();
|
|
269
277
|
}, [resetFormAndCloseDrawer]);
|
|
270
|
-
const handleCreate = useCallback(() => {
|
|
271
|
-
dispatch({
|
|
272
|
-
type: FAMILY_ACTION_TYPES.SET_DRAWER,
|
|
273
|
-
payload: { drawer: FAMILY_DRAWER.FORM_DRAWER },
|
|
274
|
-
});
|
|
275
|
-
}, [dispatch]);
|
|
276
278
|
const handleView = useCallback((row) => {
|
|
277
279
|
byIdFetchNow === null || byIdFetchNow === void 0 ? void 0 : byIdFetchNow(undefined, { params: { id: row === null || row === void 0 ? void 0 : row.id } });
|
|
278
280
|
dispatch({
|
|
@@ -288,24 +290,22 @@ export const useFamilyModule = () => {
|
|
|
288
290
|
});
|
|
289
291
|
}, [dispatch, byIdFetchNow]);
|
|
290
292
|
const handleDelete = useCallback((row) => {
|
|
293
|
+
var _a;
|
|
291
294
|
if (!confirm(t("messagesDeleteConfirmation")))
|
|
292
295
|
return;
|
|
293
296
|
deleteFetchNow === null || deleteFetchNow === void 0 ? void 0 : deleteFetchNow(undefined, {
|
|
294
|
-
body: JSON.stringify({
|
|
297
|
+
body: JSON.stringify({
|
|
298
|
+
id: row === null || row === void 0 ? void 0 : row.id,
|
|
299
|
+
schoolId: (_a = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _a === void 0 ? void 0 : _a.id,
|
|
300
|
+
}),
|
|
295
301
|
});
|
|
296
|
-
}, [t, deleteFetchNow]);
|
|
302
|
+
}, [t, deleteFetchNow, (_e = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _e === void 0 ? void 0 : _e.id]);
|
|
297
303
|
const handleFilters = useCallback(() => {
|
|
298
304
|
dispatch({
|
|
299
305
|
type: FAMILY_ACTION_TYPES.SET_DRAWER,
|
|
300
306
|
payload: { drawer: FAMILY_DRAWER.FILTER_DRAWER },
|
|
301
307
|
});
|
|
302
308
|
}, [dispatch]);
|
|
303
|
-
const handleMoreActions = useCallback(() => {
|
|
304
|
-
dispatch({
|
|
305
|
-
type: FAMILY_ACTION_TYPES.SET_DRAWER,
|
|
306
|
-
payload: { drawer: FAMILY_DRAWER.MORE_ACTIONS_DRAWER },
|
|
307
|
-
});
|
|
308
|
-
}, [dispatch]);
|
|
309
309
|
const handlePageChange = useCallback((page) => {
|
|
310
310
|
const nextPage = typeof page === "number" ? page : state.currentPage + 1;
|
|
311
311
|
dispatch({
|
|
@@ -337,17 +337,20 @@ export const useFamilyModule = () => {
|
|
|
337
337
|
});
|
|
338
338
|
}, [dispatch]);
|
|
339
339
|
const applyFilters = useCallback(() => {
|
|
340
|
+
dispatch({
|
|
341
|
+
type: FAMILY_ACTION_TYPES.SET_FILTERS,
|
|
342
|
+
payload: {
|
|
343
|
+
filters: { appliedFilterEnabled: state.filterEnabled },
|
|
344
|
+
},
|
|
345
|
+
});
|
|
340
346
|
dispatch({
|
|
341
347
|
type: FAMILY_ACTION_TYPES.SET_CURRENT_PAGE,
|
|
342
348
|
payload: { currentPage: 1 },
|
|
343
349
|
});
|
|
344
350
|
handleCloseDrawer();
|
|
345
|
-
}, [dispatch, handleCloseDrawer]);
|
|
351
|
+
}, [dispatch, handleCloseDrawer, state.filterEnabled]);
|
|
346
352
|
const clearFilters = useCallback(() => {
|
|
347
|
-
dispatch({
|
|
348
|
-
type: FAMILY_ACTION_TYPES.SET_FILTERS,
|
|
349
|
-
payload: { filters: { filterEnabled: undefined } },
|
|
350
|
-
});
|
|
353
|
+
dispatch({ type: FAMILY_ACTION_TYPES.RESET_FORM });
|
|
351
354
|
dispatch({
|
|
352
355
|
type: FAMILY_ACTION_TYPES.SET_CURRENT_PAGE,
|
|
353
356
|
payload: { currentPage: 1 },
|
|
@@ -386,28 +389,14 @@ export const useFamilyModule = () => {
|
|
|
386
389
|
// 1.4.8 HEADER & ROW ACTIONS
|
|
387
390
|
// ==========================================================================
|
|
388
391
|
const headerActions = useMemo(() => [
|
|
389
|
-
{
|
|
390
|
-
enabled: true,
|
|
391
|
-
handleOnClick: handleMoreActions,
|
|
392
|
-
label: t("actionsButtonMoreActions"),
|
|
393
|
-
order: 1,
|
|
394
|
-
icon: MoreHorizontal,
|
|
395
|
-
},
|
|
396
392
|
{
|
|
397
393
|
enabled: true,
|
|
398
394
|
handleOnClick: handleFilters,
|
|
399
395
|
label: t("actionsButtonFilters"),
|
|
400
|
-
order:
|
|
396
|
+
order: 1,
|
|
401
397
|
icon: Filter,
|
|
402
398
|
},
|
|
403
|
-
|
|
404
|
-
enabled: false,
|
|
405
|
-
handleOnClick: handleCreate,
|
|
406
|
-
label: t("actionsButtonAdd"),
|
|
407
|
-
order: 3,
|
|
408
|
-
icon: Plus,
|
|
409
|
-
},
|
|
410
|
-
], [handleFilters, handleMoreActions, handleCreate, t]);
|
|
399
|
+
], [handleFilters, t]);
|
|
411
400
|
const rowActions = useMemo(() => [
|
|
412
401
|
{
|
|
413
402
|
enabled: true,
|
|
@@ -423,7 +412,14 @@ export const useFamilyModule = () => {
|
|
|
423
412
|
order: 2,
|
|
424
413
|
icon: Pencil,
|
|
425
414
|
},
|
|
426
|
-
|
|
415
|
+
{
|
|
416
|
+
enabled: true,
|
|
417
|
+
handleOnClick: handleDelete,
|
|
418
|
+
label: t("actionsButtonDelete"),
|
|
419
|
+
order: 3,
|
|
420
|
+
variant: "destructive",
|
|
421
|
+
},
|
|
422
|
+
], [handleView, handleEdit, handleDelete, t]);
|
|
427
423
|
// ==========================================================================
|
|
428
424
|
// 1.4.9 EFFECTS
|
|
429
425
|
// ==========================================================================
|
|
@@ -435,7 +431,7 @@ export const useFamilyModule = () => {
|
|
|
435
431
|
if (!((_a = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _a === void 0 ? void 0 : _a.id))
|
|
436
432
|
return;
|
|
437
433
|
(_b = listFetchNowRef.current) === null || _b === void 0 ? void 0 : _b.call(listFetchNowRef);
|
|
438
|
-
}, [listParams, (
|
|
434
|
+
}, [listParams, (_f = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _f === void 0 ? void 0 : _f.id]);
|
|
439
435
|
// ==========================================================================
|
|
440
436
|
// 1.4.10 RETURN
|
|
441
437
|
// ==========================================================================
|
|
@@ -446,11 +442,9 @@ export const useFamilyModule = () => {
|
|
|
446
442
|
deleteLoading,
|
|
447
443
|
handleChange,
|
|
448
444
|
handleCloseDrawer,
|
|
449
|
-
handleCreate,
|
|
450
445
|
handleDelete,
|
|
451
446
|
handleEdit,
|
|
452
447
|
handleFilters,
|
|
453
|
-
handleMoreActions,
|
|
454
448
|
handlePageChange,
|
|
455
449
|
handlePageLimitChange,
|
|
456
450
|
handleSearch,
|
|
@@ -20,7 +20,6 @@ import { createGenericModulePage, } from "@react-pakistan/util-functions/factory
|
|
|
20
20
|
import { useFamilyModule, FamilyProvider, FAMILY_ACTION_TYPES, } from "./context";
|
|
21
21
|
import { FamilyFilter } from "./filter";
|
|
22
22
|
import { FamilyForm } from "./form";
|
|
23
|
-
import { FamilyMoreActions } from "./more-actions";
|
|
24
23
|
import { FamilyView } from "./view";
|
|
25
24
|
import { resolveRbacPermissions } from "../../utils/resolve-rbac-permissions";
|
|
26
25
|
import { RbacNoAccess } from "../../components/rbac-no-access";
|
|
@@ -30,7 +29,16 @@ import { RbacNoAccess } from "../../components/rbac-no-access";
|
|
|
30
29
|
const tableBodyCols = [
|
|
31
30
|
{ componentType: COMPONENT_TYPE.ID, key: "id" },
|
|
32
31
|
{ componentType: COMPONENT_TYPE.BOLD_TEXT, key: "familyCode" },
|
|
33
|
-
{
|
|
32
|
+
{
|
|
33
|
+
componentType: COMPONENT_TYPE.TEXT,
|
|
34
|
+
key: "members",
|
|
35
|
+
textFormatter: (_, row) => {
|
|
36
|
+
var _a, _b;
|
|
37
|
+
const members = (_a = row.members) !== null && _a !== void 0 ? _a : [];
|
|
38
|
+
const contact = (_b = members.find((member) => member.isPrimary && member.enabled)) !== null && _b !== void 0 ? _b : members.find((member) => member.enabled && member.role !== "STUDENT");
|
|
39
|
+
return (contact === null || contact === void 0 ? void 0 : contact.email) || (contact === null || contact === void 0 ? void 0 : contact.phone) || "—";
|
|
40
|
+
},
|
|
41
|
+
},
|
|
34
42
|
{ componentType: COMPONENT_TYPE.TEXT, key: "address" },
|
|
35
43
|
{ componentType: COMPONENT_TYPE.TEXT, key: "city" },
|
|
36
44
|
{ componentType: COMPONENT_TYPE.BOOLEAN, key: "enabled" },
|
|
@@ -42,7 +50,6 @@ const tableBodyCols = [
|
|
|
42
50
|
const createComponentInstances = () => ({
|
|
43
51
|
filter: _jsx(FamilyFilter, {}),
|
|
44
52
|
form: _jsx(FamilyForm, {}),
|
|
45
|
-
moreActions: _jsx(FamilyMoreActions, {}),
|
|
46
53
|
view: _jsx(FamilyView, {}),
|
|
47
54
|
});
|
|
48
55
|
const createFamilyConfig = ({ dispatch, drawerButtonCancel, drawerButtonSave, drawerFilterDescription, drawerFilterTitle, drawerFormDescription, drawerFormTitle, drawerMoreActionsDescription, drawerMoreActionsTitle, drawerViewDescription, drawerViewTitle, tableColumnHeaderActions, tableColumnHeaderAddress, tableColumnHeaderCity, tableColumnHeaderEnabled, tableColumnHeaderFamilyCode, tableColumnHeaderId, tableColumnHeaderPrimaryEmail, tableDescription, tableSearchPlaceholder, tableTitle, }) => {
|
|
@@ -69,7 +76,7 @@ const createFamilyConfig = ({ dispatch, drawerButtonCancel, drawerButtonSave, dr
|
|
|
69
76
|
drawerViewTitle,
|
|
70
77
|
filterContent: components.filter,
|
|
71
78
|
formContent: components.form,
|
|
72
|
-
moreActionsContent:
|
|
79
|
+
moreActionsContent: null,
|
|
73
80
|
saveLabel: drawerButtonSave,
|
|
74
81
|
searchPlaceholder: tableSearchPlaceholder,
|
|
75
82
|
tableDescription,
|
|
@@ -9,10 +9,11 @@ import { useTranslations } from "next-intl";
|
|
|
9
9
|
import { formatValue } from "@react-pakistan/util-functions/general/format-value";
|
|
10
10
|
export const FamilyView = () => {
|
|
11
11
|
const { state } = useFamilyModule();
|
|
12
|
-
const { address, city, country, enabled, familyCode, postalCode, stateProvince, } = state;
|
|
12
|
+
const { address, city, country, enabled, familyCode, members, postalCode, stateProvince, } = state;
|
|
13
13
|
const t = useTranslations("family");
|
|
14
|
+
const formatRole = (value) => value.charAt(0) + value.slice(1).toLowerCase().replace(/_/g, " ");
|
|
14
15
|
const fullAddress = [address, city, stateProvince, country, postalCode]
|
|
15
16
|
.filter(Boolean)
|
|
16
17
|
.join(", ");
|
|
17
|
-
return (_jsxs("div", { className: "space-y-4", children: [_jsx(Card, { children: _jsx(CardContent, { className: "pt-6", children: _jsxs("div", { className: "flex items-center gap-6", children: [_jsx("div", { className: "bg-primary/10 flex h-16 w-16 items-center justify-center rounded-full", children: _jsx(Home, { className: "text-primary h-8 w-8" }) }), _jsxs("div", { className: "flex-1", children: [_jsxs("div", { className: "flex items-center gap-3", children: [_jsx("h2", { className: "text-2xl font-bold", children: familyCode }), enabled ? (_jsxs(Badge, { variant: "default", className: "gap-1", children: [_jsx(CheckCircle2, { className: "h-3 w-3" }), t("badgeActive")] })) : (_jsxs(Badge, { variant: "secondary", className: "gap-1", children: [_jsx(XCircle, { className: "h-3 w-3" }), t("badgeInactive")] }))] }), _jsx("p", { className: "text-muted-foreground mt-1 text-sm", children: t("viewFieldFamilyProfile") })] })] }) }) }), _jsxs(Card, { children: [_jsxs(CardHeader, { className: "pb-3", children: [_jsxs("div", { className: "flex items-center gap-2", children: [_jsx(MapPin, { className: "text-primary h-5 w-5" }), _jsx(CardTitle, { className: "text-lg", children: t("viewSectionAddressInformation") })] }), _jsx(CardDescription, { children: t("viewSectionFamilyResidenceDetails") })] }), _jsx(Separator, {}), _jsx(CardContent, { className: "pt-6", children: _jsxs("div", { className: "space-y-4", children: [_jsxs("div", { className: "space-y-1", children: [_jsx("p", { className: "text-muted-foreground text-sm font-medium", children: t("viewFieldFullAddress") }), _jsx("p", { className: "text-base", children: fullAddress || t("viewTextAddressNotProvided") })] }), _jsxs("div", { className: "grid grid-cols-1 gap-6 md:grid-cols-2", children: [_jsxs("div", { className: "space-y-1", children: [_jsx("p", { className: "text-muted-foreground text-sm font-medium", children: t("formStreetAddressLabel") }), _jsx("p", { className: "text-base", children: formatValue(address) })] }), _jsxs("div", { className: "space-y-1", children: [_jsx("p", { className: "text-muted-foreground text-sm font-medium", children: t("formCityLabel") }), _jsx("p", { className: "text-base", children: formatValue(city) })] }), _jsxs("div", { className: "space-y-1", children: [_jsx("p", { className: "text-muted-foreground text-sm font-medium", children: t("formStateProvinceLabel") }), _jsx("p", { className: "text-base", children: formatValue(stateProvince) })] }), _jsxs("div", { className: "space-y-1", children: [_jsx("p", { className: "text-muted-foreground text-sm font-medium", children: t("formCountryLabel") }), _jsx("p", { className: "text-base", children: formatValue(country) })] }), _jsxs("div", { className: "space-y-1", children: [_jsx("p", { className: "text-muted-foreground text-sm font-medium", children: t("formPostalCodeLabel") }), _jsx("p", { className: "text-base", children: formatValue(postalCode) })] })] })] }) })] }), _jsxs(Card, { children: [_jsxs(CardHeader, { className: "pb-3", children: [_jsxs("div", { className: "flex items-center gap-2", children: [_jsx(Users, { className: "text-primary h-5 w-5" }), _jsx(CardTitle, { className: "text-lg", children: t("viewFieldFamilyStatus") })] }), _jsx(CardDescription, { children: t("viewSectionCurrentStatusInformation") })] }), _jsx(Separator, {}), _jsx(CardContent, { className: "pt-6", children: _jsx("div", { className: "flex items-center gap-3", children: enabled ? (_jsxs(_Fragment, { children: [_jsx(CheckCircle2, { className: "h-5 w-5 text-green-500" }), _jsxs("div", { children: [_jsx("p", { className: "font-medium", children: t("badgeActive") }), _jsx("p", { className: "text-muted-foreground text-sm", children: t("viewFieldThisAccountIsCurrentlyActive") })] })] })) : (_jsxs(_Fragment, { children: [_jsx(XCircle, { className: "h-5 w-5 text-red-500" }), _jsxs("div", { children: [_jsx("p", { className: "font-medium", children: t("badgeInactive") }), _jsx("p", { className: "text-muted-foreground text-sm", children: t("viewFieldThisAccountIsCurrentlyInactive") })] })] })) }) })] })] }));
|
|
18
|
+
return (_jsxs("div", { className: "space-y-4", children: [_jsx(Card, { children: _jsx(CardContent, { className: "pt-6", children: _jsxs("div", { className: "flex items-center gap-6", children: [_jsx("div", { className: "bg-primary/10 flex h-16 w-16 items-center justify-center rounded-full", children: _jsx(Home, { className: "text-primary h-8 w-8" }) }), _jsxs("div", { className: "flex-1", children: [_jsxs("div", { className: "flex items-center gap-3", children: [_jsx("h2", { className: "text-2xl font-bold", children: familyCode }), enabled ? (_jsxs(Badge, { variant: "default", className: "gap-1", children: [_jsx(CheckCircle2, { className: "h-3 w-3" }), t("badgeActive")] })) : (_jsxs(Badge, { variant: "secondary", className: "gap-1", children: [_jsx(XCircle, { className: "h-3 w-3" }), t("badgeInactive")] }))] }), _jsx("p", { className: "text-muted-foreground mt-1 text-sm", children: t("viewFieldFamilyProfile") })] })] }) }) }), _jsxs(Card, { children: [_jsxs(CardHeader, { className: "pb-3", children: [_jsxs("div", { className: "flex items-center gap-2", children: [_jsx(MapPin, { className: "text-primary h-5 w-5" }), _jsx(CardTitle, { className: "text-lg", children: t("viewSectionAddressInformation") })] }), _jsx(CardDescription, { children: t("viewSectionFamilyResidenceDetails") })] }), _jsx(Separator, {}), _jsx(CardContent, { className: "pt-6", children: _jsxs("div", { className: "space-y-4", children: [_jsxs("div", { className: "space-y-1", children: [_jsx("p", { className: "text-muted-foreground text-sm font-medium", children: t("viewFieldFullAddress") }), _jsx("p", { className: "text-base", children: fullAddress || t("viewTextAddressNotProvided") })] }), _jsxs("div", { className: "grid grid-cols-1 gap-6 md:grid-cols-2", children: [_jsxs("div", { className: "space-y-1", children: [_jsx("p", { className: "text-muted-foreground text-sm font-medium", children: t("formStreetAddressLabel") }), _jsx("p", { className: "text-base", children: formatValue(address) })] }), _jsxs("div", { className: "space-y-1", children: [_jsx("p", { className: "text-muted-foreground text-sm font-medium", children: t("formCityLabel") }), _jsx("p", { className: "text-base", children: formatValue(city) })] }), _jsxs("div", { className: "space-y-1", children: [_jsx("p", { className: "text-muted-foreground text-sm font-medium", children: t("formStateProvinceLabel") }), _jsx("p", { className: "text-base", children: formatValue(stateProvince) })] }), _jsxs("div", { className: "space-y-1", children: [_jsx("p", { className: "text-muted-foreground text-sm font-medium", children: t("formCountryLabel") }), _jsx("p", { className: "text-base", children: formatValue(country) })] }), _jsxs("div", { className: "space-y-1", children: [_jsx("p", { className: "text-muted-foreground text-sm font-medium", children: t("formPostalCodeLabel") }), _jsx("p", { className: "text-base", children: formatValue(postalCode) })] })] })] }) })] }), _jsxs(Card, { children: [_jsxs(CardHeader, { className: "pb-3", children: [_jsxs("div", { className: "flex items-center gap-2", children: [_jsx(Users, { className: "text-primary h-5 w-5" }), _jsx(CardTitle, { className: "text-lg", children: t("viewSectionMembers") })] }), _jsx(CardDescription, { children: t("viewSectionMembersDescription") })] }), _jsx(Separator, {}), _jsx(CardContent, { className: "pt-6", children: (members === null || members === void 0 ? void 0 : members.length) ? (_jsx("div", { className: "space-y-3", children: members.map((member) => (_jsxs("div", { className: "flex items-center justify-between gap-4", children: [_jsxs("div", { children: [_jsxs("p", { className: "font-medium", children: [member.firstName, " ", member.lastName, member.isPrimary ? ` · ${t("badgePrimary")}` : ""] }), _jsxs("p", { className: "text-muted-foreground text-sm", children: [formatRole(member.role), " \u00B7", " ", member.email || member.phone || "—"] })] }), _jsx(Badge, { variant: member.enabled ? "default" : "secondary", children: member.enabled ? t("badgeActive") : t("badgeInactive") })] }, member.id))) })) : (_jsx("p", { className: "text-muted-foreground text-sm", children: t("viewNoMembers") })) })] }), _jsxs(Card, { children: [_jsxs(CardHeader, { className: "pb-3", children: [_jsxs("div", { className: "flex items-center gap-2", children: [_jsx(Users, { className: "text-primary h-5 w-5" }), _jsx(CardTitle, { className: "text-lg", children: t("viewFieldFamilyStatus") })] }), _jsx(CardDescription, { children: t("viewSectionCurrentStatusInformation") })] }), _jsx(Separator, {}), _jsx(CardContent, { className: "pt-6", children: _jsx("div", { className: "flex items-center gap-3", children: enabled ? (_jsxs(_Fragment, { children: [_jsx(CheckCircle2, { className: "h-5 w-5 text-green-500" }), _jsxs("div", { children: [_jsx("p", { className: "font-medium", children: t("badgeActive") }), _jsx("p", { className: "text-muted-foreground text-sm", children: t("viewFieldThisAccountIsCurrentlyActive") })] })] })) : (_jsxs(_Fragment, { children: [_jsx(XCircle, { className: "h-5 w-5 text-red-500" }), _jsxs("div", { children: [_jsx("p", { className: "font-medium", children: t("badgeInactive") }), _jsx("p", { className: "text-muted-foreground text-sm", children: t("viewFieldThisAccountIsCurrentlyInactive") })] })] })) }) })] })] }));
|
|
18
19
|
};
|
|
@@ -17,3 +17,11 @@ export declare const ENABLED_OPTIONS: readonly [{
|
|
|
17
17
|
readonly label: "Disabled";
|
|
18
18
|
readonly value: "false";
|
|
19
19
|
}];
|
|
20
|
+
export declare const FAMILY_MEMBER_ROLE_OPTIONS: {
|
|
21
|
+
label: string;
|
|
22
|
+
value: string;
|
|
23
|
+
}[];
|
|
24
|
+
export declare const GENDER_OPTIONS: {
|
|
25
|
+
label: string;
|
|
26
|
+
value: string;
|
|
27
|
+
}[];
|
|
@@ -18,3 +18,15 @@ export const ENABLED_OPTIONS = [
|
|
|
18
18
|
{ label: "Enabled", value: "true" },
|
|
19
19
|
{ label: "Disabled", value: "false" },
|
|
20
20
|
];
|
|
21
|
+
export const FAMILY_MEMBER_ROLE_OPTIONS = [
|
|
22
|
+
{ label: "Father", value: "FATHER" },
|
|
23
|
+
{ label: "Mother", value: "MOTHER" },
|
|
24
|
+
{ label: "Guardian", value: "GUARDIAN" },
|
|
25
|
+
{ label: "Student", value: "STUDENT" },
|
|
26
|
+
];
|
|
27
|
+
export const GENDER_OPTIONS = [
|
|
28
|
+
{ label: "Male", value: "MALE" },
|
|
29
|
+
{ label: "Female", value: "FEMALE" },
|
|
30
|
+
{ label: "Other", value: "OTHER" },
|
|
31
|
+
{ label: "Prefer not to say", value: "PREFER_NOT_TO_SAY" },
|
|
32
|
+
];
|
|
@@ -26,6 +26,7 @@ export declare const FAMILY_MEMBER_ACTION_TYPES: {
|
|
|
26
26
|
searchQuery: string;
|
|
27
27
|
familyId: string;
|
|
28
28
|
filterEnabled: boolean | undefined;
|
|
29
|
+
appliedFilterEnabled: boolean | undefined;
|
|
29
30
|
disableSaveButton: boolean;
|
|
30
31
|
drawer: string | null;
|
|
31
32
|
avatar: string;
|
|
@@ -38,6 +39,7 @@ export declare const FAMILY_MEMBER_ACTION_TYPES: {
|
|
|
38
39
|
firstName: string;
|
|
39
40
|
gender: string;
|
|
40
41
|
id: string;
|
|
42
|
+
hasStudentProfile: boolean;
|
|
41
43
|
idNumber: string;
|
|
42
44
|
isPrimary: boolean;
|
|
43
45
|
lastName: string;
|
|
@@ -53,6 +55,7 @@ export declare const FAMILY_MEMBER_ACTION_TYPES: {
|
|
|
53
55
|
searchQuery: string;
|
|
54
56
|
familyId: string;
|
|
55
57
|
filterEnabled: boolean | undefined;
|
|
58
|
+
appliedFilterEnabled: boolean | undefined;
|
|
56
59
|
disableSaveButton: boolean;
|
|
57
60
|
drawer: string | null;
|
|
58
61
|
avatar: string;
|
|
@@ -65,6 +68,7 @@ export declare const FAMILY_MEMBER_ACTION_TYPES: {
|
|
|
65
68
|
firstName: string;
|
|
66
69
|
gender: string;
|
|
67
70
|
id: string;
|
|
71
|
+
hasStudentProfile: boolean;
|
|
68
72
|
idNumber: string;
|
|
69
73
|
isPrimary: boolean;
|
|
70
74
|
lastName: string;
|
|
@@ -82,6 +86,7 @@ export declare const FAMILY_MEMBER_ACTION_TYPES: {
|
|
|
82
86
|
searchQuery: string;
|
|
83
87
|
familyId: string;
|
|
84
88
|
filterEnabled: boolean | undefined;
|
|
89
|
+
appliedFilterEnabled: boolean | undefined;
|
|
85
90
|
disableSaveButton: boolean;
|
|
86
91
|
drawer: string | null;
|
|
87
92
|
avatar: string;
|
|
@@ -94,6 +99,7 @@ export declare const FAMILY_MEMBER_ACTION_TYPES: {
|
|
|
94
99
|
firstName: string;
|
|
95
100
|
gender: string;
|
|
96
101
|
id: string;
|
|
102
|
+
hasStudentProfile: boolean;
|
|
97
103
|
idNumber: string;
|
|
98
104
|
isPrimary: boolean;
|
|
99
105
|
lastName: string;
|
|
@@ -109,6 +115,7 @@ export declare const FAMILY_MEMBER_ACTION_TYPES: {
|
|
|
109
115
|
searchQuery: string;
|
|
110
116
|
familyId: string;
|
|
111
117
|
filterEnabled: boolean | undefined;
|
|
118
|
+
appliedFilterEnabled: boolean | undefined;
|
|
112
119
|
disableSaveButton: boolean;
|
|
113
120
|
drawer: string | null;
|
|
114
121
|
avatar: string;
|
|
@@ -121,6 +128,7 @@ export declare const FAMILY_MEMBER_ACTION_TYPES: {
|
|
|
121
128
|
firstName: string;
|
|
122
129
|
gender: string;
|
|
123
130
|
id: string;
|
|
131
|
+
hasStudentProfile: boolean;
|
|
124
132
|
idNumber: string;
|
|
125
133
|
isPrimary: boolean;
|
|
126
134
|
lastName: string;
|
|
@@ -136,6 +144,7 @@ export declare const FAMILY_MEMBER_ACTION_TYPES: {
|
|
|
136
144
|
searchQuery: string;
|
|
137
145
|
familyId: string;
|
|
138
146
|
filterEnabled: boolean | undefined;
|
|
147
|
+
appliedFilterEnabled: boolean | undefined;
|
|
139
148
|
disableSaveButton: boolean;
|
|
140
149
|
drawer: string | null;
|
|
141
150
|
avatar: string;
|
|
@@ -148,6 +157,7 @@ export declare const FAMILY_MEMBER_ACTION_TYPES: {
|
|
|
148
157
|
firstName: string;
|
|
149
158
|
gender: string;
|
|
150
159
|
id: string;
|
|
160
|
+
hasStudentProfile: boolean;
|
|
151
161
|
idNumber: string;
|
|
152
162
|
isPrimary: boolean;
|
|
153
163
|
lastName: string;
|
|
@@ -164,11 +174,9 @@ export declare const useFamilyMemberModule: () => {
|
|
|
164
174
|
deleteLoading: boolean;
|
|
165
175
|
handleChange: (key: string, value: string | number | boolean | Date | undefined | null) => void;
|
|
166
176
|
handleCloseDrawer: () => void;
|
|
167
|
-
handleCreate: () => void;
|
|
168
177
|
handleDelete: (row?: TableRow) => void;
|
|
169
178
|
handleEdit: (row?: TableRow) => void;
|
|
170
179
|
handleFilters: () => void;
|
|
171
|
-
handleMoreActions: () => void;
|
|
172
180
|
handlePageChange: (page: number | unknown) => void;
|
|
173
181
|
handlePageLimitChange: (_k: string, value: object) => void;
|
|
174
182
|
handleSearch: (query: string) => void;
|
|
@@ -193,6 +201,7 @@ export declare const useFamilyMemberModule: () => {
|
|
|
193
201
|
searchQuery: string;
|
|
194
202
|
familyId: string;
|
|
195
203
|
filterEnabled: boolean | undefined;
|
|
204
|
+
appliedFilterEnabled: boolean | undefined;
|
|
196
205
|
disableSaveButton: boolean;
|
|
197
206
|
drawer: string | null;
|
|
198
207
|
avatar: string;
|
|
@@ -205,6 +214,7 @@ export declare const useFamilyMemberModule: () => {
|
|
|
205
214
|
firstName: string;
|
|
206
215
|
gender: string;
|
|
207
216
|
id: string;
|
|
217
|
+
hasStudentProfile: boolean;
|
|
208
218
|
idNumber: string;
|
|
209
219
|
isPrimary: boolean;
|
|
210
220
|
lastName: string;
|