@appcorp/fusion-storybook 0.3.3 → 0.3.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.
@@ -13,13 +13,13 @@ 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;
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 : "";
20
20
  const t = useTranslations("studentFee");
21
21
  const [computerNumber, setComputerNumber] = useState("");
22
- const debouncedComputerNumber = useDebounce(computerNumber, 500);
22
+ const debouncedComputerNumber = useDebounce(computerNumber, 800);
23
23
  const { fetchNow: fetchByComputerNumber, data: feeByComputerNumber, loading: fetchingByCN, } = useFetch(STUDENT_FEE_API_ROUTES.BY_COMPUTER_NUMBER, {
24
24
  method: API_METHODS.GET,
25
25
  });
@@ -28,12 +28,16 @@ export const SingleEntryStudentFeeForm = () => {
28
28
  fetchByCNRef.current = fetchByComputerNumber;
29
29
  }, [fetchByComputerNumber]);
30
30
  useEffect(() => {
31
+ var _a;
31
32
  if (!debouncedComputerNumber)
32
33
  return;
33
34
  fetchByCNRef.current(undefined, {
34
- params: { computerNumber: debouncedComputerNumber },
35
+ params: {
36
+ computerNumber: debouncedComputerNumber,
37
+ schoolId: (_a = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _a === void 0 ? void 0 : _a.id,
38
+ },
35
39
  });
36
- }, [debouncedComputerNumber]);
40
+ }, [debouncedComputerNumber, (_c = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _c === void 0 ? void 0 : _c.id]);
37
41
  const isStale = computerNumber !== debouncedComputerNumber;
38
42
  const hasData = !!feeByComputerNumber &&
39
43
  !!debouncedComputerNumber &&
@@ -55,10 +59,10 @@ export const SingleEntryStudentFeeForm = () => {
55
59
  REFUNDED: t("formOptionRefunded"),
56
60
  };
57
61
  const studentName = (fee === null || fee === void 0 ? void 0 : fee.studentProfile)
58
- ? `${(_d = (_c = fee.studentProfile.familyMember) === null || _c === void 0 ? void 0 : _c.firstName) !== null && _d !== void 0 ? _d : ""} ${(_f = (_e = fee.studentProfile.familyMember) === null || _e === void 0 ? void 0 : _e.lastName) !== null && _f !== void 0 ? _f : ""}`.trim() ||
62
+ ? `${(_e = (_d = fee.studentProfile.familyMember) === null || _d === void 0 ? void 0 : _d.firstName) !== null && _e !== void 0 ? _e : ""} ${(_g = (_f = fee.studentProfile.familyMember) === null || _f === void 0 ? void 0 : _f.lastName) !== null && _g !== void 0 ? _g : ""}`.trim() ||
59
63
  fee.studentProfileId
60
64
  : (fee === null || fee === void 0 ? void 0 : fee.studentProfileId) || "";
61
- const feeStructureName = ((_g = fee === null || fee === void 0 ? void 0 : fee.feeStructure) === null || _g === void 0 ? void 0 : _g.name) || (fee === null || fee === void 0 ? void 0 : fee.feeStructureId) || "";
65
+ const feeStructureName = ((_h = fee === null || fee === void 0 ? void 0 : fee.feeStructure) === null || _h === void 0 ? void 0 : _h.name) || (fee === null || fee === void 0 ? void 0 : fee.feeStructureId) || "";
62
66
  const discountCodeLabel = (fee === null || fee === void 0 ? void 0 : fee.discountCode)
63
67
  ? `${fee.discountCode.code} - ${fee.discountCode.discountValue}${fee.discountCode.discountType === DISCOUNT_TYPE.PERCENTAGE ? "%" : currency}`
64
68
  : (fee === null || fee === void 0 ? void 0 : fee.discountCodeId) || "";
@@ -71,5 +75,5 @@ export const SingleEntryStudentFeeForm = () => {
71
75
  const d = rawDate instanceof Date ? rawDate : new Date(rawDate);
72
76
  return `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, "0")}-${String(d.getDate()).padStart(2, "0")}`;
73
77
  };
