@appcorp/fusion-storybook 0.2.71 → 0.2.73
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.
|
@@ -10,7 +10,7 @@ import { EnhancedInput } from "@appcorp/shadcn/components/enhanced-input";
|
|
|
10
10
|
import { EnhancedCheckbox } from "@appcorp/shadcn/components/enhanced-checkbox";
|
|
11
11
|
import { EnhancedTextarea } from "@appcorp/shadcn/components/enhanced-textarea";
|
|
12
12
|
import { useEnhancedCombobox } from "@appcorp/shadcn/hooks/use-enhanced-combobox";
|
|
13
|
-
import {
|
|
13
|
+
import { useEffect } from "react";
|
|
14
14
|
import { useStudentFeeModule } from "./context";
|
|
15
15
|
import { PAYMENT_STATUS_OPTIONS } from "./constants";
|
|
16
16
|
import { STUDENT_FEE_API_ROUTES, DISCOUNT_CODE_API_ROUTES, FEE_STRUCTURE_API_ROUTES, STUDENT_PROFILE_API_ROUTES, } from "../../constants";
|
|
@@ -20,7 +20,7 @@ import { DISCOUNT_TYPE, } from "../../type";
|
|
|
20
20
|
import { useTranslations } from "next-intl";
|
|
21
21
|
import { useFetch } from "@react-pakistan/util-functions/hooks/use-fetch";
|
|
22
22
|
export const StudentFeeForm = () => {
|
|
23
|
-
var _a, _b;
|
|
23
|
+
var _a, _b, _c, _d, _e;
|
|
24
24
|
const { state, handleChange } = useStudentFeeModule();
|
|
25
25
|
const { amount, amountDue, amountPaid, discountAmount, discountCodeId, dueDate, enabled, errors, familyId, feeStructureId, remarks, status, studentProfileId, } = state;
|
|
26
26
|
const workspace = getCachedWorkspaceSync();
|
|
@@ -34,51 +34,48 @@ export const StudentFeeForm = () => {
|
|
|
34
34
|
CANCELLED: t("formOptionCancelled"),
|
|
35
35
|
REFUNDED: t("formOptionRefunded"),
|
|
36
36
|
};
|
|
37
|
-
const { data: studentProfiles } = useFetch("/api/v1/student-profile", {
|
|
37
|
+
const { fetchNow: studentProfileFetchNow, data: studentProfiles } = useFetch("/api/v1/student-profile", {
|
|
38
38
|
params: { workspaceId: workspace === null || workspace === void 0 ? void 0 : workspace.id },
|
|
39
39
|
method: API_METHODS.GET,
|
|
40
40
|
});
|
|
41
|
-
const { data: feeStructures } = useFetch("/api/v1/fee-structure", {
|
|
41
|
+
const { fetchNow: feeStructureFetchNow, data: feeStructures } = useFetch("/api/v1/fee-structure", {
|
|
42
42
|
params: { workspaceId: workspace === null || workspace === void 0 ? void 0 : workspace.id },
|
|
43
43
|
method: API_METHODS.GET,
|
|
44
44
|
});
|
|
45
|
-
const { data: discountCodes } = useFetch("/api/v1/discount-code", {
|
|
45
|
+
const { fetchNow: discountCodeFetchNow, data: discountCodes } = useFetch("/api/v1/discount-code", {
|
|
46
46
|
params: { workspaceId: workspace === null || workspace === void 0 ? void 0 : workspace.id },
|
|
47
47
|
method: API_METHODS.GET,
|
|
48
48
|
});
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
})
|
|
55
|
-
var _a, _b;
|
|
56
|
-
return ({
|
|
57
|
-
id: s.id,
|
|
58
|
-
name: `${s.computerNumber} - ${(_a = s.familyMember) === null || _a === void 0 ? void 0 : _a.firstName} ${(_b = s.familyMember) === null || _b === void 0 ? void 0 : _b.lastName}` ||
|
|
59
|
-
s.id,
|
|
60
|
-
});
|
|
61
|
-
}), [studentProfiles, familyId]);
|
|
49
|
+
useEffect(() => {
|
|
50
|
+
studentProfileFetchNow();
|
|
51
|
+
feeStructureFetchNow();
|
|
52
|
+
discountCodeFetchNow();
|
|
53
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
54
|
+
}, []);
|
|
62
55
|
const { enhancedComboboxElement: studentProfileIdCombo } = useEnhancedCombobox({
|
|
63
56
|
emptyText: t("formNoStudentEmpty"),
|
|
64
57
|
id: "studentProfileId",
|
|
65
58
|
info: t("formStudentInfo"),
|
|
66
59
|
label: t("formStudentLabel"),
|
|
67
60
|
onValueChange: (value) => handleChange("studentProfileId", value),
|
|
68
|
-
options:
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
61
|
+
options: (_c = studentProfiles === null || studentProfiles === void 0 ? void 0 : studentProfiles.items) === null || _c === void 0 ? void 0 : _c.map((s) => {
|
|
62
|
+
var _a, _b;
|
|
63
|
+
return ({
|
|
64
|
+
value: s.id,
|
|
65
|
+
label: `${(_a = s === null || s === void 0 ? void 0 : s.familyMember) === null || _a === void 0 ? void 0 : _a.firstName} ${(_b = s === null || s === void 0 ? void 0 : s.familyMember) === null || _b === void 0 ? void 0 : _b.lastName}`,
|
|
66
|
+
});
|
|
67
|
+
}),
|
|
72
68
|
placeholder: t("formStudentPlaceholder"),
|
|
73
69
|
required: true,
|
|
74
70
|
searchEndpoint: STUDENT_PROFILE_API_ROUTES.UNIT,
|
|
75
71
|
searchPlaceholder: t("formSearchStudentsPlaceholder"),
|
|
76
72
|
formatSearchResult: (item) => {
|
|
77
73
|
var _a, _b;
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
74
|
+
const student = item;
|
|
75
|
+
return {
|
|
76
|
+
label: `${(_a = student === null || student === void 0 ? void 0 : student.familyMember) === null || _a === void 0 ? void 0 : _a.firstName} ${(_b = student === null || student === void 0 ? void 0 : student.familyMember) === null || _b === void 0 ? void 0 : _b.lastName}`,
|
|
77
|
+
value: student.id,
|
|
78
|
+
};
|
|
82
79
|
},
|
|
83
80
|
value: studentProfileId || "",
|
|
84
81
|
});
|
|
@@ -88,20 +85,20 @@ export const StudentFeeForm = () => {
|
|
|
88
85
|
info: t("formFeeStructureInfo"),
|
|
89
86
|
label: t("formFeeStructureLabel"),
|
|
90
87
|
onValueChange: (value) => handleChange("feeStructureId", value),
|
|
91
|
-
options: feeStructures === null || feeStructures === void 0 ? void 0 : feeStructures.map((fs) => ({
|
|
88
|
+
options: (_d = feeStructures === null || feeStructures === void 0 ? void 0 : feeStructures.items) === null || _d === void 0 ? void 0 : _d.map((fs) => ({
|
|
92
89
|
value: fs.id,
|
|
93
|
-
label: fs.name
|
|
90
|
+
label: fs.name,
|
|
94
91
|
})),
|
|
95
92
|
placeholder: t("formFeeStructurePlaceholder"),
|
|
96
93
|
required: true,
|
|
97
94
|
searchEndpoint: FEE_STRUCTURE_API_ROUTES.UNIT,
|
|
98
95
|
searchPlaceholder: t("formSearchFeeStructuresPlaceholder"),
|
|
99
96
|
formatSearchResult: (item) => {
|
|
100
|
-
|
|
101
|
-
return
|
|
102
|
-
label:
|
|
103
|
-
value:
|
|
104
|
-
}
|
|
97
|
+
const feeStructure = item;
|
|
98
|
+
return {
|
|
99
|
+
label: feeStructure.name,
|
|
100
|
+
value: feeStructure.id,
|
|
101
|
+
};
|
|
105
102
|
},
|
|
106
103
|
value: feeStructureId || "",
|
|
107
104
|
});
|
|
@@ -111,7 +108,7 @@ export const StudentFeeForm = () => {
|
|
|
111
108
|
info: t("formDiscountCodeInfo"),
|
|
112
109
|
label: t("formDiscountCodeLabel"),
|
|
113
110
|
onValueChange: (value) => handleChange("discountCodeId", value),
|
|
114
|
-
options: (discountCodes === null || discountCodes === void 0 ? void 0 : discountCodes.map((code) => ({
|
|
111
|
+
options: ((_e = discountCodes === null || discountCodes === void 0 ? void 0 : discountCodes.items) === null || _e === void 0 ? void 0 : _e.map((code) => ({
|
|
115
112
|
value: code.id,
|
|
116
113
|
label: `${code.code} - ${code.discountValue}${code.discountType === DISCOUNT_TYPE.PERCENTAGE ? "%" : currency}`,
|
|
117
114
|
}))) || [],
|
|
@@ -119,11 +116,11 @@ export const StudentFeeForm = () => {
|
|
|
119
116
|
searchEndpoint: DISCOUNT_CODE_API_ROUTES.UNIT,
|
|
120
117
|
searchPlaceholder: t("formSearchDiscountCodesPlaceholder"),
|
|
121
118
|
formatSearchResult: (item) => {
|
|
122
|
-
|
|
123
|
-
return
|
|
124
|
-
label:
|
|
125
|
-
value:
|
|
126
|
-
}
|
|
119
|
+
const discountCode = item;
|
|
120
|
+
return {
|
|
121
|
+
label: `${discountCode.code} - ${discountCode.discountValue}${discountCode.discountType === DISCOUNT_TYPE.PERCENTAGE ? "%" : currency}`,
|
|
122
|
+
value: discountCode.id,
|
|
123
|
+
};
|
|
127
124
|
},
|
|
128
125
|
value: discountCodeId || "",
|
|
129
126
|
});
|
|
@@ -35,7 +35,10 @@ const tableBodyCols = [
|
|
|
35
35
|
{ componentType: COMPONENT_TYPE.OBJECT, key: ["familyMember:firstName"] },
|
|
36
36
|
{ componentType: COMPONENT_TYPE.OBJECT, key: ["familyMember:lastName"] },
|
|
37
37
|
{ componentType: COMPONENT_TYPE.TEXT, key: "studentCode" },
|
|
38
|
-
{
|
|
38
|
+
{
|
|
39
|
+
componentType: COMPONENT_TYPE.OBJECT,
|
|
40
|
+
key: ["enrollments[0]:class:name", "enrollments[0]:section:name"],
|
|
41
|
+
},
|
|
39
42
|
{ componentType: COMPONENT_TYPE.BOOLEAN, key: "enabled" },
|
|
40
43
|
{ componentType: COMPONENT_TYPE.ACTIONS },
|
|
41
44
|
];
|