@appcorp/fusion-storybook 0.4.2 → 0.4.4

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.
@@ -36,10 +36,12 @@ export const PAYMENT_STATUS_OPTIONS_CONST = [
36
36
  import { FAMILY_MEMBER_ROLE } from "../../type";
37
37
  import { getCachedWorkspaceSync } from "../workspace/cache";
38
38
  export const formatStudentName = (_, row) => {
39
- var _a, _b;
39
+ var _a, _b, _c;
40
40
  const fee = row;
41
41
  const member = (_b = (_a = fee === null || fee === void 0 ? void 0 : fee.family) === null || _a === void 0 ? void 0 : _a.members) === null || _b === void 0 ? void 0 : _b.find(({ role }) => role === FAMILY_MEMBER_ROLE.STUDENT);
42
- return member ? `${member.firstName} ${member.lastName}` : "N/A";
42
+ return member
43
+ ? `${member.firstName} ${member.lastName} - ${(_c = member.studentProfile) === null || _c === void 0 ? void 0 : _c.computerNumber}`
44
+ : "N/A";
43
45
  };
44
46
  export const formatCurrency = (amount) => {
45
47
  var _a, _b, _c;
@@ -52,15 +52,11 @@ export const StudentFeeSingle = () => {
52
52
  return 0;
53
53
  return feeByComputerNumber.studentFees.reduce((sum, f) => { var _a; return sum + ((_a = f.amount) !== null && _a !== void 0 ? _a : 0); }, 0);
54
54
  }, [feeByComputerNumber]);
55
- const accumulatedFine = 0;
56
55
  useEffect(() => {
57
56
  var _a;
58
57
  if (!((_a = feeByComputerNumber === null || feeByComputerNumber === void 0 ? void 0 : feeByComputerNumber.studentFees) === null || _a === void 0 ? void 0 : _a.length))
59
58
  return;
60
- const total = accumulatedAmount + (accumulatedFine !== null && accumulatedFine !== void 0 ? accumulatedFine : 0);
61
- const initialStatus = total > 0 ? PAYMENT_STATUS.PAID : PAYMENT_STATUS.PENDING;
62
- const today = new Date();
63
- const todayStr = `${today.getFullYear()}-${String(today.getMonth() + 1).padStart(2, "0")}-${String(today.getDate()).padStart(2, "0")}`;
59
+ const total = accumulatedAmount + 0;
64
60
  dispatch({
65
61
  type: STUDENT_FEE_ACTION_TYPES.SET_INPUT_FIELD,
66
62
  payload: {
@@ -74,20 +70,17 @@ export const StudentFeeSingle = () => {
74
70
  });
75
71
  dispatch({
76
72
  type: STUDENT_FEE_ACTION_TYPES.SET_INPUT_FIELD,
77
- payload: { key: "status", value: initialStatus },
73
+ payload: { key: "paidAt", value: state.paidAt },
78
74
  });
79
75
  dispatch({
80
76
  type: STUDENT_FEE_ACTION_TYPES.SET_INPUT_FIELD,
81
- payload: {
82
- key: "paidAt",
83
- value: initialStatus === PAYMENT_STATUS.PAID ? todayStr : "",
84
- },
77
+ payload: { key: "remarks", value: "" },
85
78
  });
86
79
  dispatch({
87
80
  type: STUDENT_FEE_ACTION_TYPES.SET_INPUT_FIELD,
88
- payload: { key: "remarks", value: "" },
81
+ payload: { key: "status", value: PAYMENT_STATUS.PAID },
89
82
  });
90
- }, [feeByComputerNumber, dispatch, accumulatedAmount, accumulatedFine]);
83
+ }, [feeByComputerNumber, dispatch, accumulatedAmount, state.paidAt]);
91
84
  const isStale = computerNumber !== debouncedComputerNumber;
92
85
  const hasData = !!feeByComputerNumber &&
93
86
  !!debouncedComputerNumber &&
@@ -125,23 +118,16 @@ export const StudentFeeSingle = () => {
125
118
  const d = new Date(rawDate);
126
119
  return `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, "0")}-${String(d.getDate()).padStart(2, "0")}`;
127
120
  };
121
+ // const accumulatedFine = useMemo(() => {
122
+ // if (!response?.studentFees?.length) return 0;
123
+ // return response.studentFees.reduce((sum, f) => sum + (f.fine ?? 0), 0);
124
+ // }, [response]);
125
+ const accumulatedFine = 0;
128
126
  const handleUpdateAmountPaid = (value) => {
129
127
  const parsed = parseFloat(value);
130
128
  if (isNaN(parsed))
131
129
  return;
132
130
  handleChange("amountPaid", parsed);
133
- const total = (accumulatedAmount !== null && accumulatedAmount !== void 0 ? accumulatedAmount : 0) + (accumulatedFine !== null && accumulatedFine !== void 0 ? accumulatedFine : 0);
134
- const newStatus = parsed <= 0
135
- ? PAYMENT_STATUS.PENDING
136
- : parsed >= total
137
- ? PAYMENT_STATUS.PAID
138
- : PAYMENT_STATUS.PARTIAL;
139
- handleChange("status", newStatus);
140
- if (newStatus === PAYMENT_STATUS.PAID) {
141
- const today = new Date();
142
- const todayStr = `${today.getFullYear()}-${String(today.getMonth() + 1).padStart(2, "0")}-${String(today.getDate()).padStart(2, "0")}`;
143
- handleChange("paidAt", todayStr);
144
- }
145
131
  };
146
132
  const { enhancedComboboxElement: statusCombo } = useEnhancedCombobox({
147
133
  emptyText: t("formNoStatusEmpty"),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@appcorp/fusion-storybook",
3
- "version": "0.4.2",
3
+ "version": "0.4.4",
4
4
  "scripts": {
5
5
  "build-storybook": "storybook build",
6
6
  "build:next": "next build",