74
- 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 ? (_jsxs(_Fragment, { children: [_jsx(EnhancedInput, { disabled: true, id: "studentProfileId-readonly", label: t("formStudentLabel"), value: studentName }), _jsx(EnhancedInput, { disabled: true, id: "feeStructureId-readonly", label: t("formFeeStructureLabel"), value: feeStructureName }), _jsx(EnhancedInput, { disabled: true, id: "discountCodeId-readonly", label: t("formDiscountCodeLabel"), value: discountCodeLabel }), _jsx(EnhancedInput, { disabled: true, id: "discountAmount-readonly", label: t("formDiscountAmountLabel"), value: (_h = fee.discountAmount) !== null && _h !== void 0 ? _h : 0, type: "number", step: "0.01" }), _jsx(EnhancedInput, { disabled: true, id: "amount-readonly", info: t("formTotalAmountInfo"), label: t("formTotalAmountLabel"), value: fee.amount, type: "number", step: "0.01" }), _jsx(EnhancedInput, { disabled: true, id: "amountPaid-readonly", info: t("formAmountPaidInfo"), label: t("formAmountPaidLabel"), value: fee.amountPaid, type: "number", step: "0.01" }), _jsx(EnhancedInput, { disabled: true, id: "amountDue-readonly", info: t("formAmountDueInfo"), label: t("formAmountDueLabel"), value: fee.amountDue, type: "number", step: "0.01" }), _jsx(EnhancedInput, { disabled: true, id: "dueDate-readonly", label: t("formDueDateLabel"), value: formatDisplayDate(fee.dueDate), type: "date" }), _jsx(EnhancedInput, { disabled: true, id: "status-readonly", label: t("formStatusLabel"), value: statusDisplay }), _jsx(EnhancedTextarea, { disabled: true, id: "remarks-readonly", label: t("formRemarksLabel"), value: fee.remarks || "" })] })) : null] }));
78
+ 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 ? (_jsxs(_Fragment, { children: [_jsx(EnhancedInput, { disabled: true, id: "studentProfileId-readonly", label: t("formStudentLabel"), value: studentName }), _jsx(EnhancedInput, { disabled: true, id: "feeStructureId-readonly", label: t("formFeeStructureLabel"), value: feeStructureName }), _jsx(EnhancedInput, { disabled: true, id: "discountCodeId-readonly", label: t("formDiscountCodeLabel"), value: discountCodeLabel }), _jsx(EnhancedInput, { disabled: true, id: "discountAmount-readonly", label: t("formDiscountAmountLabel"), value: (_j = fee.discountAmount) !== null && _j !== void 0 ? _j : 0, type: "number", step: "0.01" }), _jsx(EnhancedInput, { disabled: true, id: "amount-readonly", info: t("formTotalAmountInfo"), label: t("formTotalAmountLabel"), value: fee.amount, type: "number", step: "0.01" }), _jsx(EnhancedInput, { disabled: true, id: "amountPaid-readonly", info: t("formAmountPaidInfo"), label: t("formAmountPaidLabel"), value: fee.amountPaid, type: "number", step: "0.01" }), _jsx(EnhancedInput, { disabled: true, id: "amountDue-readonly", info: t("formAmountDueInfo"), label: t("formAmountDueLabel"), value: fee.amountDue, type: "number", step: "0.01" }), _jsx(EnhancedInput, { disabled: true, id: "dueDate-readonly", label: t("formDueDateLabel"), value: formatDisplayDate(fee.dueDate), type: "date" }), _jsx(EnhancedInput, { disabled: true, id: "status-readonly", label: t("formStatusLabel"), value: statusDisplay }), _jsx(EnhancedTextarea, { disabled: true, id: "remarks-readonly", label: t("formRemarksLabel"), value: fee.remarks || "" })] })) : null] }));
75
79
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@appcorp/fusion-storybook",
3
- "version": "0.3.3",
3
+ "version": "0.3.4",
4
4
  "scripts": {
5
5
  "build-storybook": "storybook build",
6
6
  "build:next": "next build",