@appcorp/fusion-storybook 0.3.12 → 0.3.13

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.
@@ -7,7 +7,7 @@ export declare const useStudentFeeModule: () => {
7
7
  clearSearch: () => void;
8
8
  closeDrawer: () => void;
9
9
  deleteLoading: boolean;
10
- handleChange: (field: string, value: string | number | boolean | PAYMENT_STATUS | FEE_RISK_LEVEL | null | undefined) => void;
10
+ handleChange: (field: string, value: string | number | boolean | PAYMENT_STATUS | FEE_RISK_LEVEL | null | undefined) => Promise<void>;
11
11
  handleCreate: () => void;
12
12
  handleCreateMonthly: () => void;
13
13
  handleCreateSingleEntry: () => void;
@@ -2,7 +2,7 @@
2
2
  import { useCallback, useEffect, useMemo, useRef } from "react";
3
3
  import { useTheme } from "next-themes";
4
4
  import { useTranslations } from "next-intl";
5
- import { validateForm, isCreatedOrUpdated, } from "@react-pakistan/util-functions";
5
+ import { validateForm, isCreatedOrUpdated, API_METHODS, fetchData, } from "@react-pakistan/util-functions";
6
6
  import { useModuleEntityV2, } from "@react-pakistan/util-functions/hooks/use-module-entity-v2";
7
7
  import { useDebounce } from "@react-pakistan/util-functions/hooks/use-debounce";
8
8
  import { generateThemeToast, TOAST_VARIANT, } from "@appcorp/shadcn/lib/toast-utils";
@@ -230,8 +230,8 @@ export const useStudentFeeModule = () => {
230
230
  // ============================================================================
231
231
  // 1.4.6 HANDLERS
232
232
  // ============================================================================
233
- const handleChange = useCallback((field, value) => {
234
- var _a, _b, _c, _d, _e;
233
+ const handleChange = useCallback(async (field, value) => {
234
+ var _a, _b, _c, _d;
235
235
  dispatch({
236
236
  type: STUDENT_FEE_ACTION_TYPES.SET_ERRORS,
237
237
  payload: { errors: {} },
@@ -281,22 +281,29 @@ export const useStudentFeeModule = () => {
281
281
  });
282
282
  }
283
283
  }
284
- catch (_f) {
284
+ catch (_e) {
285
285
  // silent fallback
286
286
  }
287
287
  }
288
288
  if (field === "studentProfileId" && typeof value === "string" && value) {
289
289
  try {
290
+ const { data } = await fetchData({
291
+ url: "/api/v1/student-profile",
292
+ method: API_METHODS.GET,
293
+ headers: { "Content-Type": "application/json" },
294
+ params: { id: value, workspaceId: workspace === null || workspace === void 0 ? void 0 : workspace.id },
295
+ });
296
+ const familyId = (data === null || data === void 0 ? void 0 : data.studentProfile.familyMember.familyId) || "";
290
297
  const studentProfile = (_b = getCachedStudentProfilesSync().items) === null || _b === void 0 ? void 0 : _b.find((s) => s.id === value);
291
298
  dispatch({
292
299
  type: STUDENT_FEE_ACTION_TYPES.SET_INPUT_FIELD,
293
300
  payload: {
294
301
  key: "familyId",
295
- value: (_c = studentProfile === null || studentProfile === void 0 ? void 0 : studentProfile.familyMember) === null || _c === void 0 ? void 0 : _c.familyId,
302
+ value: familyId,
296
303
  },
297
304
  });
298
305
  if (studentProfile === null || studentProfile === void 0 ? void 0 : studentProfile.discountCode) {
299
- const discountCode = (_d = discountCodes.items) === null || _d === void 0 ? void 0 : _d.find((code) => code.code === studentProfile.discountCode && code.enabled);
306
+ const discountCode = (_c = discountCodes.items) === null || _c === void 0 ? void 0 : _c.find((code) => code.code === studentProfile.discountCode && code.enabled);
300
307
  if (discountCode) {
301
308
  dispatch({
302
309
  type: STUDENT_FEE_ACTION_TYPES.SET_INPUT_FIELD,
@@ -327,13 +334,13 @@ export const useStudentFeeModule = () => {
327
334
  }
328
335
  }
329
336
  }
330
- catch (_g) {
337
+ catch (_f) {
331
338
  // silent fallback
332
339
  }
333
340
  }
334
341
  if (field === "discountCodeId" && typeof value === "string" && value) {
335
342
  try {
336
- const discountCode = (_e = discountCodes.items) === null || _e === void 0 ? void 0 : _e.find((code) => code.id === value && code.enabled);
343
+ const discountCode = (_d = discountCodes.items) === null || _d === void 0 ? void 0 : _d.find((code) => code.id === value && code.enabled);
337
344
  if (discountCode) {
338
345
  const originalFee = Number(currentState.originalFee) || 0;
339
346
  let discountAmount = discountCode.discountType === DISCOUNT_TYPE.PERCENTAGE
@@ -355,7 +362,7 @@ export const useStudentFeeModule = () => {
355
362
  });
356
363
  }
357
364
  }
358
- catch (_h) {
365
+ catch (_g) {
359
366
  // silent fallback
360
367
  }
361
368
  }
@@ -592,7 +599,6 @@ export const useStudentFeeModule = () => {
592
599
  });
593
600
  },
594
601
  errorCallback: (errors) => {
595
- console.log("errors", errors);
596
602
  dispatch({
597
603
  type: STUDENT_FEE_ACTION_TYPES.SET_ERRORS,
598
604
  payload: { errors },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@appcorp/fusion-storybook",
3
- "version": "0.3.12",
3
+ "version": "0.3.13",
4
4
  "scripts": {
5
5
  "build-storybook": "storybook build",
6
6
  "build:next": "next build",