@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.
@@ -35,7 +35,8 @@ import { formatPhoneDisplay } from "@react-pakistan/util-functions/general/forma
35
35
  import { toE164Phone } from "../../utils/to-e164-phone";
36
36
  import { useTranslations } from "next-intl";
37
37
  import { getCachedWorkspaceSync } from "../workspace/cache";
38
- import { Eye, Filter, MoreHorizontal, Pencil, Plus } from "lucide-react";
38
+ import { toDateInput } from "./date";
39
+ import { Eye, Filter, Pencil } from "lucide-react";
39
40
  // ============================================================================
40
41
  // 1.1 DRAWER TYPES
41
42
  // ============================================================================
@@ -61,7 +62,10 @@ const familyMemberConfig = {
61
62
  searchQuery: "",
62
63
  // Filters
63
64
  familyId: "",
64
- filterEnabled: undefined,
65
+ // Staged filter: the drawer edits `filterEnabled`; Apply copies it to
66
+ // `appliedFilterEnabled`.
67
+ filterEnabled: true,
68
+ appliedFilterEnabled: true,
65
69
  // UI State
66
70
  disableSaveButton: false,
67
71
  drawer: null,
@@ -76,6 +80,7 @@ const familyMemberConfig = {
76
80
  firstName: "",
77
81
  gender: "",
78
82
  id: "",
83
+ hasStudentProfile: false,
79
84
  idNumber: "",
80
85
  isPrimary: false,
81
86
  lastName: "",
@@ -97,7 +102,7 @@ export const useFamilyMemberModule = () => {
97
102
  // ============================================================================
98
103
  // 1.4.1 STATE & CORE HOOKS
99
104
  // ============================================================================
100
- var _a, _b, _c;
105
+ var _a, _b, _c, _d, _e, _f, _g;
101
106
  const context = useFamilyMemberContext();
102
107
  const { dispatch } = context;
103
108
  const state = context.state;
@@ -111,19 +116,18 @@ export const useFamilyMemberModule = () => {
111
116
  // ============================================================================
112
117
  const listParams = useMemo(() => {
113
118
  var _a;
114
- return (Object.assign(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.filterEnabled !== undefined
115
- ? { filterEnabled: String(state.filterEnabled) }
116
- : {})), (state.familyId ? { familyId: state.familyId } : {})));
119
+ 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
120
+ ? { filterEnabled: String(state.appliedFilterEnabled) }
121
+ : {})));
117
122
  }, [
123
+ state.appliedFilterEnabled,
118
124
  state.currentPage,
119
- state.filterEnabled,
120
- state.familyId,
121
125
  state.pageLimit,
122
126
  debouncedQuery,
123
127
  (_a = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _a === void 0 ? void 0 : _a.id,
124
128
  ]);
