@appcorp/fusion-storybook 0.4.5 → 0.4.6

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.
@@ -34,6 +34,8 @@ export declare const STUDENT_FEE_ACTION_TYPES: {
34
34
  disableSaveButton: boolean;
35
35
  drawer: string | null;
36
36
  errors: Record<string, string>;
37
+ keepPosting: boolean;
38
+ computerNumber: string;
37
39
  amount: number;
38
40
  amountDue: number;
39
41
  amountPaid: number;
@@ -66,6 +68,8 @@ export declare const STUDENT_FEE_ACTION_TYPES: {
66
68
  disableSaveButton: boolean;
67
69
  drawer: string | null;
68
70
  errors: Record<string, string>;
71
+ keepPosting: boolean;
72
+ computerNumber: string;
69
73
  amount: number;
70
74
  amountDue: number;
71
75
  amountPaid: number;
@@ -100,6 +104,8 @@ export declare const STUDENT_FEE_ACTION_TYPES: {
100
104
  disableSaveButton: boolean;
101
105
  drawer: string | null;
102
106
  errors: Record<string, string>;
107
+ keepPosting: boolean;
108
+ computerNumber: string;
103
109
  amount: number;
104
110
  amountDue: number;
105
111
  amountPaid: number;
@@ -132,6 +138,8 @@ export declare const STUDENT_FEE_ACTION_TYPES: {
132
138
  disableSaveButton: boolean;
133
139
  drawer: string | null;
134
140
  errors: Record<string, string>;
141
+ keepPosting: boolean;
142
+ computerNumber: string;
135
143
  amount: number;
136
144
  amountDue: number;
137
145
  amountPaid: number;
@@ -164,6 +172,8 @@ export declare const STUDENT_FEE_ACTION_TYPES: {
164
172
  disableSaveButton: boolean;
165
173
  drawer: string | null;
166
174
  errors: Record<string, string>;
175
+ keepPosting: boolean;
176
+ computerNumber: string;
167
177
  amount: number;
168
178
  amountDue: number;
169
179
  amountPaid: number;
@@ -30,6 +30,8 @@ const studentFeeConfig = {
30
30
  disableSaveButton: false,
31
31
  drawer: null,
32
32
  errors: {},
33
+ keepPosting: false,
34
+ computerNumber: "",
33
35
  // Form State
34
36
  amount: 0,
35
37
  amountDue: 0,
@@ -46,6 +46,8 @@ export declare const useStudentFeeModule: () => {
46
46
  disableSaveButton: boolean;
47
47
  drawer: string | null;
48
48
  errors: Record<string, string>;
49
+ keepPosting: boolean;
50
+ computerNumber: string;
49
51
  amount: number;
50
52
  amountDue: number;
51
53
  amountPaid: number;
@@ -540,7 +540,37 @@ export const useStudentFeeModule = () => {
540
540
  return;
541
541
  }
542
542
  showToast(t("messagesStudentFeeUpdated"), TOAST_VARIANT.SUCCESS);
543
- resetFormAndCloseDrawer();
543
+ if (state.keepPosting) {
544
+ const today = new Date();
545
+ const todayStr = `${today.getFullYear()}-${String(today.getMonth() + 1).padStart(2, "0")}-${String(today.getDate()).padStart(2, "0")}`;
546
+ dispatch({
547
+ type: STUDENT_FEE_ACTION_TYPES.SET_INPUT_FIELD,
548
+ payload: { key: "computerNumber", value: "" },
549
+ });
550
+ dispatch({
551
+ type: STUDENT_FEE_ACTION_TYPES.SET_INPUT_FIELD,
552
+ payload: { key: "studentFeesSingleEntry", value: [] },
553
+ });
554
+ dispatch({
555
+ type: STUDENT_FEE_ACTION_TYPES.SET_INPUT_FIELD,
556
+ payload: { key: "amountPaid", value: 0 },
557
+ });
558
+ dispatch({
559
+ type: STUDENT_FEE_ACTION_TYPES.SET_INPUT_FIELD,
560
+ payload: { key: "paidAt", value: todayStr },
561
+ });
562
+ dispatch({
563
+ type: STUDENT_FEE_ACTION_TYPES.SET_INPUT_FIELD,
564
+ payload: { key: "remarks", value: "" },
565
+ });
566
+ dispatch({
567
+ type: STUDENT_FEE_ACTION_TYPES.SET_INPUT_FIELD,
568
+ payload: { key: "status", value: PAYMENT_STATUS.PAID },
569
+ });
570
+ }
571
+ else {
572
+ resetFormAndCloseDrawer();
573
+ }
544
574
  listFetchNow === null || listFetchNow === void 0 ? void 0 : listFetchNow();
545
575
  }
546
576
  catch (_b) {
@@ -564,6 +594,7 @@ export const useStudentFeeModule = () => {
564
594
  state.paidAt,
565
595
  state.remarks,
566
596
  state.status,
597
+ state.keepPosting,
567
598
  ]);
568
599
  // ============================================================================
569
600
  // 1.4.6 HEADER & ROW ACTIONS
@@ -6,10 +6,11 @@ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-run
6
6
  * Filter UI for the student-fee list. Supports filterEnabled (radio) and
7
7
  * filterStatus (payment status combobox).
8
8
  */
9
- import { useEffect, useMemo, useRef, useState } from "react";
9
+ import { useEffect, useMemo, useRef } from "react";
10
10
  import { STUDENT_FEE_ACTION_TYPES, useStudentFeeModule } from "./context";
11
11
  import { useTranslations } from "next-intl";
12
12
  import { useEnhancedCombobox } from "@appcorp/shadcn/hooks/use-enhanced-combobox";
13
+ import { EnhancedCheckbox } from "@appcorp/shadcn/components/enhanced-checkbox";
13
14
  import { EnhancedTextarea } from "@appcorp/shadcn/components/enhanced-textarea";
14
15
  import { EnhancedInput } from "@appcorp/shadcn/components/enhanced-input";
15
16
  import { getCachedWorkspaceSync } from "../workspace/cache";
@@ -26,8 +27,7 @@ export const StudentFeeSingle = () => {
26
27
  const workspace = getCachedWorkspaceSync();
27
28
  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 : "";
28
29
  const t = useTranslations("studentFee");
29
- const [computerNumber, setComputerNumber] = useState("");
30
- const debouncedComputerNumber = useDebounce(computerNumber, 800);
30
+ const debouncedComputerNumber = useDebounce(state.computerNumber, 800);
31
31
  const { fetchNow: fetchByComputerNumber, data: feeByComputerNumber, loading: fetchingByCN, } = useFetch(STUDENT_FEE_API_ROUTES.BY_COMPUTER_NUMBER, {
32
32
  method: API_METHODS.GET,
33
33
  });
@@ -81,7 +81,7 @@ export const StudentFeeSingle = () => {
81
81
  payload: { key: "status", value: PAYMENT_STATUS.PAID },
82
82
  });
83
83
  }, [feeByComputerNumber, dispatch, accumulatedAmount, state.paidAt]);
84
- const isStale = computerNumber !== debouncedComputerNumber;
84
+ const isStale = state.computerNumber !== debouncedComputerNumber;
85
85
  const hasData = !!feeByComputerNumber &&
86
86
  !!debouncedComputerNumber &&
87
87
  !isStale &&
@@ -152,7 +152,7 @@ export const StudentFeeSingle = () => {
152
152
  },
153
153
  value: state.status,
154
154
  });
155
- 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: "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: accumulatedAmount + (accumulatedFine !== null && accumulatedFine !== void 0 ? accumulatedFine : 0), type: "number", step: "0.01" }), _jsx(EnhancedInput, { id: "amountPaid", info: t("formAmountPaidInfo"), label: t("formAmountPaidLabel"), value: state.amountPaid || 0, 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: (accumulatedAmount !== null && accumulatedAmount !== void 0 ? accumulatedAmount : 0) +
155
+ return (_jsxs("div", { className: "grid grid-cols-1 gap-4", children: [_jsx(EnhancedCheckbox, { checked: state.keepPosting, id: "keepPosting", info: t("formKeepPostingInfo"), label: t("formKeepPostingLabel"), onCheckedChange: (checked) => handleChange("keepPosting", !!checked) }), _jsx(EnhancedInput, { id: "computerNumber", info: t("formComputerNumberInfo"), label: t("formComputerNumberLabel"), onChange: (e) => handleChange("computerNumber", e.target.value), placeholder: t("formComputerNumberPlaceholder"), type: "number", required: true, value: state.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: "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: accumulatedAmount + (accumulatedFine !== null && accumulatedFine !== void 0 ? accumulatedFine : 0), type: "number", step: "0.01" }), _jsx(EnhancedInput, { id: "amountPaid", info: t("formAmountPaidInfo"), label: t("formAmountPaidLabel"), value: state.amountPaid || 0, 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: (accumulatedAmount !== null && accumulatedAmount !== void 0 ? accumulatedAmount : 0) +
156
156
  (accumulatedFine !== null && accumulatedFine !== void 0 ? accumulatedFine : 0) -
157
157
  Number(state.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, { id: "paidAt", info: t("formPaidAtInfo"), label: t("formPaidAtLabel"), onChange: (e) => handleChange("paidAt", e.target.value), onClick: (e) => { var _a, _b; return (_b = (_a = e.currentTarget).showPicker) === null || _b === void 0 ? void 0 : _b.call(_a); }, type: "date", value: state.paidAt || "" }), statusCombo, _jsx(EnhancedTextarea, { id: "remarks", label: t("formRemarksLabel"), value: state.remarks || "", onChange: (e) => handleChange("remarks", e.target.value) })] })) : null] }));
158
158
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@appcorp/fusion-storybook",
3
- "version": "0.4.5",
3
+ "version": "0.4.6",
4
4
  "scripts": {
5
5
  "build-storybook": "storybook build",
6
6
  "build:next": "next build",