@appcorp/fusion-storybook 0.2.94 → 0.2.96

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.
@@ -29,45 +29,50 @@ export const useStudentFeeModule = () => {
29
29
  // ============================================================================
30
30
  // 1.4.1 STATE & CORE HOOKS
31
31
  // ============================================================================
32
- var _a;
32
+ var _a, _b, _c, _d;
33
33
  const context = useStudentFeeContext();
34
34
  const { dispatch } = context;
35
35
  const state = context.state;
36
36
  const t = useTranslations("studentFee");
37
37
  const { theme } = useTheme();
38
38
  const workspace = getCachedWorkspaceSync();
39
- const schoolId = ((_a = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _a === void 0 ? void 0 : _a.id) || "";
40
39
  const listFetchNowRef = useRef(null);
41
40
  const debouncedQuery = useDebounce(state.searchQuery, 800);
42
41
  // ============================================================================
43
42
  // 1.4.2 API PARAMETERS
44
43
  // ============================================================================
45
- const listParams = useMemo(() => (Object.assign(Object.assign(Object.assign({ currentPage: state.currentPage, pageLimit: state.pageLimit, schoolId }, (debouncedQuery ? { searchQuery: debouncedQuery } : {})), (state.filterEnabled !== undefined
46
- ? { filterEnabled: state.filterEnabled }
47
- : {})), (state.filterStatus ? { status: state.filterStatus } : {}))), [
44
+ const listParams = useMemo(() => {
45
+ var _a;
46
+ 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
47
+ ? { filterEnabled: state.filterEnabled }
48
+ : {})), (state.filterStatus ? { status: state.filterStatus } : {})));
49
+ }, [
48
50
  state.currentPage,
49
51
  state.filterEnabled,
50
52
  state.filterStatus,
51
53
  state.pageLimit,
52
54
  debouncedQuery,
53
- schoolId,
55
+ (_a = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _a === void 0 ? void 0 : _a.id,
54
56
  ]);
55
- const updateParams = useMemo(() => ({
56
- amount: Number(state.amount),
57
- amountDue: Number(state.amountDue),
58
- amountPaid: Number(state.amountPaid),
59
- discountAmount: Number(state.discountAmount),
60
- discountCodeId: state.discountCodeId,
61
- dueDate: state.dueDate,
62
- enabled: state.enabled,
63
- familyId: state.familyId,
64
- feeStructureId: state.feeStructureId,
65
- id: state.id,
66
- remarks: state.remarks || null,
67
- schoolId,
68
- status: state.status,
69
- studentProfileId: state.studentProfileId,
70
- }), [state, schoolId]);
57
+ const updateParams = useMemo(() => {
58
+ var _a;
59
+ return ({
60
+ amount: Number(state.amount),
61
+ amountDue: Number(state.amountDue),
62
+ amountPaid: Number(state.amountPaid),
63
+ discountAmount: Number(state.discountAmount),
64
+ discountCodeId: state.discountCodeId,
65
+ dueDate: state.dueDate,
66
+ enabled: state.enabled,
67
+ familyId: state.familyId,
68
+ feeStructureId: state.feeStructureId,
69
+ id: state.id,
70
+ remarks: state.remarks || null,
71
+ schoolId: ((_a = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _a === void 0 ? void 0 : _a.id) || "",
72
+ status: state.status,
73
+ studentProfileId: state.studentProfileId,
74
+ });
75
+ }, [state, (_b = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _b === void 0 ? void 0 : _b.id]);
71
76
  const byIdParams = useMemo(() => ({ id: state.id }), [state.id]);
72
77
  const deleteParams = useMemo(() => ({ id: state.id }), [state.id]);
73
78
  // ============================================================================
@@ -96,6 +101,11 @@ export const useStudentFeeModule = () => {
96
101
  });
97
102
  }, [dispatch]);
98
103
  const resetRecordFormState = useCallback(() => {
104
+ var _a, _b;
105
+ const days = (_a = workspace === null || workspace === void 0 ? void 0 : workspace.dueDateLength) !== null && _a !== void 0 ? _a : 0;
106
+ const dueDate = new Date();
107
+ if (days > 0)
108
+ dueDate.setDate(dueDate.getDate() + days);
99
109
  dispatch({
100
110
  type: STUDENT_FEE_ACTION_TYPES.SET_ERRORS,
101
111
  payload: { errors: {} },
@@ -113,7 +123,7 @@ export const useStudentFeeModule = () => {
113
123
  amountPaid: 0,
114
124
  discountAmount: 0,
115
125
  discountCodeId: null,
116
- dueDate: new Date().toISOString().slice(0, 10),
126
+ dueDate: dueDate.toISOString().slice(0, 10),
117
127
  enabled: true,
118
128
  familyId: "",
119
129
  feeStructureId: "",
@@ -126,13 +136,13 @@ export const useStudentFeeModule = () => {
126
136
  reliabilityScore: null,
127
137
  remarks: null,
128
138
  riskLevel: null,
129
- schoolId,
139
+ schoolId: ((_b = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _b === void 0 ? void 0 : _b.id) || "",
130
140
  status: PAYMENT_STATUS.PENDING,
131
141
  studentProfileId: "",
132
142
  },
133
143
  },
134
144
  });
135
- }, [dispatch, schoolId]);
145
+ }, [dispatch, workspace === null || workspace === void 0 ? void 0 : workspace.dueDateLength, (_c = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _c === void 0 ? void 0 : _c.id]);
136
146
  // ============================================================================
137
147
  // 1.4.4 API CALLBACKS
138
148
  // ============================================================================
@@ -448,11 +458,12 @@ export const useStudentFeeModule = () => {
448
458
  });
449
459
  }, [updateFetchNow]);
450
460
  const handleCreate = useCallback(() => {
461
+ resetRecordFormState();
451
462
  dispatch({
452
463
  type: STUDENT_FEE_ACTION_TYPES.SET_DRAWER,
453
464
  payload: { drawer: STUDENT_FEE_DRAWER.FORM_DRAWER },
454
465
  });
455
- }, [dispatch]);
466
+ }, [dispatch, resetRecordFormState]);
456
467
  const handleView = useCallback((row) => {
457
468
  resetRecordFormState();
458
469
  byIdFetchNow === null || byIdFetchNow === void 0 ? void 0 : byIdFetchNow(undefined, { params: { id: row === null || row === void 0 ? void 0 : row.id } });
@@ -591,11 +602,11 @@ export const useStudentFeeModule = () => {
591
602
  listFetchNowRef.current = listFetchNow;
592
603
  }, [listFetchNow]);
593
604
  useEffect(() => {
594
- var _a;
595
- if (!schoolId)
605
+ var _a, _b;
606
+ if (!((_a = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _a === void 0 ? void 0 : _a.id))
596
607
  return;
597
- (_a = listFetchNowRef.current) === null || _a === void 0 ? void 0 : _a.call(listFetchNowRef);
598
- }, [dispatch, listParams, schoolId, showToast, t]);
608
+ (_b = listFetchNowRef.current) === null || _b === void 0 ? void 0 : _b.call(listFetchNowRef);
609
+ }, [dispatch, listParams, (_d = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _d === void 0 ? void 0 : _d.id, showToast, t]);
599
610
  // ============================================================================
600
611
  // 1.4.10 RETURN
601
612
  // ============================================================================
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@appcorp/fusion-storybook",
3
- "version": "0.2.94",
3
+ "version": "0.2.96",
4
4
  "scripts": {
5
5
  "build-storybook": "storybook build",
6
6
  "build:next": "next build",