@appcorp/fusion-storybook 0.1.13 → 0.1.14

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.
@@ -195,10 +195,85 @@ export const useAdmissionModule = () => {
195
195
  siblings: context.state.siblings || "",
196
196
  state: context.state.state || "",
197
197
  });
198
- }, [context.state, (_b = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _b === void 0 ? void 0 : _b.id]);
198
+ }, [
199
+ context.state.address,
200
+ context.state.admissionNotes,
201
+ context.state.status,
202
+ context.state.bForm,
203
+ context.state.city,
204
+ context.state.classForAdmission,
205
+ context.state.country,
206
+ context.state.discountCode,
207
+ context.state.dob,
208
+ context.state.emergencyContact,
209
+ context.state.enabled,
210
+ context.state.fatherCnic,
211
+ context.state.fatherFirstName,
212
+ context.state.fatherLastName,
213
+ context.state.fatherMobile,
214
+ context.state.fatherOccupation,
215
+ context.state.fatherOrganization,
216
+ context.state.firstName,
217
+ context.state.gender,
218
+ context.state.hafiz,
219
+ context.state.id,
220
+ context.state.lastName,
221
+ context.state.motherCnic,
222
+ context.state.motherFirstName,
223
+ context.state.motherLastName,
224
+ context.state.motherMobile,
225
+ context.state.notes,
226
+ context.state.orphan,
227
+ context.state.postalCode,
228
+ context.state.previousSchool,
229
+ context.state.registrationCode,
230
+ context.state.siblings,
231
+ context.state.state,
232
+ (_b = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _b === void 0 ? void 0 : _b.id,
233
+ ]);
199
234
  const byIdParams = useMemo(() => ({ id: context.state.id }), [context.state.id]);
200
235
  const deleteParams = useMemo(() => ({ id: context.state.id }), [context.state.id]);
201
236
  // ============================================================================
237
+ // UTILITIES
238
+ // ============================================================================
239
+ const showToast = useCallback((message, variant) => {
240
+ generateThemeToast({ description: message, variant });
241
+ }, []);
242
+ const setField = useCallback((key, value) => {
243
+ var _a, _b, _c;
244
+ let formatted = value === null
245
+ ? undefined
246
+ : value;
247
+ if ((key === "bForm" || key === "fatherCnic" || key === "motherCnic") &&
248
+ typeof value === "string" &&
249
+ value.length === 13) {
250
+ formatted = (_a = formatCnic(value)) !== null && _a !== void 0 ? _a : value;
251
+ }
252
+ if ((key === "fatherMobile" || key === "motherMobile") &&
253
+ typeof value === "string" &&
254
+ value.length >= 13) {
255
+ formatted = (_c = (_b = formatPhone(value, "PK")) === null || _b === void 0 ? void 0 : _b.international) !== null && _c !== void 0 ? _c : value;
256
+ }
257
+ context.dispatch({
258
+ type: ADMISSION_ACTION_TYPES.SET_INPUT_FIELD,
259
+ payload: { key, value: formatted || value },
260
+ });
261
+ }, [context]);
262
+ const resetFormAndCloseDrawer = useCallback(() => {
263
+ context.dispatch({
264
+ type: ADMISSION_ACTION_TYPES.SET_ERRORS,
265
+ payload: { errors: {} },
266
+ });
267
+ context.dispatch({
268
+ type: ADMISSION_ACTION_TYPES.SET_DISABLE_SAVE_BUTTON,
269
+ payload: { disabled: false },
270
+ });
271
+ context.dispatch({
272
+ type: ADMISSION_ACTION_TYPES.SET_DRAWER,
273
+ payload: { drawer: null },
274
+ });
275
+ }, [context]);
276
+ // ============================================================================
202
277
  // API CALLBACKS
203
278
  // ============================================================================
204
279
  const listCallback = ({ data, error }) => {
@@ -317,46 +392,6 @@ export const useAdmissionModule = () => {
317
392
  },
318
393
  });
319
394
  // ============================================================================
