@appcorp/fusion-storybook 0.3.22 → 0.3.24

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.
@@ -13,7 +13,7 @@ import { useFetch } from "@react-pakistan/util-functions/hooks/use-fetch";
13
13
  import { useDebounce } from "@react-pakistan/util-functions/hooks/use-debounce";
14
14
  import { Loader2 } from "lucide-react";
15
15
  export const SingleEntryStudentFeeForm = () => {
16
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
16
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
17
17
  const { dispatch } = useStudentFeeModule();
18
18
  const workspace = getCachedWorkspaceSync();
19
19
  const currency = (_b = (_a = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _a === void 0 ? void 0 : _a.currency) !== null && _b !== void 0 ? _b : "";
@@ -50,16 +50,10 @@ export const SingleEntryStudentFeeForm = () => {
50
50
  : null;
51
51
  const profile = (_d = response === null || response === void 0 ? void 0 : response.studentProfile) !== null && _d !== void 0 ? _d : null;
52
52
  const fee = (_f = (_e = response === null || response === void 0 ? void 0 : response.studentFees) === null || _e === void 0 ? void 0 : _e[0]) !== null && _f !== void 0 ? _f : null;
53
- useEffect(() => {
54
- (async () => {
55
- var _a, _b;
56
- setAmountPaid(String(((_a = fee === null || fee === void 0 ? void 0 : fee.amount) !== null && _a !== void 0 ? _a : 0) + ((_b = fee === null || fee === void 0 ? void 0 : fee.fine) !== null && _b !== void 0 ? _b : 0)));
57
- })();
58
- }, [fee]);
59
53
  useEffect(() => {
60
54
  dispatch({
61
55
  type: STUDENT_FEE_ACTION_TYPES.SET_DISABLE_SAVE_BUTTON,
62
- payload: { disabled: !!fee },
56
+ payload: { disabled: false },
63
57
  });
64
58
  }, [fee, dispatch]);
65
59
  const paymentStatusLabelMap = {
@@ -86,6 +80,12 @@ export const SingleEntryStudentFeeForm = () => {
86
80
  const d = new Date(rawDate);
87
81
  return `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, "0")}-${String(d.getDate()).padStart(2, "0")}`;
88
82
  };
83
+ const accumulatedAmount = useMemo(() => {
84
+ var _a;
85
+ if (!((_a = response === null || response === void 0 ? void 0 : response.studentFees) === null || _a === void 0 ? void 0 : _a.length))
86
+ return 0;
87
+ return response.studentFees.reduce((sum, f) => { var _a, _b; return sum + ((_a = f.amount) !== null && _a !== void 0 ? _a : 0) + ((_b = f.fine) !== null && _b !== void 0 ? _b : 0); }, 0);
88
+ }, [response]);
89
89
  const accumulatedFine = useMemo(() => {
90
90
  var _a;
91
91
  if (!((_a = response === null || response === void 0 ? void 0 : response.studentFees) === null || _a === void 0 ? void 0 : _a.length))
@@ -98,7 +98,13 @@ export const SingleEntryStudentFeeForm = () => {
98
98
  return;
99
99
  setAmountPaid(value);
100
100
  };
101
- return (_jsxs("div", { className: "grid grid-cols-1 gap-4", children: [_jsx(EnhancedInput, { id: "computerNumber", info: t("formComputerNumberInfo"), label: t("formComputerNumberLabel"), onChange: (e) => setComputerNumber(e.target.value), placeholder: t("formComputerNumberPlaceholder"), type: "number", required: true, value: computerNumber }), fetchingByCN && debouncedComputerNumber ? (_jsx("div", { className: "flex items-center justify-center py-4", children: _jsx(Loader2, { className: "text-muted-foreground h-5 w-5 animate-spin" }) })) : null, fee && profile ? (_jsxs(_Fragment, { children: [_jsx(EnhancedInput, { readOnly: true, id: "studentProfileId-readonly", label: t("formStudentLabel"), value: studentName }), _jsx(EnhancedInput, { readOnly: true, id: "computerNumber-readonly", label: t("formComputerNumberLabel"), value: profile === null || profile === void 0 ? void 0 : profile.computerNumber, type: "number" }), _jsx(EnhancedInput, { readOnly: true, id: "feeStructureId-readonly", label: t("formFeeStructureLabel"), value: feeStructureName }), _jsx(EnhancedInput, { readOnly: true, id: "discountCodeId-readonly", label: t("formDiscountCodeLabel"), value: discountCodeLabel }), _jsx(EnhancedInput, { readOnly: true, id: "discountAmount-readonly", label: t("formDiscountAmountLabel"), value: (_h = fee === null || fee === void 0 ? void 0 : fee.discountAmount) !== null && _h !== void 0 ? _h : 0, type: "number", step: "0.01" }), _jsx(EnhancedInput, { readOnly: true, id: "accumulatedFine-readonly", info: t("formAccumulatedFineInfo"), label: t("formAccumulatedFineLabel"), value: accumulatedFine, type: "number", step: "0.01" }), _jsx(EnhancedInput, { readOnly: true, id: "amount-readonly", info: t("formTotalAmountInfo"), label: t("formTotalAmountLabel"), value: ((_j = fee === null || fee === void 0 ? void 0 : fee.amount) !== null && _j !== void 0 ? _j : 0) + ((_k = fee === null || fee === void 0 ? void 0 : fee.fine) !== null && _k !== void 0 ? _k : 0), type: "number", step: "0.01" }), _jsx(EnhancedInput, { id: "amountPaid", info: t("formAmountPaidInfo"), label: t("formAmountPaidLabel"), value: amountPaid, onChange: (e) => handleUpdateAmountPaid(e.target.value), type: "number", step: "0.01" }), _jsx(EnhancedInput, { readOnly: true, id: "amountDue-readonly", info: t("formAmountDueInfo"), label: t("formAmountDueLabel"), value: Number(fee === null || fee === void 0 ? void 0 : fee.amountDue) +
102
- ((_l = fee === null || fee === void 0 ? void 0 : fee.fine) !== null && _l !== void 0 ? _l : 0) -
101
+ useEffect(() => {
102
+ (async () => {
103
+ var _a;
104
+ setAmountPaid(String(((_a = fee === null || fee === void 0 ? void 0 : fee.amount) !== null && _a !== void 0 ? _a : 0) + (accumulatedFine !== null && accumulatedFine !== void 0 ? accumulatedFine : 0)));
105
+ })();
106
+ }, [fee, accumulatedFine]);
107
+ return (_jsxs("div", { className: "grid grid-cols-1 gap-4", children: [_jsx(EnhancedInput, { id: "computerNumber", info: t("formComputerNumberInfo"), label: t("formComputerNumberLabel"), onChange: (e) => setComputerNumber(e.target.value), placeholder: t("formComputerNumberPlaceholder"), type: "number", required: true, value: computerNumber }), fetchingByCN && debouncedComputerNumber ? (_jsx("div", { className: "flex items-center justify-center py-4", children: _jsx(Loader2, { className: "text-muted-foreground h-5 w-5 animate-spin" }) })) : null, fee && profile ? (_jsxs(_Fragment, { children: [_jsx(EnhancedInput, { readOnly: true, id: "studentProfileId-readonly", label: t("formStudentLabel"), value: studentName }), _jsx(EnhancedInput, { readOnly: true, id: "computerNumber-readonly", label: t("formComputerNumberLabel"), value: profile === null || profile === void 0 ? void 0 : profile.computerNumber, type: "number" }), _jsx(EnhancedInput, { readOnly: true, id: "feeStructureId-readonly", label: t("formFeeStructureLabel"), value: feeStructureName }), _jsx(EnhancedInput, { readOnly: true, id: "discountCodeId-readonly", label: t("formDiscountCodeLabel"), value: discountCodeLabel }), _jsx(EnhancedInput, { readOnly: true, id: "discountAmount-readonly", label: t("formDiscountAmountLabel"), value: (_h = fee === null || fee === void 0 ? void 0 : fee.discountAmount) !== null && _h !== void 0 ? _h : 0, type: "number", step: "0.01" }), _jsx(EnhancedInput, { readOnly: true, id: "accumulatedAmount-readonly", info: t("formAccumulatedAmountInfo"), label: t("formAccumulatedAmountLabel"), value: accumulatedAmount, type: "number", step: "0.01" }), _jsx(EnhancedInput, { readOnly: true, id: "accumulatedFine-readonly", info: t("formAccumulatedFineInfo"), label: t("formAccumulatedFineLabel"), value: accumulatedFine, type: "number", step: "0.01" }), _jsx(EnhancedInput, { readOnly: true, id: "amount-readonly", info: t("formTotalAmountInfo"), label: t("formTotalAmountLabel"), value: ((_j = fee === null || fee === void 0 ? void 0 : fee.amount) !== null && _j !== void 0 ? _j : 0) + (accumulatedFine !== null && accumulatedFine !== void 0 ? accumulatedFine : 0), type: "number", step: "0.01" }), _jsx(EnhancedInput, { id: "amountPaid", info: t("formAmountPaidInfo"), label: t("formAmountPaidLabel"), value: amountPaid, onChange: (e) => handleUpdateAmountPaid(e.target.value), type: "number", step: "0.01" }), _jsx(EnhancedInput, { readOnly: true, id: "amountDue-readonly", info: t("formAmountDueInfo"), label: t("formAmountDueLabel"), value: Number(fee === null || fee === void 0 ? void 0 : fee.amountDue) +
108
+ (accumulatedFine !== null && accumulatedFine !== void 0 ? accumulatedFine : 0) -
103
109
  parseFloat(amountPaid || "0"), type: "number", step: "0.01" }), _jsx(EnhancedInput, { readOnly: true, id: "dueDate-readonly", label: t("formDueDateLabel"), value: formatDisplayDate(fee === null || fee === void 0 ? void 0 : fee.dueDate), type: "date" }), _jsx(EnhancedInput, { readOnly: true, id: "status-readonly", label: t("formStatusLabel"), value: statusDisplay }), _jsx(EnhancedTextarea, { id: "remarks-readonly", label: t("formRemarksLabel"), value: remarks || "", onChange: (e) => setRemarks(e.target.value) })] })) : null] }));
104
110
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@appcorp/fusion-storybook",
3
- "version": "0.3.22",
3
+ "version": "0.3.24",
4
4
  "scripts": {
5
5
  "build-storybook": "storybook build",
6
6
  "build:next": "next build",