125
129
  const updateParams = useMemo(() => {
126
- var _a, _b;
130
+ var _a, _b, _c;
127
131
  return ({
128
132
  id: state.id,
129
133
  familyId: state.familyId,
@@ -142,6 +146,7 @@ export const useFamilyMemberModule = () => {
142
146
  avatar: state.avatar,
143
147
  isPrimary: state.isPrimary,
144
148
  enabled: state.enabled,
149
+ schoolId: ((_c = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _c === void 0 ? void 0 : _c.id) || "",
145
150
  });
146
151
  }, [
147
152
  state.avatar,
@@ -151,6 +156,7 @@ export const useFamilyMemberModule = () => {
151
156
  state.emergencyPhone,
152
157
  state.enabled,
153
158
  state.familyId,
159
+ (_b = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _b === void 0 ? void 0 : _b.id,
154
160
  state.firstName,
155
161
  state.gender,
156
162
  state.id,
@@ -161,10 +167,10 @@ export const useFamilyMemberModule = () => {
161
167
  state.phone,
162
168
  state.relationship,
163
169
  state.role,
164
- (_b = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _b === void 0 ? void 0 : _b.country,
170
+ (_c = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _c === void 0 ? void 0 : _c.country,
165
171
  ]);
166
- const byIdParams = useMemo(() => ({ id: state.id }), [state.id]);
167
- const deleteParams = useMemo(() => ({ id: state.id }), [state.id]);
172
+ 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, (_d = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _d === void 0 ? void 0 : _d.id]);
173
+ 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, (_e = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _e === void 0 ? void 0 : _e.id]);
168
174
  // ============================================================================
169
175
  // 1.4.3 UTILITIES
170
176
  // ============================================================================
@@ -222,58 +228,61 @@ export const useFamilyMemberModule = () => {
222
228
  }
223
229
  }, [dispatch, showToast, t]);
224
230
  const updateCallback = useCallback(({ data, error }) => {
225
- var _a;
226
231
  const isCreated = isCreatedOrUpdated(data);
227
232
  if (error) {
228
- showToast(isCreated ? t("messagesCreateFailed") : t("messagesUpdateFailed"), TOAST_VARIANT.ERROR);
233
+ const message = data === null || data === void 0 ? void 0 : data.error;
234
+ showToast(message !== null && message !== void 0 ? message : (isCreated ? t("messagesCreateFailed") : t("messagesUpdateFailed")), TOAST_VARIANT.ERROR);
229
235
  return;
230
236
  }
231
237
  if (data) {
232
238
  showToast(t("messagesSaveSuccess"), TOAST_VARIANT.SUCCESS);
233
- (_a = listFetchNowRef.current) === null || _a === void 0 ? void 0 : _a.call(listFetchNowRef);
239
+ // `useModuleEntityV2` schedules the list refresh.
234
240
  resetFormAndCloseDrawer();
235
241
  }
236
242
  }, [showToast, t, resetFormAndCloseDrawer]);
237
243
  const byIdCallback = useCallback(({ data, error }) => {
244
+ var _a, _b, _c, _d;
238
245
  if (error) {
239
246
  showToast(t("messagesDetailsFetchFailed"), TOAST_VARIANT.ERROR);
240
247
  return;
241
248
  }
242
249
  if (data) {
243
- const familyMember = data;
244
- const fieldMappings = {
245
- id: familyMember.id,
246
- familyId: familyMember.familyId,
247
- role: familyMember.role,
248
- firstName: familyMember.firstName,
249
- lastName: familyMember.lastName,
250
- dateOfBirth: familyMember.dateOfBirth,
251
- gender: familyMember.gender,
252
- bloodGroup: familyMember.bloodGroup,
253
- phone: familyMember.phone,
254
- email: familyMember.email,
255
- relationship: familyMember.relationship,
256
- occupation: familyMember.occupation,
257
- emergencyPhone: formatPhoneDisplay(familyMember.emergencyPhone) || "",
258
- idNumber: familyMember.idNumber,
259
- avatar: familyMember.avatar,
260
- isPrimary: familyMember.isPrimary,
261
- enabled: familyMember.enabled,
262
- };
263
- Object.entries(fieldMappings).forEach(([key, value]) => {
264
- setField(key, value !== null && value !== void 0 ? value : undefined);
250
+ const member = data;
251
+ dispatch({
252
+ type: FAMILY_MEMBER_ACTION_TYPES.SET_FORM_DATA,
253
+ payload: {
254
+ form: {
255
+ avatar: (_a = member.avatar) !== null && _a !== void 0 ? _a : "",
256
+ bloodGroup: (_b = member.bloodGroup) !== null && _b !== void 0 ? _b : "",
257
+ dateOfBirth: toDateInput(member.dateOfBirth),
258
+ email: (_c = member.email) !== null && _c !== void 0 ? _c : "",
259
+ emergencyPhone: formatPhoneDisplay(member.emergencyPhone) || "",
260
+ enabled: member.enabled,
261
+ familyId: member.familyId,
262
+ firstName: member.firstName,
263
+ gender: member.gender,
264
+ hasStudentProfile: Boolean(member.studentProfile),
265
+ id: member.id,
266
+ idNumber: member.idNumber,
267
+ isPrimary: member.isPrimary,
268
+ lastName: member.lastName,
269
+ occupation: (_d = member.occupation) !== null && _d !== void 0 ? _d : "",
270
+ phone: formatPhoneDisplay(member.phone) || "",
271
+ relationship: member.relationship,
272
+ role: member.role,
273
+ },
274
+ },
265
275
  });
266
276
  }
267
- }, [showToast, t, setField]);
277
+ }, [dispatch, showToast, t]);
268
278
  const deleteCallback = useCallback(({ data, error }) => {
269
- var _a;
270
279
  if (error) {
271
- showToast(t("messagesDeleteFailed"), TOAST_VARIANT.ERROR);
280
+ const message = data === null || data === void 0 ? void 0 : data.error;
281
+ showToast(message !== null && message !== void 0 ? message : t("messagesDeleteFailed"), TOAST_VARIANT.ERROR);
272
282
  return;
273
283
  }
274
284
  if (data) {
275
285
  showToast(t("messagesDeleteSuccess"), TOAST_VARIANT.SUCCESS);
276
- (_a = listFetchNowRef.current) === null || _a === void 0 ? void 0 : _a.call(listFetchNowRef);
277
286
  }
278
287
  }, [showToast, t]);
279
288
  // ============================================================================
@@ -294,7 +303,6 @@ export const useFamilyMemberModule = () => {
294
303
  updateParams,
295
304
  headers: {
296
305
  "Content-Type": "application/json",
297
- "x-api-token": process.env.NEXT_PUBLIC_API_KEY,
298
306
  },
299
307
  });
300
308
  // ============================================================================
@@ -332,12 +340,6 @@ export const useFamilyMemberModule = () => {
332
340
  const handleCloseDrawer = useCallback(() => {
333
341
  resetFormAndCloseDrawer();
334
342
  }, [resetFormAndCloseDrawer]);
335
- const handleCreate = useCallback(() => {
336
- dispatch({
337
- type: FAMILY_MEMBER_ACTION_TYPES.SET_DRAWER,
338
- payload: { drawer: FAMILY_MEMBER_DRAWER.FORM_DRAWER },
339
- });
340
- }, [dispatch]);
341
343
  const handleView = useCallback((row) => {
342
344
  byIdFetchNow === null || byIdFetchNow === void 0 ? void 0 : byIdFetchNow(undefined, { params: { id: row === null || row === void 0 ? void 0 : row.id } });
343
345
  dispatch({
@@ -353,24 +355,22 @@ export const useFamilyMemberModule = () => {
353
355
  });
354
356
  }, [dispatch, byIdFetchNow]);
355
357
  const handleDelete = useCallback((row) => {
358
+ var _a;
356
359
  if (!confirm(t("messagesDeleteConfirmation")))
357
360
  return;
358
361
  deleteFetchNow === null || deleteFetchNow === void 0 ? void 0 : deleteFetchNow(undefined, {
359
- body: JSON.stringify({ id: row === null || row === void 0 ? void 0 : row.id }),
362
+ body: JSON.stringify({
363
+ id: row === null || row === void 0 ? void 0 : row.id,
364
+ schoolId: (_a = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _a === void 0 ? void 0 : _a.id,
365
+ }),
360
366
  });
361
- }, [t, deleteFetchNow]);
367
+ }, [t, deleteFetchNow, (_f = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _f === void 0 ? void 0 : _f.id]);
362
368
  const handleFilters = useCallback(() => {
363
369
  dispatch({
364
370
  type: FAMILY_MEMBER_ACTION_TYPES.SET_DRAWER,
365
371
  payload: { drawer: FAMILY_MEMBER_DRAWER.FILTER_DRAWER },
366
372
  });
367
373
  }, [dispatch]);
368
- const handleMoreActions = useCallback(() => {
369
- dispatch({
370
- type: FAMILY_MEMBER_ACTION_TYPES.SET_DRAWER,
371
- payload: { drawer: FAMILY_MEMBER_DRAWER.MORE_ACTIONS_DRAWER },
372
- });
373
- }, [dispatch]);
374
374
  const handleSearch = useCallback((query) => {
375
375
  dispatch({
376
376
  type: FAMILY_MEMBER_ACTION_TYPES.SET_SEARCH_QUERY,
@@ -384,17 +384,20 @@ export const useFamilyMemberModule = () => {
384
384
  });
385
385
  }, [dispatch]);
386
386
  const applyFilters = useCallback(() => {
387
+ dispatch({
388
+ type: FAMILY_MEMBER_ACTION_TYPES.SET_FILTERS,
389
+ payload: {
390
+ filters: { appliedFilterEnabled: state.filterEnabled },
391
+ },
392
+ });
387
393
  dispatch({
388
394
  type: FAMILY_MEMBER_ACTION_TYPES.SET_CURRENT_PAGE,
389
395
  payload: { currentPage: 1 },
390
396
  });
391
397
  handleCloseDrawer();
392
- }, [dispatch, handleCloseDrawer]);
398
+ }, [dispatch, handleCloseDrawer, state.filterEnabled]);
393
399
  const clearFilters = useCallback(() => {
394
- dispatch({
395
- type: FAMILY_MEMBER_ACTION_TYPES.SET_FILTERS,
396
- payload: { filters: { filterEnabled: undefined } },
397
- });
400
+ dispatch({ type: FAMILY_MEMBER_ACTION_TYPES.RESET_FORM });
398
401
  dispatch({
399
402
  type: FAMILY_MEMBER_ACTION_TYPES.SET_CURRENT_PAGE,
400
403
  payload: { currentPage: 1 },
@@ -433,28 +436,14 @@ export const useFamilyMemberModule = () => {
433
436
  // 1.4.8 HEADER & ROW ACTIONS
434
437
  // ============================================================================
435
438
  const headerActions = useMemo(() => [
436
- {
437
- enabled: true,
438
- handleOnClick: handleMoreActions,
439
- label: t("actionsButtonMoreActions"),
440
- order: 1,
441
- icon: MoreHorizontal,
442
- },
443
439
  {
444
440
  enabled: true,
445
441
  handleOnClick: handleFilters,
446
442
  label: t("actionsButtonFilters"),
447
- order: 2,
443
+ order: 1,
448
444
  icon: Filter,
449
445
  },
450
- {
451
- enabled: false,
452
- handleOnClick: handleCreate,
453
- label: t("actionsButtonAdd"),
454
- order: 3,
455
- icon: Plus,
456
- },
457
- ], [handleFilters, handleMoreActions, handleCreate, t]);
446
+ ], [handleFilters, t]);
458
447
  const rowActions = useMemo(() => [
459
448
  {
460
449
  enabled: true,
@@ -470,7 +459,17 @@ export const useFamilyMemberModule = () => {
470
459
  order: 2,
471
460
  icon: Pencil,
472
461
  },
473
- ], [handleView, handleEdit, t]);
462
+ {
463
+ enabled: (row) => {
464
+ const member = row;
465
+ return (member === null || member === void 0 ? void 0 : member.enabled) === true && !(member === null || member === void 0 ? void 0 : member.studentProfile);
466
+ },
467
+ handleOnClick: handleDelete,
468
+ label: t("actionsButtonDelete"),
469
+ order: 3,
470
+ variant: "destructive",
471
+ },
472
+ ], [handleView, handleEdit, handleDelete, t]);
474
473
  // ============================================================================
475
474
  // 1.4.9 EFFECTS
476
475
  // ============================================================================
@@ -482,7 +481,7 @@ export const useFamilyMemberModule = () => {
482
481
  if (!((_a = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _a === void 0 ? void 0 : _a.id))
483
482
  return;
484
483
  (_b = listFetchNowRef.current) === null || _b === void 0 ? void 0 : _b.call(listFetchNowRef);
485
- }, [listParams, (_c = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _c === void 0 ? void 0 : _c.id]);
484
+ }, [listParams, (_g = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _g === void 0 ? void 0 : _g.id]);
486
485
  // ============================================================================
487
486
  // 1.4.10 RETURN
488
487
  // ============================================================================
@@ -493,11 +492,9 @@ export const useFamilyMemberModule = () => {
493
492
  deleteLoading,
494
493
  handleChange,
495
494
  handleCloseDrawer,
496
- handleCreate,
497
495
  handleDelete,
498
496
  handleEdit,
499
497
  handleFilters,
500
- handleMoreActions,
501
498
  handlePageChange,
502
499
  handlePageLimitChange,
503
500
  handleSearch,
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Family member dates are calendar days stored at UTC midnight. Formatting
3
+ * them with the local timezone shifts the day in negative-offset zones.
4
+ */
5
+ /** `YYYY-MM-DD` for `<input type="date">`; empty string when invalid. */
6
+ export declare const toDateInput: (value?: string | Date | null) => string;
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Family member dates are calendar days stored at UTC midnight. Formatting
3
+ * them with the local timezone shifts the day in negative-offset zones.
4
+ */
5
+ /** `YYYY-MM-DD` for `<input type="date">`; empty string when invalid. */
6
+ export const toDateInput = (value) => {
7
+ if (!value)
8
+ return "";
9
+ const date = new Date(value);
10
+ if (Number.isNaN(date.getTime()))
11
+ return "";
12
+ return date.toISOString().slice(0, 10);
13
+ };
@@ -17,7 +17,7 @@ export const FamilyMemberFilter = () => {
17
17
  : filterEnabled
18
18
  ? "true"
19
19
  : "false";
20
- return (_jsx("div", { className: "space-y-4", children: _jsx("div", { className: "grid grid-cols-1 gap-4", children: _jsx(EnhancedRadio, { label: t("filterOptionEnabled"), name: "filterEnabled", value: filterEnabledValue, options: [
20
+ return (_jsx("div", { className: "space-y-4", children: _jsx("div", { className: "grid grid-cols-1 gap-4", children: _jsx(EnhancedRadio, { label: t("filterRecordStateLabel"), name: "filterEnabled", value: filterEnabledValue, options: [
21
21
  { label: t("filterOptionAll"), value: "undefined" },
22
22
  { label: t("filterOptionEnabled"), value: "true" },
23
23
  { label: t("filterOptionDisabled"), value: "false" },
@@ -6,16 +6,39 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
6
6
  * Create and edit form for family member records.
7
7
  */
8
8
  import { EnhancedCheckbox } from "@appcorp/shadcn/components/enhanced-checkbox";
9
+ import { EnhancedCombobox } from "@appcorp/shadcn/components/enhanced-combobox";
9
10
  import { EnhancedInput } from "@appcorp/shadcn/components/enhanced-input";
10
11
  import { useFamilyMemberModule } from "./context";
11
12
  import { useTranslations } from "next-intl";
12
13
  import { formatPhone } from "@react-pakistan/util-functions/general/format-phone";
13
14
  import { getTranslatedError } from "../../utils/get-translated-error";
15
+ import { FAMILY_MEMBER_ROLE_OPTIONS, GENDER_OPTIONS } from "./constants";
16
+ import { toDateInput } from "./date";
14
17
  export const FamilyMemberForm = () => {
15
18
  const { handleChange, state } = useFamilyMemberModule();
16
- const { bloodGroup, dateOfBirth, email, emergencyPhone, enabled, errors, firstName, gender, idNumber, isPrimary, lastName, occupation, phone, relationship, role, } = state;
19
+ const { bloodGroup, dateOfBirth, email, emergencyPhone, enabled, errors, firstName, gender, hasStudentProfile, idNumber, isPrimary, lastName, occupation, phone, relationship, role, } = state;
17
20
  const t = useTranslations("familyMember");
18
- return (_jsxs("div", { className: "space-y-4", children: [_jsxs("div", { className: "space-y-4", children: [_jsx("h3", { className: "text-lg font-semibold", children: t("formSectionPersonalInformation") }), _jsxs("div", { className: "grid grid-cols-1 gap-4 md:grid-cols-2", children: [_jsx(EnhancedInput, { error: getTranslatedError({ errors, key: "firstName", t }), id: "firstName", info: t("formFirstNameInfo"), label: t("formFirstNameLabel"), onChange: (e) => handleChange("firstName", e.target.value), placeholder: t("formFirstNamePlaceholder"), required: true, value: firstName }), _jsx(EnhancedInput, { error: getTranslatedError({ errors, key: "lastName", t }), id: "lastName", info: t("formLastNameInfo"), label: t("formLastNameLabel"), onChange: (e) => handleChange("lastName", e.target.value), placeholder: t("formLastNamePlaceholder"), required: true, value: lastName })] }), _jsxs("div", { className: "grid grid-cols-1 gap-4 md:grid-cols-2", children: [_jsx(EnhancedInput, { error: getTranslatedError({ errors, key: "role", t }), id: "role", info: t("formRoleInfo"), label: t("formRoleLabel"), onChange: (e) => handleChange("role", e.target.value), placeholder: t("formRolePlaceholder"), required: true, value: role }), _jsx(EnhancedInput, { error: getTranslatedError({ errors, key: "dateOfBirth", t }), id: "dateOfBirth", info: t("formDateOfBirthInfo"), label: t("formDateOfBirthLabel"), onChange: (e) => handleChange("dateOfBirth", e.target.value), onClick: (e) => { var _a, _b; return (_b = (_a = e.currentTarget).showPicker) === null || _b === void 0 ? void 0 : _b.call(_a); }, placeholder: "YYYY-MM-DD", type: "date", value: dateOfBirth })] }), _jsxs("div", { className: "grid grid-cols-1 gap-4 md:grid-cols-2", children: [_jsx(EnhancedInput, { error: getTranslatedError({ errors, key: "gender", t }), id: "gender", info: t("formGenderInfo"), label: t("formGenderLabel"), onChange: (e) => handleChange("gender", e.target.value), placeholder: t("formGenderPlaceholder"), value: gender }), _jsx(EnhancedInput, { error: getTranslatedError({ errors, key: "bloodGroup", t }), id: "bloodGroup", info: t("formBloodGroupInfo"), label: t("formBloodGroupLabel"), onChange: (e) => handleChange("bloodGroup", e.target.value), placeholder: t("formBloodGroupPlaceholder"), value: bloodGroup })] }), _jsx(EnhancedInput, { error: getTranslatedError({ errors, key: "idNumber", t }), id: "idNumber", info: t("formIdNumberInfo"), label: t("formIdNumberLabel"), onChange: (e) => handleChange("idNumber", e.target.value), placeholder: t("formIdNumberPlaceholder"), value: idNumber })] }), _jsxs("div", { className: "space-y-4", children: [_jsx("h3", { className: "text-lg font-semibold", children: t("formSectionContactInformation") }), _jsxs("div", { className: "grid grid-cols-1 gap-4 md:grid-cols-2", children: [_jsx(EnhancedInput, { error: getTranslatedError({ errors, key: "phone", t }), id: "phone", info: t("formPhoneInfo"), label: t("formPhoneLabel"), onChange: (e) => {
21
+ const roleLabelMap = {
22
+ FATHER: t("formRoleOptionFather"),
23
+ MOTHER: t("formRoleOptionMother"),
24
+ GUARDIAN: t("formRoleOptionGuardian"),
25
+ STUDENT: t("formRoleOptionStudent"),
26
+ };
27
+ const genderLabelMap = {
28
+ MALE: t("formGenderOptionMale"),
29
+ FEMALE: t("formGenderOptionFemale"),
30
+ OTHER: t("formGenderOptionOther"),
31
+ PREFER_NOT_TO_SAY: t("formGenderOptionPreferNotToSay"),
32
+ };
33
+ return (_jsxs("div", { className: "space-y-4", children: [_jsxs("div", { className: "space-y-4", children: [_jsx("h3", { className: "text-lg font-semibold", children: t("formSectionPersonalInformation") }), _jsxs("div", { className: "grid grid-cols-1 gap-4 md:grid-cols-2", children: [_jsx(EnhancedInput, { error: getTranslatedError({ errors, key: "firstName", t }), id: "firstName", info: t("formFirstNameInfo"), label: t("formFirstNameLabel"), onChange: (e) => handleChange("firstName", e.target.value), placeholder: t("formFirstNamePlaceholder"), required: true, value: firstName }), _jsx(EnhancedInput, { error: getTranslatedError({ errors, key: "lastName", t }), id: "lastName", info: t("formLastNameInfo"), label: t("formLastNameLabel"), onChange: (e) => handleChange("lastName", e.target.value), placeholder: t("formLastNamePlaceholder"), required: true, value: lastName })] }), _jsxs("div", { className: "grid grid-cols-1 gap-4 md:grid-cols-2", children: [_jsx(EnhancedCombobox, { disabled: hasStudentProfile, emptyText: t("formNoRoleEmpty"), error: getTranslatedError({ errors, key: "role", t }), id: "role", info: hasStudentProfile
34
+ ? t("formRoleStudentLockedInfo")
35
+ : t("formRoleInfo"), label: t("formRoleLabel"), onValueChange: (value) => handleChange("role", value), options: FAMILY_MEMBER_ROLE_OPTIONS.map((opt) => ({
36
+ value: opt.value,
37
+ label: roleLabelMap[opt.value] || opt.label,
38
+ })), placeholder: t("formRolePlaceholder"), required: true, searchPlaceholder: t("formRolePlaceholder"), value: role }), _jsx(EnhancedInput, { error: getTranslatedError({ errors, key: "dateOfBirth", t }), id: "dateOfBirth", info: t("formDateOfBirthInfo"), label: t("formDateOfBirthLabel"), onChange: (e) => handleChange("dateOfBirth", e.target.value), onClick: (e) => { var _a, _b; return (_b = (_a = e.currentTarget).showPicker) === null || _b === void 0 ? void 0 : _b.call(_a); }, placeholder: "YYYY-MM-DD", type: "date", value: toDateInput(dateOfBirth) })] }), _jsxs("div", { className: "grid grid-cols-1 gap-4 md:grid-cols-2", children: [_jsx(EnhancedCombobox, { emptyText: t("formNoGenderEmpty"), error: getTranslatedError({ errors, key: "gender", t }), id: "gender", info: t("formGenderInfo"), label: t("formGenderLabel"), onValueChange: (value) => handleChange("gender", value), options: GENDER_OPTIONS.map((opt) => ({
39
+ value: opt.value,
40
+ label: genderLabelMap[opt.value] || opt.label,
41
+ })), placeholder: t("formGenderPlaceholder"), searchPlaceholder: t("formGenderPlaceholder"), value: gender }), _jsx(EnhancedInput, { error: getTranslatedError({ errors, key: "bloodGroup", t }), id: "bloodGroup", info: t("formBloodGroupInfo"), label: t("formBloodGroupLabel"), onChange: (e) => handleChange("bloodGroup", e.target.value), placeholder: t("formBloodGroupPlaceholder"), value: bloodGroup })] }), _jsx(EnhancedInput, { error: getTranslatedError({ errors, key: "idNumber", t }), id: "idNumber", info: t("formIdNumberInfo"), label: t("formIdNumberLabel"), onChange: (e) => handleChange("idNumber", e.target.value), placeholder: t("formIdNumberPlaceholder"), value: idNumber })] }), _jsxs("div", { className: "space-y-4", children: [_jsx("h3", { className: "text-lg font-semibold", children: t("formSectionContactInformation") }), _jsxs("div", { className: "grid grid-cols-1 gap-4 md:grid-cols-2", children: [_jsx(EnhancedInput, { error: getTranslatedError({ errors, key: "phone", t }), id: "phone", info: t("formPhoneInfo"), label: t("formPhoneLabel"), onChange: (e) => {
19
42
  var _a;
20
43
  return handleChange("phone", ((_a = formatPhone(e.target.value)) === null || _a === void 0 ? void 0 : _a.international) || e.target.value);
21
44
  }, placeholder: t("formPhonePlaceholder"), type: "tel", value: phone }), _jsx(EnhancedInput, { error: getTranslatedError({ errors, key: "email", t }), id: "email", info: t("formEmailInfo"), label: t("formEmailLabel"), onChange: (e) => handleChange("email", e.target.value), placeholder: t("formEmailPlaceholder"), type: "email", value: email })] }), _jsx(EnhancedInput, { error: getTranslatedError({ errors, key: "emergencyPhone", t }), id: "emergencyPhone", info: t("formEmergencyPhoneInfo"), label: t("formEmergencyPhoneLabel"), onChange: (e) => {
@@ -20,17 +20,26 @@ import { createGenericModulePage, } from "@react-pakistan/util-functions/factory
20
20
  import { useFamilyMemberModule, FamilyMemberProvider, FAMILY_MEMBER_ACTION_TYPES, } from "./context";
21
21
  import { FamilyMemberFilter } from "./filter";
22
22
  import { FamilyMemberForm } from "./form";
23
- import { FamilyMemberMoreActions } from "./more-actions";
24
23
  import { FamilyMemberView } from "./view";
25
24
  import { resolveRbacPermissions } from "../../utils/resolve-rbac-permissions";
26
25
  import { RbacNoAccess } from "../../components/rbac-no-access";
27
26
  // ============================================================================
28
27
  // TABLE COLUMN CONFIGURATION (static — no runtime deps)
29
28
  // ============================================================================
29
+ const formatRole = (value) => {
30
+ const role = String(value !== null && value !== void 0 ? value : "");
31
+ if (!role)
32
+ return "—";
33
+ return role.charAt(0) + role.slice(1).toLowerCase().replace(/_/g, " ");
34
+ };
30
35
  const tableBodyCols = [
31
36
  { componentType: COMPONENT_TYPE.ID, key: "id" },
32
37
  { componentType: COMPONENT_TYPE.BOLD_TEXT, key: ["firstName", "lastName"] },
33
- { componentType: COMPONENT_TYPE.TEXT, key: "role" },
38
+ {
39
+ componentType: COMPONENT_TYPE.TEXT,
40
+ key: "role",
41
+ textFormatter: formatRole,
42
+ },
34
43
  { componentType: COMPONENT_TYPE.TEXT, key: "email" },
35
44
  { componentType: COMPONENT_TYPE.TEXT, key: "phone" },
36
45
  { componentType: COMPONENT_TYPE.BOOLEAN, key: "isPrimary" },
@@ -43,7 +52,6 @@ const tableBodyCols = [
43
52
  const createComponentInstances = () => ({
44
53
  filter: _jsx(FamilyMemberFilter, {}),
45
54
  form: _jsx(FamilyMemberForm, {}),
46
- moreActions: _jsx(FamilyMemberMoreActions, {}),
47
55
  view: _jsx(FamilyMemberView, {}),
48
56
  });
49
57
  const createFamilyMemberConfig = ({ dispatch, drawerButtonCancel, drawerButtonSave, drawerFilterDescription, drawerFilterTitle, drawerFormDescription, drawerFormTitle, drawerMoreActionsDescription, drawerMoreActionsTitle, drawerViewDescription, drawerViewTitle, tableColumnHeaderActions, tableColumnHeaderEmail, tableColumnHeaderEnabled, tableColumnHeaderFirstName, tableColumnHeaderId, tableColumnHeaderPhone, tableColumnHeaderPrimaryContact, tableColumnHeaderRole, tableDescription, tableSearchPlaceholder, tableTitle, }) => {
@@ -71,7 +79,7 @@ const createFamilyMemberConfig = ({ dispatch, drawerButtonCancel, drawerButtonSa
71
79
  drawerViewTitle,
72
80
  filterContent: components.filter,
73
81
  formContent: components.form,
74
- moreActionsContent: components.moreActions,
82
+ moreActionsContent: null,
75
83
  saveLabel: drawerButtonSave,
76
84
  searchPlaceholder: tableSearchPlaceholder,
77
85
  tableDescription,
package/constants.d.ts CHANGED
@@ -48,13 +48,9 @@ export declare const EXPENSE_API_ROUTES: {
48
48
  };
49
49
  export declare const FAMILY_API_ROUTES: {
50
50
  readonly UNIT: "/api/v1/family";
51
- readonly BULK: "/api/v1/family/bulk";
52
- readonly BULK_STATUS: (jobId: string) => string;
53
51
  };
54
52
  export declare const FAMILY_MEMBER_API_ROUTES: {
55
53
  readonly UNIT: "/api/v1/family-member";
56
- readonly BULK: "/api/v1/family-member/bulk";
57
- readonly BULK_STATUS: (jobId: string) => string;
58
54
  };
59
55
  export declare const FEE_STRUCTURE_API_ROUTES: {
60
56
  readonly CLASS: "/api/v1/class";
package/constants.js CHANGED
@@ -51,13 +51,9 @@ export const EXPENSE_API_ROUTES = {
51
51
  };
52
52
  export const FAMILY_API_ROUTES = {
53
53
  UNIT: "/api/v1/family",
54
- BULK: "/api/v1/family/bulk",
55
- BULK_STATUS: (jobId) => `/api/v1/family/bulk/${jobId}`,
56
54
  };
57
55
  export const FAMILY_MEMBER_API_ROUTES = {
58
56
  UNIT: "/api/v1/family-member",
59
- BULK: "/api/v1/family-member/bulk",
60
- BULK_STATUS: (jobId) => `/api/v1/family-member/bulk/${jobId}`,
61
57
  };
62
58
  export const FEE_STRUCTURE_API_ROUTES = {
63
59
  CLASS: "/api/v1/class",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@appcorp/fusion-storybook",
3
- "version": "0.5.17",
3
+ "version": "0.5.19",
4
4
  "scripts": {
5
5
  "build-storybook": "storybook build",
6
6
  "build:next": "next build",