@appcorp/fusion-storybook 0.3.13 → 0.3.15
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,7 +29,7 @@ export const useStudentFeeModule = () => {
|
|
|
29
29
|
// ============================================================================
|
|
30
30
|
// 1.4.1 STATE & CORE HOOKS
|
|
31
31
|
// ============================================================================
|
|
32
|
-
var _a, _b, _c, _d, _e;
|
|
32
|
+
var _a, _b, _c, _d, _e, _f;
|
|
33
33
|
const context = useStudentFeeContext();
|
|
34
34
|
const { dispatch } = context;
|
|
35
35
|
const state = context.state;
|
|
@@ -231,7 +231,7 @@ export const useStudentFeeModule = () => {
|
|
|
231
231
|
// 1.4.6 HANDLERS
|
|
232
232
|
// ============================================================================
|
|
233
233
|
const handleChange = useCallback(async (field, value) => {
|
|
234
|
-
var _a, _b, _c, _d;
|
|
234
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
235
235
|
dispatch({
|
|
236
236
|
type: STUDENT_FEE_ACTION_TYPES.SET_ERRORS,
|
|
237
237
|
payload: { errors: {} },
|
|
@@ -281,20 +281,26 @@ export const useStudentFeeModule = () => {
|
|
|
281
281
|
});
|
|
282
282
|
}
|
|
283
283
|
}
|
|
284
|
-
catch (
|
|
284
|
+
catch (_h) {
|
|
285
285
|
// silent fallback
|
|
286
286
|
}
|
|
287
287
|
}
|
|
288
288
|
if (field === "studentProfileId" && typeof value === "string" && value) {
|
|
289
289
|
try {
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
290
|
+
// eslint-disable-next-line
|
|
291
|
+
let apiResponse;
|
|
292
|
+
(async () => {
|
|
293
|
+
var _a;
|
|
294
|
+
const response = await fetchData({
|
|
295
|
+
url: "/api/v1/student-profile",
|
|
296
|
+
method: API_METHODS.GET,
|
|
297
|
+
headers: { "Content-Type": "application/json" },
|
|
298
|
+
params: { id: value, schoolId: (_a = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _a === void 0 ? void 0 : _a.id },
|
|
299
|
+
});
|
|
300
|
+
apiResponse = response;
|
|
301
|
+
})();
|
|
302
|
+
const familyId = ((_d = (_c = (_b = apiResponse === null || apiResponse === void 0 ? void 0 : apiResponse.data) === null || _b === void 0 ? void 0 : _b.studentProfile) === null || _c === void 0 ? void 0 : _c.familyMember) === null || _d === void 0 ? void 0 : _d.familyId) || "";
|
|
303
|
+
const studentProfile = (_e = getCachedStudentProfilesSync().items) === null || _e === void 0 ? void 0 : _e.find((s) => s.id === value);
|
|
298
304
|
dispatch({
|
|
299
305
|
type: STUDENT_FEE_ACTION_TYPES.SET_INPUT_FIELD,
|
|
300
306
|
payload: {
|
|
@@ -303,7 +309,7 @@ export const useStudentFeeModule = () => {
|
|
|
303
309
|
},
|
|
304
310
|
});
|
|
305
311
|
if (studentProfile === null || studentProfile === void 0 ? void 0 : studentProfile.discountCode) {
|
|
306
|
-
const discountCode = (
|
|
312
|
+
const discountCode = (_f = discountCodes.items) === null || _f === void 0 ? void 0 : _f.find((code) => code.code === studentProfile.discountCode && code.enabled);
|
|
307
313
|
if (discountCode) {
|
|
308
314
|
dispatch({
|
|
309
315
|
type: STUDENT_FEE_ACTION_TYPES.SET_INPUT_FIELD,
|
|
@@ -334,13 +340,13 @@ export const useStudentFeeModule = () => {
|
|
|
334
340
|
}
|
|
335
341
|
}
|
|
336
342
|
}
|
|
337
|
-
catch (
|
|
343
|
+
catch (_j) {
|
|
338
344
|
// silent fallback
|
|
339
345
|
}
|
|
340
346
|
}
|
|
341
347
|
if (field === "discountCodeId" && typeof value === "string" && value) {
|
|
342
348
|
try {
|
|
343
|
-
const discountCode = (
|
|
349
|
+
const discountCode = (_g = discountCodes.items) === null || _g === void 0 ? void 0 : _g.find((code) => code.id === value && code.enabled);
|
|
344
350
|
if (discountCode) {
|
|
345
351
|
const originalFee = Number(currentState.originalFee) || 0;
|
|
346
352
|
let discountAmount = discountCode.discountType === DISCOUNT_TYPE.PERCENTAGE
|
|
@@ -362,7 +368,7 @@ export const useStudentFeeModule = () => {
|
|
|
362
368
|
});
|
|
363
369
|
}
|
|
364
370
|
}
|
|
365
|
-
catch (
|
|
371
|
+
catch (_k) {
|
|
366
372
|
// silent fallback
|
|
367
373
|
}
|
|
368
374
|
}
|
|
@@ -430,7 +436,7 @@ export const useStudentFeeModule = () => {
|
|
|
430
436
|
payload: { key: "amountDue", value: amountDue },
|
|
431
437
|
});
|
|
432
438
|
}
|
|
433
|
-
}, [dispatch, state]);
|
|
439
|
+
}, [dispatch, state, (_d = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _d === void 0 ? void 0 : _d.id]);
|
|
434
440
|
const handlePageChange = useCallback((page) => {
|
|
435
441
|
const nextPage = typeof page === "number" ? page : state.currentPage + 1;
|
|
436
442
|
dispatch({
|
|
@@ -584,7 +590,7 @@ export const useStudentFeeModule = () => {
|
|
|
584
590
|
payload: { disabled: false },
|
|
585
591
|
});
|
|
586
592
|
}
|
|
587
|
-
}, [dispatch, showToast, t, (
|
|
593
|
+
}, [dispatch, showToast, t, (_e = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _e === void 0 ? void 0 : _e.id, resetFormAndCloseDrawer]);
|
|
588
594
|
const handleSubmit = useCallback(() => {
|
|
589
595
|
dispatch({
|
|
590
596
|
type: STUDENT_FEE_ACTION_TYPES.SET_DISABLE_SAVE_BUTTON,
|
|
@@ -599,6 +605,7 @@ export const useStudentFeeModule = () => {
|
|
|
599
605
|
});
|
|
600
606
|
},
|
|
601
607
|
errorCallback: (errors) => {
|
|
608
|
+
console.log("_>>>,", errors);
|
|
602
609
|
dispatch({
|
|
603
610
|
type: STUDENT_FEE_ACTION_TYPES.SET_ERRORS,
|
|
604
611
|
payload: { errors },
|
|
@@ -685,7 +692,7 @@ export const useStudentFeeModule = () => {
|
|
|
685
692
|
if (!((_a = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _a === void 0 ? void 0 : _a.id))
|
|
686
693
|
return;
|
|
687
694
|
(_b = listFetchNowRef.current) === null || _b === void 0 ? void 0 : _b.call(listFetchNowRef);
|
|
688
|
-
}, [dispatch, listParams, (
|
|
695
|
+
}, [dispatch, listParams, (_f = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _f === void 0 ? void 0 : _f.id, showToast, t]);
|
|
689
696
|
// ============================================================================
|
|
690
697
|
// 1.4.10 RETURN
|
|
691
698
|
// ============================================================================
|