320
- // UTILITIES
321
- // ============================================================================
322
- const showToast = useCallback((message, variant) => {
323
- generateThemeToast({ description: message, variant });
324
- }, []);
325
- const resetFormAndCloseDrawer = useCallback(() => {
326
- context.dispatch({
327
- type: ADMISSION_ACTION_TYPES.SET_ERRORS,
328
- payload: { errors: {} },
329
- });
330
- context.dispatch({
331
- type: ADMISSION_ACTION_TYPES.SET_DISABLE_SAVE_BUTTON,
332
- payload: { disabled: false },
333
- });
334
- context.dispatch({
335
- type: ADMISSION_ACTION_TYPES.SET_DRAWER,
336
- payload: { drawer: null },
337
- });
338
- }, [context]);
339
- const setField = useCallback((key, value) => {
340
- var _a, _b, _c;
341
- let formatted = value === null
342
- ? undefined
343
- : value;
344
- if ((key === "bForm" || key === "fatherCnic" || key === "motherCnic") &&
345
- typeof value === "string" &&
346
- value.length === 13) {
347
- formatted = (_a = formatCnic(value)) !== null && _a !== void 0 ? _a : value;
348
- }
349
- if ((key === "fatherMobile" || key === "motherMobile") &&
350
- typeof value === "string" &&
351
- value.length >= 13) {
352
- formatted = (_c = (_b = formatPhone(value, "PK")) === null || _b === void 0 ? void 0 : _b.international) !== null && _c !== void 0 ? _c : value;
353
- }
354
- context.dispatch({
355
- type: ADMISSION_ACTION_TYPES.SET_INPUT_FIELD,
356
- payload: { key, value: formatted || value },
357
- });
358
- }, [context]);
359
- // ============================================================================
360
395
  // HANDLERS
361
396
  // ============================================================================
362
397
  const handleChange = useCallback((field, value) => {
@@ -724,7 +759,7 @@ export const useAdmissionModule = () => {
724
759
  showToast(t("messagesFetchFailed"), TOAST_VARIANT.ERROR);
725
760
  }
726
761
  })();
727
- }, [listParams, workspace === null || workspace === void 0 ? void 0 : workspace.id, t, showToast, context]);
762
+ }, [listParams, workspace === null || workspace === void 0 ? void 0 : workspace.id, t, showToast, context.dispatch]);
728
763
  // ============================================================================
729
764
  // RETURN
730
765
  // ============================================================================
@@ -88,16 +88,50 @@ const GenericAdmissionPage = createGenericModulePage();
88
88
  // ============================================================================
89
89
  const AdmissionPageInner = (props) => {
90
90
  const context = useAdmissionModule();
91
- // Memoize config creation
92
- const admissionConfig = useMemo(() => createAdmissionConfig(Object.assign({ dispatch: context.dispatch, drawer: context.state.drawer }, props)), [context.dispatch, context.state.drawer, props]);
93
- // Memoize permission check to avoid recalculation on every render
94
- const hasPermission = useMemo(() => resolveRbacPermissions({
91
+ // Memoize config creation - destructure props to avoid object reference changes
92
+ const admissionConfig = useMemo(() => createAdmissionConfig({
93
+ dispatch: context.dispatch,
94
+ drawer: context.state.drawer,
95
+ cancelLabel: props.cancelLabel,
96
+ drawerTitle: props.drawerTitle,
97
+ labelActions: props.labelActions,
98
+ labelClass: props.labelClass,
99
+ labelEnabled: props.labelEnabled,
100
+ labelFirstName: props.labelFirstName,
101
+ labelId: props.labelId,
102
+ labelLastName: props.labelLastName,
103
+ labelRegistrationCode: props.labelRegistrationCode,
104
+ labelStatus: props.labelStatus,
105
+ saveLabel: props.saveLabel,
106
+ searchPlaceholder: props.searchPlaceholder,
107
+ tableDescription: props.tableDescription,
108
+ tableTitle: props.tableTitle,
109
+ }), [
110
+ context.dispatch,
111
+ context.state.drawer,
112
+ props.cancelLabel,
113
+ props.drawerTitle,
114
+ props.labelActions,
115
+ props.labelClass,
116
+ props.labelEnabled,
117
+ props.labelFirstName,
118
+ props.labelId,
119
+ props.labelLastName,
120
+ props.labelRegistrationCode,
121
+ props.labelStatus,
122
+ props.saveLabel,
123
+ props.searchPlaceholder,
124
+ props.tableDescription,
125
+ props.tableTitle,
126
+ ]);
127
+ const hasPermission = resolveRbacPermissions({
95
128
  userRole: props.userRole,
96
129
  moduleName: "Admission",
97
- }), [props.userRole]);
130
+ });
98
131
  if (!hasPermission) {
99
132
  return _jsx(RbacNoAccess, { moduleName: "Admission" });
100
133
  }
134
+ console.log("Rendering AdmissionPageInner with config:", admissionConfig);
101
135
  return (_jsx("div", { className: "p-4", children: _jsx(GenericAdmissionPage, { overrideConfig: admissionConfig, context: context, tableBodyCols: tableBodyCols }) }));
102
136
  };
103
137
  export const AdmissionPage = (props) => (_jsx(AdmissionProvider, { children: _jsx(AdmissionPageInner, Object.assign({}, props)) }));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@appcorp/fusion-storybook",
3
- "version": "0.1.13",
3
+ "version": "0.1.14",
4
4
  "scripts": {
5
5
  "build-storybook": "storybook build",
6
6
  "build:next": "next build",