@appcorp/fusion-storybook 0.5.21 → 0.5.25
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.
- package/base-modules/school/cache.js +0 -1
- package/base-modules/school/context.d.ts +0 -2
- package/base-modules/school/context.js +77 -18
- package/base-modules/school/drawer.js +1 -3
- package/base-modules/school/form.js +4 -23
- package/base-modules/school/page.js +2 -2
- package/base-modules/section/context.d.ts +6 -0
- package/base-modules/section/context.js +66 -34
- package/base-modules/section/form.js +2 -2
- package/base-modules/section/more-actions.js +71 -16
- package/base-modules/section/page.js +7 -3
- package/base-modules/student-fee/context/student-fee-api-provider.js +20 -14
- package/base-modules/student-fee/context/use-student-fee-module.d.ts +3 -3
- package/base-modules/student-fee/context/use-student-fee-module.js +63 -30
- package/base-modules/student-fee/form.js +8 -24
- package/base-modules/student-fee/more-actions.js +9 -9
- package/base-modules/student-fee/page.js +1 -1
- package/base-modules/student-profile/constants.d.ts +2 -24
- package/base-modules/student-profile/constants.js +2 -68
- package/base-modules/student-profile/context/module-base.d.ts +10 -0
- package/base-modules/student-profile/context/module-base.js +2 -0
- package/base-modules/student-profile/context/use-student-profile-module.d.ts +3 -1
- package/base-modules/student-profile/context/use-student-profile-module.js +113 -71
- package/base-modules/student-profile/filter.js +5 -22
- package/base-modules/student-profile/form.js +22 -46
- package/base-modules/student-profile/page.js +2 -4
- package/constants.d.ts +3 -3
- package/constants.js +0 -2
- package/package.json +1 -1
- package/tsconfig.build.tsbuildinfo +1 -1
- package/utils/resolve-rbac-permissions.js +7 -4
- package/base-modules/school/filter.d.ts +0 -1
- package/base-modules/school/filter.js +0 -13
- package/base-modules/school/more-actions.d.ts +0 -1
- package/base-modules/school/more-actions.js +0 -13
- package/base-modules/student-profile/more-actions.d.ts +0 -1
- package/base-modules/student-profile/more-actions.js +0 -257
|
@@ -3,12 +3,13 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
3
3
|
import { EnhancedInput } from "@appcorp/shadcn/components/enhanced-input";
|
|
4
4
|
import { EnhancedCheckbox } from "@appcorp/shadcn/components/enhanced-checkbox";
|
|
5
5
|
import { EnhancedTextarea } from "@appcorp/shadcn/components/enhanced-textarea";
|
|
6
|
+
import { EnhancedCombobox } from "@appcorp/shadcn/components/enhanced-combobox";
|
|
6
7
|
import { useEnhancedCombobox } from "@appcorp/shadcn/hooks/use-enhanced-combobox";
|
|
7
8
|
import { useTranslations } from "next-intl";
|
|
8
9
|
import { useEffect } from "react";
|
|
9
10
|
import { useStudentProfileModule } from "./context";
|
|
10
11
|
import { STATUS_OPTIONS, GENDER_OPTIONS } from "./constants";
|
|
11
|
-
import {
|
|
12
|
+
import { DISCOUNT_CODE_API_ROUTES } from "../../constants";
|
|
12
13
|
import { formatPhone } from "@react-pakistan/util-functions/general/format-phone";
|
|
13
14
|
import { getTranslatedError } from "../../utils/get-translated-error";
|
|
14
15
|
import { getCachedWorkspaceSync } from "../workspace/cache";
|
|
@@ -16,7 +17,7 @@ import { API_METHODS } from "@react-pakistan/util-functions/constants/api-method
|
|
|
16
17
|
import { DISCOUNT_TYPE } from "../../type";
|
|
17
18
|
import { useFetch } from "@react-pakistan/util-functions/hooks/use-fetch";
|
|
18
19
|
export const StudentProfileForm = () => {
|
|
19
|
-
var _a, _b, _c;
|
|
20
|
+
var _a, _b, _c, _d, _e;
|
|
20
21
|
const t = useTranslations("studentProfile");
|
|
21
22
|
const genderLabelMap = {
|
|
22
23
|
MALE: t("formOptionMale"),
|
|
@@ -24,54 +25,28 @@ export const StudentProfileForm = () => {
|
|
|
24
25
|
OTHER: t("formOptionOther"),
|
|
25
26
|
};
|
|
26
27
|
const context = useStudentProfileModule();
|
|
27
|
-
const {
|
|
28
|
-
const stateValue = context.state.state;
|
|
28
|
+
const { dateOfBirth, discountCodeId, emergencyPhone, enabled, errors, firstName, gender, lastName, phone, remarks, status, } = context.state;
|
|
29
29
|
const { handleChange } = context;
|
|
30
|
-
const {
|
|
31
|
-
id: "gender",
|
|
32
|
-
info: t("formGenderInfo"),
|
|
33
|
-
label: t("formGenderLabel"),
|
|
34
|
-
onValueChange: (value) => handleChange("gender", value),
|
|
35
|
-
options: GENDER_OPTIONS.map((opt) => ({
|
|
30
|
+
const genderCombo = (_jsx(EnhancedCombobox, { emptyText: t("formGenderPlaceholder"), error: getTranslatedError({ errors, key: "gender", t }), id: "gender", info: t("formGenderInfo"), label: t("formGenderLabel"), onValueChange: (value) => handleChange("gender", value || null), options: GENDER_OPTIONS.map((opt) => ({
|
|
36
31
|
value: opt.value,
|
|
37
32
|
label: genderLabelMap[opt.value] || opt.label,
|
|
38
|
-
})),
|
|
39
|
-
|
|
40
|
-
searchEndpoint: STUDENT_PROFILE_API_ROUTES.UNIT,
|
|
41
|
-
formatSearchResult: (item) => {
|
|
42
|
-
var _a, _b;
|
|
43
|
-
return ({
|
|
44
|
-
label: String((_a = item.label) !== null && _a !== void 0 ? _a : ""),
|
|
45
|
-
value: String((_b = item.value) !== null && _b !== void 0 ? _b : ""),
|
|
46
|
-
});
|
|
47
|
-
},
|
|
48
|
-
value: gender,
|
|
49
|
-
});
|
|
50
|
-
const { enhancedComboboxElement: statusCombo } = useEnhancedCombobox({
|
|
51
|
-
id: "status",
|
|
52
|
-
info: t("formStatusInfo"),
|
|
53
|
-
label: t("formStatusLabel"),
|
|
54
|
-
onValueChange: (value) => handleChange("status", value),
|
|
55
|
-
options: STATUS_OPTIONS.map((opt) => ({
|
|
33
|
+
})), placeholder: t("formGenderPlaceholder"), value: gender || "" }));
|
|
34
|
+
const statusCombo = (_jsx(EnhancedCombobox, { emptyText: t("formStatusPlaceholder"), error: getTranslatedError({ errors, key: "status", t }), id: "status", info: t("formStatusInfo"), label: t("formStatusLabel"), onValueChange: (value) => handleChange("status", value), options: STATUS_OPTIONS.map((opt) => ({
|
|
56
35
|
value: opt.value,
|
|
57
|
-
label: opt.
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
});
|
|
68
|
-
},
|
|
69
|
-
value: status,
|
|
70
|
-
});
|
|
36
|
+
label: opt.value === "ACTIVE"
|
|
37
|
+
? t("formOptionActive")
|
|
38
|
+
: opt.value === "INACTIVE"
|
|
39
|
+
? t("formOptionInactive")
|
|
40
|
+
: opt.value === "GRADUATED"
|
|
41
|
+
? t("formOptionGraduated")
|
|
42
|
+
: opt.value === "TRANSFERRED"
|
|
43
|
+
? t("formOptionTransferred")
|
|
44
|
+
: t("formOptionDropped"),
|
|
45
|
+
})), placeholder: t("formStatusPlaceholder"), required: true, value: status }));
|
|
71
46
|
const workspace = getCachedWorkspaceSync();
|
|
72
47
|
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 : "";
|
|
73
48
|
const { fetchNow: discountCodeFetchNow, data: discountCodes } = useFetch(DISCOUNT_CODE_API_ROUTES.UNIT, {
|
|
74
|
-
params: {
|
|
49
|
+
params: { schoolId: (_c = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _c === void 0 ? void 0 : _c.id },
|
|
75
50
|
method: API_METHODS.GET,
|
|
76
51
|
});
|
|
77
52
|
useEffect(() => {
|
|
@@ -83,13 +58,14 @@ export const StudentProfileForm = () => {
|
|
|
83
58
|
id: "discountCodeId",
|
|
84
59
|
info: "Optional discount code to apply",
|
|
85
60
|
label: "Discount Code",
|
|
86
|
-
onValueChange: (value) => handleChange("discountCodeId", value),
|
|
87
|
-
options: ((
|
|
61
|
+
onValueChange: (value) => handleChange("discountCodeId", value || null),
|
|
62
|
+
options: ((_d = discountCodes === null || discountCodes === void 0 ? void 0 : discountCodes.items) !== null && _d !== void 0 ? _d : []).map((code) => ({
|
|
88
63
|
value: code.id,
|
|
89
64
|
label: `${code.code} - ${code.discountValue}${code.discountType === DISCOUNT_TYPE.PERCENTAGE ? "%" : currency}`,
|
|
90
65
|
})),
|
|
91
66
|
placeholder: "Select discount code",
|
|
92
67
|
searchEndpoint: DISCOUNT_CODE_API_ROUTES.UNIT,
|
|
68
|
+
searchParams: { schoolId: (_e = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _e === void 0 ? void 0 : _e.id },
|
|
93
69
|
searchPlaceholder: "Search discount codes...",
|
|
94
70
|
formatSearchResult: (item) => {
|
|
95
71
|
const discountCode = item;
|
|
@@ -110,5 +86,5 @@ export const StudentProfileForm = () => {
|
|
|
110
86
|
}, placeholder: t("formPhonePlaceholder"), type: "tel", value: phone || "" }), _jsx(EnhancedInput, { error: getTranslatedError({ errors, key: "emergencyPhone", t }), id: "emergencyPhone", info: t("formEmergencyPhoneInfo"), label: t("formEmergencyPhoneLabel"), onChange: (e) => {
|
|
111
87
|
var _a;
|
|
112
88
|
return handleChange("emergencyPhone", ((_a = formatPhone(e.target.value)) === null || _a === void 0 ? void 0 : _a.international) || e.target.value);
|
|
113
|
-
}, placeholder: t("formEmergencyPhonePlaceholder"), type: "tel", value: emergencyPhone || "" })] })
|
|
89
|
+
}, placeholder: t("formEmergencyPhonePlaceholder"), type: "tel", value: emergencyPhone || "" })] })] }), _jsxs("div", { className: "space-y-4", children: [_jsx("h3", { className: "text-lg font-semibold", children: t("formSectionAcademicInformation") }), _jsxs("div", { className: "grid grid-cols-1 gap-4", children: [statusCombo, discountCodeIdCombo, _jsx(EnhancedTextarea, { error: getTranslatedError({ errors, key: "remarks", t }), id: "remarks", info: t("formRemarksInfo"), label: t("formRemarksLabel"), onChange: (e) => handleChange("remarks", e.target.value), placeholder: t("formRemarksPlaceholder"), rows: 4, value: remarks || "" })] }), _jsx(EnhancedCheckbox, { checked: enabled, info: t("formEnabledInfo"), label: t("formEnabledLabel"), onCheckedChange: (checked) => handleChange("enabled", checked) })] })] }));
|
|
114
90
|
};
|
|
@@ -23,7 +23,6 @@ import { createGenericModulePage, } from "@react-pakistan/util-functions/factory
|
|
|
23
23
|
import { useStudentProfileModule, StudentProfileProvider, STUDENT_PROFILE_ACTION_TYPES, } from "./context";
|
|
24
24
|
import { StudentProfileFilter } from "./filter";
|
|
25
25
|
import { StudentProfileForm } from "./form";
|
|
26
|
-
import { StudentProfileMoreActions } from "./more-actions";
|
|
27
26
|
import { StudentProfileView } from "./view";
|
|
28
27
|
import { resolveRbacPermissions } from "../../utils/resolve-rbac-permissions";
|
|
29
28
|
import { RbacNoAccess } from "../../components/rbac-no-access";
|
|
@@ -67,7 +66,7 @@ const tableBodyCols = [
|
|
|
67
66
|
},
|
|
68
67
|
{
|
|
69
68
|
componentType: COMPONENT_TYPE.TEXT,
|
|
70
|
-
key: "
|
|
69
|
+
key: "emergencyPhone",
|
|
71
70
|
textFormatter: (val, row) => {
|
|
72
71
|
var _a;
|
|
73
72
|
const rowItem = row;
|
|
@@ -83,7 +82,6 @@ const tableBodyCols = [
|
|
|
83
82
|
const createComponentInstances = () => ({
|
|
84
83
|
filter: _jsx(StudentProfileFilter, {}),
|
|
85
84
|
form: _jsx(StudentProfileForm, {}),
|
|
86
|
-
moreActions: _jsx(StudentProfileMoreActions, {}),
|
|
87
85
|
view: _jsx(StudentProfileView, {}),
|
|
88
86
|
});
|
|
89
87
|
const createStudentProfileConfig = ({ dispatch, drawerButtonCancel, drawerButtonSave, drawerFilterDescription, drawerFilterTitle, drawerFormDescription, drawerFormTitle, drawerMoreActionsDescription, drawerMoreActionsTitle, drawerViewDescription, drawerViewTitle, tableColumnHeaderActions, tableColumnHeaderClassSection, tableColumnHeaderComputerCode, tableColumnHeaderEmergencyPhone, tableColumnHeaderEnabled, tableColumnHeaderId, tableColumnHeaderName, tableColumnHeaderStudentCode, tableDescription, tableSearchPlaceholder, tableTitle, }) => {
|
|
@@ -111,7 +109,7 @@ const createStudentProfileConfig = ({ dispatch, drawerButtonCancel, drawerButton
|
|
|
111
109
|
drawerViewTitle,
|
|
112
110
|
filterContent: components.filter,
|
|
113
111
|
formContent: components.form,
|
|
114
|
-
moreActionsContent:
|
|
112
|
+
moreActionsContent: null,
|
|
115
113
|
saveLabel: drawerButtonSave,
|
|
116
114
|
searchPlaceholder: tableSearchPlaceholder,
|
|
117
115
|
tableDescription,
|
package/constants.d.ts
CHANGED
|
@@ -71,7 +71,9 @@ export declare const RBAC_API_ROUTES: {
|
|
|
71
71
|
readonly PERMISSIONS_LIST: "/api/v1/permission";
|
|
72
72
|
readonly ROLE_PERMISSION_UNIT: "/api/v1/role-permission";
|
|
73
73
|
};
|
|
74
|
-
export declare const SCHOOL_API_ROUTES:
|
|
74
|
+
export declare const SCHOOL_API_ROUTES: {
|
|
75
|
+
readonly UNIT: "/api/v1/school";
|
|
76
|
+
};
|
|
75
77
|
export declare const SECTION_API_ROUTES: {
|
|
76
78
|
readonly LIST: "/api/v1/section";
|
|
77
79
|
readonly UNIT: "/api/v1/section";
|
|
@@ -92,8 +94,6 @@ export declare const STUDENT_FEE_API_ROUTES: {
|
|
|
92
94
|
export declare const STUDENT_PROFILE_API_ROUTES: {
|
|
93
95
|
readonly LIST: "/api/v1/student-profile";
|
|
94
96
|
readonly UNIT: "/api/v1/student-profile";
|
|
95
|
-
readonly BULK: "/api/v1/student-profile/bulk";
|
|
96
|
-
readonly BULK_STATUS: (jobId: string) => string;
|
|
97
97
|
};
|
|
98
98
|
export declare const SUBJECT_API_ROUTES: {
|
|
99
99
|
readonly LIST: "/api/v1/subject";
|
package/constants.js
CHANGED
|
@@ -97,8 +97,6 @@ export const STUDENT_FEE_API_ROUTES = {
|
|
|
97
97
|
export const STUDENT_PROFILE_API_ROUTES = {
|
|
98
98
|
LIST: "/api/v1/student-profile",
|
|
99
99
|
UNIT: "/api/v1/student-profile",
|
|
100
|
-
BULK: "/api/v1/student-profile/bulk",
|
|
101
|
-
BULK_STATUS: (jobId) => `/api/v1/student-profile/bulk/${jobId}`,
|
|
102
100
|
};
|
|
103
101
|
export const SUBJECT_API_ROUTES = {
|
|
104
102
|
LIST: "/api/v1/subject",
|