@appcorp/fusion-storybook 0.5.36 → 0.5.37
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/admission/form.js +117 -54
- package/package.json +1 -1
- package/tsconfig.build.tsbuildinfo +1 -1
|
@@ -17,7 +17,8 @@ import { useEnhancedCombobox } from "@appcorp/shadcn/hooks/use-enhanced-combobox
|
|
|
17
17
|
import { EnhancedCombobox } from "@appcorp/shadcn/components/enhanced-combobox";
|
|
18
18
|
import { Separator } from "@appcorp/shadcn/components/ui/separator";
|
|
19
19
|
import { useAdmissionModule, ADMISSION_ACTION_TYPES } from "./context";
|
|
20
|
-
import { useEffect } from "react";
|
|
20
|
+
import { useEffect, } from "react";
|
|
21
|
+
import { FileText, GraduationCap, Home, IdCard, StickyNote, User, UserRound, } from "lucide-react";
|
|
21
22
|
import { getCachedWorkspaceSync } from "../workspace/cache";
|
|
22
23
|
import { PhoneInput } from "../../components/phone-input";
|
|
23
24
|
import { GovernmentIdTypeSelect } from "../../components/government-id-type-select";
|
|
@@ -27,6 +28,11 @@ import { GENDER_OPTIONS } from "./constants";
|
|
|
27
28
|
import { DISCOUNT_CODE_API_ROUTES } from "../../constants";
|
|
28
29
|
import { useTranslations } from "next-intl";
|
|
29
30
|
import { getTranslatedError } from "../../utils/get-translated-error";
|
|
31
|
+
const ID_IMAGE_DROPZONE_CLASS = "[&>div:first-of-type]:min-h-36! [&>div:first-of-type]:p-3!";
|
|
32
|
+
const DOCUMENT_DROPZONE_CLASS = "[&>div:first-of-type]:min-h-48!";
|
|
33
|
+
const SectionHeading = ({ icon: Icon, children, }) => (_jsxs("div", { className: "flex items-center gap-2", children: [_jsx("span", { className: "bg-primary/10 text-primary flex h-7 w-7 items-center justify-center rounded-md", children: _jsx(Icon, { className: "h-4 w-4" }) }), _jsx("h4", { className: "text-muted-foreground m-0 p-0 text-sm font-semibold tracking-wide uppercase", children: children })] }));
|
|
34
|
+
const IdentityDocumentCard = ({ title, children, }) => (_jsxs("div", { className: "bg-muted/20 flex h-full flex-col gap-4 rounded-lg border p-4", children: [_jsxs("div", { className: "flex items-center gap-2", children: [_jsx(IdCard, { className: "text-muted-foreground h-4 w-4" }), _jsx("h5", { className: "m-0 text-sm font-semibold", children: title })] }), children] }));
|
|
35
|
+
const IdImageField = ({ id, label, info, value, onChange, onRemoveRemote, }) => (_jsx(EnhancedDropzone, { accept: ["application/pdf", "image/jpeg", "image/png", "image/webp"], className: ID_IMAGE_DROPZONE_CLASS, id: id, info: info, label: label, maxFiles: 4, maxSize: 10 * 1024 * 1024, onChange: onChange, onRemoveRemote: onRemoveRemote, value: value }));
|
|
30
36
|
export const AdmissionForm = () => {
|
|
31
37
|
var _a, _b, _c;
|
|
32
38
|
const { state, handleChange, dispatch, discountCodes } = useAdmissionModule();
|
|
@@ -98,57 +104,114 @@ export const AdmissionForm = () => {
|
|
|
98
104
|
}
|
|
99
105
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
100
106
|
}, [id, dispatch]);
|
|
101
|
-
return (_jsxs("div", { className: "
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
107
|
+
return (_jsxs("div", { className: "space-y-6", children: [_jsxs("section", { className: "bg-card/40 space-y-4 rounded-xl border p-4 sm:p-5", children: [_jsx(SectionHeading, { icon: UserRound, children: t("formSectionStudentInformation") }), _jsxs("div", { className: "grid gap-4 lg:grid-cols-12", children: [_jsxs("div", { className: "space-y-4 lg:col-span-7", children: [_jsxs("div", { className: "grid gap-4 sm:grid-cols-2", children: [_jsx(EnhancedInput, { error: getTranslatedError({ errors, key: "firstName", t }), id: "firstName", info: t("formFirstNameInfo"), label: t("formFirstNameLabel"), onChange: (e) => handleChange("firstName", e.target.value), placeholder: t("formFirstNamePlaceholder"), required: true, type: "text", value: firstName || "" }), _jsx(EnhancedInput, { error: getTranslatedError({ errors, key: "lastName", t }), id: "lastName", info: t("formLastNameInfo"), label: t("formLastNameLabel"), onChange: (e) => handleChange("lastName", e.target.value), placeholder: t("formLastNamePlaceholder"), required: true, type: "text", value: lastName || "" }), _jsx(EnhancedInput, { error: getTranslatedError({ errors, key: "dob", t }), id: "dob", info: t("formDobInfo"), label: t("formDobLabel"), onChange: (e) => handleChange("dob", e.target.value), onClick: (e) => { var _a, _b; return (_b = (_a = e.currentTarget).showPicker) === null || _b === void 0 ? void 0 : _b.call(_a); }, placeholder: t("formDobPlaceholder"), required: true, type: "date", value: dob || "" }), genderCombo] }), _jsxs("div", { className: "grid gap-4 sm:grid-cols-2", children: [_jsx(EnhancedInput, { error: getTranslatedError({
|
|
108
|
+
errors,
|
|
109
|
+
key: "registrationCode",
|
|
110
|
+
t,
|
|
111
|
+
}), id: "registrationCode", info: t("formRegistrationCodeInfo"), label: t("formRegistrationCodeLabel"), onChange: (e) => handleChange("registrationCode", e.target.value), placeholder: t("formRegistrationCodePlaceholder"), required: true, type: "text", value: registrationCode || "", disabled: true }), discountCodeCombo] }), _jsxs("div", { className: "flex flex-wrap items-center gap-6", children: [_jsx(EnhancedCheckbox, { label: t("formHafizLabel"), id: "hafiz", info: t("formHafizInfo"), onCheckedChange: (checked) => handleChange("hafiz", checked) }), _jsx(EnhancedCheckbox, { label: t("formOrphanLabel"), id: "orphan", info: t("formOrphanInfo"), onCheckedChange: (checked) => handleChange("orphan", checked) })] })] }), _jsx("div", { className: "lg:col-span-5", children: _jsxs(IdentityDocumentCard, { title: t("formIdentityDocumentLabel"), children: [_jsxs("div", { className: "grid gap-4 sm:grid-cols-2", children: [_jsx(GovernmentIdTypeSelect, { error: getTranslatedError({
|
|
112
|
+
errors,
|
|
113
|
+
key: "studentIdType",
|
|
114
|
+
t,
|
|
115
|
+
}), id: "studentIdType", onChange: (value) => handleChange("studentIdType", value), required: true, value: studentIdType }), _jsx(EnhancedInput, { error: getTranslatedError({
|
|
116
|
+
errors,
|
|
117
|
+
key: "studentIdNumber",
|
|
118
|
+
t,
|
|
119
|
+
}), id: "studentIdNumber", info: t("formStudentIdNumberInfo"), label: t("formStudentIdNumberLabel"), onChange: (e) => handleChange("studentIdNumber", e.target.value), placeholder: t("formStudentIdNumberPlaceholder"), required: true, type: "text", value: studentIdNumber || "" })] }), _jsx(IdImageField, { id: "studentIdImages", info: t("formStudentIdImagesInfo"), label: t("formStudentIdImagesLabel"), onChange: (files) => dispatch({
|
|
120
|
+
type: ADMISSION_ACTION_TYPES.SET_INPUT_FIELD,
|
|
121
|
+
payload: { key: "studentIdImagesFiles", value: files },
|
|
122
|
+
}), onRemoveRemote: (url) => dispatch({
|
|
123
|
+
type: ADMISSION_ACTION_TYPES.SET_INPUT_FIELD,
|
|
124
|
+
payload: {
|
|
125
|
+
key: "studentIdImages",
|
|
126
|
+
value: (studentIdImages || []).filter((item) => item !== url),
|
|
127
|
+
},
|
|
128
|
+
}), value: studentIdImages || [] })] }) })] })] }), _jsx(Separator, {}), _jsxs("section", { className: "bg-card/40 space-y-4 rounded-xl border p-4 sm:p-5", children: [_jsx(SectionHeading, { icon: User, children: t("formSectionFatherInformation") }), _jsxs("div", { className: "grid gap-4 lg:grid-cols-12", children: [_jsxs("div", { className: "space-y-4 lg:col-span-7", children: [_jsxs("div", { className: "grid gap-4 sm:grid-cols-2", children: [_jsx(EnhancedInput, { error: getTranslatedError({
|
|
129
|
+
errors,
|
|
130
|
+
key: "fatherFirstName",
|
|
131
|
+
t,
|
|
132
|
+
}), id: "fatherFirstName", info: t("formFatherFirstNameInfo"), label: t("formFirstNameLabel"), onChange: (e) => handleChange("fatherFirstName", e.target.value), placeholder: t("formFirstNamePlaceholder"), required: true, type: "text", value: fatherFirstName || "" }), _jsx(EnhancedInput, { error: getTranslatedError({
|
|
133
|
+
errors,
|
|
134
|
+
key: "fatherLastName",
|
|
135
|
+
t,
|
|
136
|
+
}), id: "fatherLastName", info: t("formFatherLastNameInfo"), label: t("formLastNameLabel"), onChange: (e) => handleChange("fatherLastName", e.target.value), placeholder: t("formLastNamePlaceholder"), required: true, type: "text", value: fatherLastName || "" }), _jsx(PhoneInput, { error: getTranslatedError({
|
|
137
|
+
errors,
|
|
138
|
+
key: "fatherMobile",
|
|
139
|
+
t,
|
|
140
|
+
}), id: "fatherMobile", info: t("formFatherMobileInfo"), label: t("formMobileLabel"), onChange: (value) => handleChange("fatherMobile", value), placeholder: t("formPhonePlaceholder"), required: true, value: fatherMobile || "", defaultCountry: country || ((_b = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _b === void 0 ? void 0 : _b.country) || "PK", className: "sm:col-span-2" }), _jsx(EnhancedInput, { error: getTranslatedError({
|
|
141
|
+
errors,
|
|
142
|
+
key: "fatherOccupation",
|
|
143
|
+
t,
|
|
144
|
+
}), id: "fatherOccupation", info: t("formFatherOccupationInfo"), label: t("formOccupationLabel"), onChange: (e) => handleChange("fatherOccupation", e.target.value), placeholder: t("formOccupationPlaceholder"), required: false, type: "text", value: fatherOccupation || "" }), _jsx(EnhancedInput, { error: getTranslatedError({
|
|
145
|
+
errors,
|
|
146
|
+
key: "fatherOrganization",
|
|
147
|
+
t,
|
|
148
|
+
}), id: "fatherOrganization", info: t("formFatherOrganizationInfo"), label: t("formOrganizationLabel"), onChange: (e) => handleChange("fatherOrganization", e.target.value), placeholder: t("formOrganizationPlaceholder"), required: false, type: "text", value: fatherOrganization || "" })] }), _jsx(EnhancedCheckbox, { label: t("formEmergencyContactLabel"), id: "emergencyContactFather", info: t("formFatherEmergencyContactInfo"), checked: emergencyContact === "Father", onCheckedChange: (checked) => handleChange("emergencyContact", checked ? "Father" : "") })] }), _jsx("div", { className: "lg:col-span-5", children: _jsxs(IdentityDocumentCard, { title: t("formIdentityDocumentLabel"), children: [_jsxs("div", { className: "grid gap-4 sm:grid-cols-2", children: [_jsx(GovernmentIdTypeSelect, { error: getTranslatedError({
|
|
149
|
+
errors,
|
|
150
|
+
key: "fatherIdType",
|
|
151
|
+
t,
|
|
152
|
+
}), id: "fatherIdType", onChange: (value) => handleChange("fatherIdType", value), required: true, value: fatherIdType }), _jsx(EnhancedInput, { error: getTranslatedError({
|
|
153
|
+
errors,
|
|
154
|
+
key: "fatherIdNumber",
|
|
155
|
+
t,
|
|
156
|
+
}), id: "fatherIdNumber", info: t("formFatherIdNumberInfo"), label: t("formIdNumberLabel"), onChange: (e) => handleChange("fatherIdNumber", e.target.value), placeholder: t("formIdNumberPlaceholder"), required: true, type: "text", value: fatherIdNumber || "" })] }), _jsx(IdImageField, { id: "fatherIdImages", info: t("formFatherIdImagesInfo"), label: t("formFatherIdImagesLabel"), onChange: (files) => dispatch({
|
|
157
|
+
type: ADMISSION_ACTION_TYPES.SET_INPUT_FIELD,
|
|
158
|
+
payload: { key: "fatherIdImagesFiles", value: files },
|
|
159
|
+
}), onRemoveRemote: (url) => dispatch({
|
|
160
|
+
type: ADMISSION_ACTION_TYPES.SET_INPUT_FIELD,
|
|
161
|
+
payload: {
|
|
162
|
+
key: "fatherIdImages",
|
|
163
|
+
value: (fatherIdImages || []).filter((item) => item !== url),
|
|
164
|
+
},
|
|
165
|
+
}), value: fatherIdImages || [] })] }) })] })] }), _jsx(Separator, {}), _jsxs("section", { className: "bg-card/40 space-y-4 rounded-xl border p-4 sm:p-5", children: [_jsx(SectionHeading, { icon: User, children: t("formSectionMotherInformation") }), _jsxs("div", { className: "grid gap-4 lg:grid-cols-12", children: [_jsxs("div", { className: "space-y-4 lg:col-span-7", children: [_jsxs("div", { className: "grid gap-4 sm:grid-cols-2", children: [_jsx(EnhancedInput, { error: getTranslatedError({
|
|
166
|
+
errors,
|
|
167
|
+
key: "motherFirstName",
|
|
168
|
+
t,
|
|
169
|
+
}), id: "motherFirstName", info: t("formMotherFirstNameInfo"), label: t("formFirstNameLabel"), onChange: (e) => handleChange("motherFirstName", e.target.value), placeholder: t("formFirstNamePlaceholder"), required: true, type: "text", value: motherFirstName || "" }), _jsx(EnhancedInput, { error: getTranslatedError({
|
|
170
|
+
errors,
|
|
171
|
+
key: "motherLastName",
|
|
172
|
+
t,
|
|
173
|
+
}), id: "motherLastName", info: t("formMotherLastNameInfo"), label: t("formLastNameLabel"), onChange: (e) => handleChange("motherLastName", e.target.value), placeholder: t("formLastNamePlaceholder"), required: true, type: "text", value: motherLastName || "" }), _jsx(PhoneInput, { error: getTranslatedError({
|
|
174
|
+
errors,
|
|
175
|
+
key: "motherMobile",
|
|
176
|
+
t,
|
|
177
|
+
}), id: "motherMobile", info: t("formMotherMobileInfo"), label: t("formMobileLabel"), onChange: (value) => handleChange("motherMobile", value), placeholder: t("formPhonePlaceholder"), required: true, value: motherMobile || "", defaultCountry: country || ((_c = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _c === void 0 ? void 0 : _c.country) || "PK", className: "sm:col-span-2" })] }), _jsx(EnhancedCheckbox, { label: t("formEmergencyContactLabel"), id: "emergencyContactMother", info: t("formMotherEmergencyContactInfo"), checked: emergencyContact === "Mother", onCheckedChange: (checked) => handleChange("emergencyContact", checked ? "Mother" : "") })] }), _jsx("div", { className: "lg:col-span-5", children: _jsxs(IdentityDocumentCard, { title: t("formIdentityDocumentLabel"), children: [_jsxs("div", { className: "grid gap-4 sm:grid-cols-2", children: [_jsx(GovernmentIdTypeSelect, { error: getTranslatedError({
|
|
178
|
+
errors,
|
|
179
|
+
key: "motherIdType",
|
|
180
|
+
t,
|
|
181
|
+
}), id: "motherIdType", onChange: (value) => handleChange("motherIdType", value), required: true, value: motherIdType }), _jsx(EnhancedInput, { error: getTranslatedError({
|
|
182
|
+
errors,
|
|
183
|
+
key: "motherIdNumber",
|
|
184
|
+
t,
|
|
185
|
+
}), id: "motherIdNumber", info: t("formMotherIdNumberInfo"), label: t("formIdNumberLabel"), onChange: (e) => handleChange("motherIdNumber", e.target.value), placeholder: t("formIdNumberPlaceholder"), required: true, type: "text", value: motherIdNumber || "" })] }), _jsx(IdImageField, { id: "motherIdImages", info: t("formMotherIdImagesInfo"), label: t("formMotherIdImagesLabel"), onChange: (files) => dispatch({
|
|
186
|
+
type: ADMISSION_ACTION_TYPES.SET_INPUT_FIELD,
|
|
187
|
+
payload: { key: "motherIdImagesFiles", value: files },
|
|
188
|
+
}), onRemoveRemote: (url) => dispatch({
|
|
189
|
+
type: ADMISSION_ACTION_TYPES.SET_INPUT_FIELD,
|
|
190
|
+
payload: {
|
|
191
|
+
key: "motherIdImages",
|
|
192
|
+
value: (motherIdImages || []).filter((item) => item !== url),
|
|
193
|
+
},
|
|
194
|
+
}), value: motherIdImages || [] })] }) })] })] }), _jsx(Separator, {}), _jsxs("section", { className: "space-y-4", children: [_jsx(SectionHeading, { icon: Home, children: t("formSectionHomeInformation") }), _jsxs("div", { className: "grid gap-4 sm:grid-cols-2 xl:grid-cols-4", children: [_jsx("div", { className: "sm:col-span-2 xl:col-span-4", children: _jsx(EnhancedTextarea, { error: getTranslatedError({ errors, key: "address", t }), id: "homeAddress", info: t("formHomeAddressInfo"), label: t("formHomeAddressLabel"), onChange: (e) => handleChange("address", e.target.value), placeholder: t("formHomeAddressPlaceholder"), required: true, rows: 2, value: address || "" }) }), _jsx(EnhancedInput, { error: getTranslatedError({ errors, key: "city", t }), id: "city", info: t("formCityInfo"), label: t("formCityLabel"), onChange: (e) => handleChange("city", e.target.value), placeholder: t("formCityPlaceholder"), required: true, type: "text", value: city || "" }), _jsx(EnhancedInput, { error: getTranslatedError({ errors, key: "state", t }), id: "state", info: t("formStateInfo"), label: t("formStateLabel"), onChange: (e) => handleChange("state", e.target.value), placeholder: t("formStatePlaceholder"), required: true, type: "text", value: provinceState || "" }), _jsx(EnhancedInput, { error: getTranslatedError({ errors, key: "country", t }), id: "country", info: t("formCountryInfo"), label: t("formCountryLabel"), onChange: (e) => handleChange("country", e.target.value), placeholder: t("formCountryPlaceholder"), required: true, type: "text", value: country || "" })] })] }), _jsx(Separator, {}), _jsxs("section", { className: "space-y-4", children: [_jsx(SectionHeading, { icon: GraduationCap, children: t("formSectionAdmissionInformation") }), _jsxs("div", { className: "grid gap-4 sm:grid-cols-2", children: [_jsx(EnhancedInput, { error: getTranslatedError({
|
|
195
|
+
errors,
|
|
196
|
+
key: "classForAdmission",
|
|
197
|
+
t,
|
|
198
|
+
}), id: "classForAdmission", info: t("formClassForAdmissionInfo"), label: t("formClassForAdmissionLabel"), onChange: (e) => handleChange("classForAdmission", e.target.value), placeholder: t("formClassForAdmissionPlaceholder"), required: true, type: "text", value: classForAdmission || "" }), _jsx(EnhancedInput, { error: getTranslatedError({
|
|
199
|
+
errors,
|
|
200
|
+
key: "previousSchool",
|
|
201
|
+
t,
|
|
202
|
+
}), id: "previousSchool", info: t("formPreviousSchoolInfo"), label: t("formPreviousSchoolLabel"), onChange: (e) => handleChange("previousSchool", e.target.value), placeholder: t("formPreviousSchoolPlaceholder"), type: "text", value: previousSchool || "" }), _jsx("div", { className: "sm:col-span-2", children: _jsx(EnhancedTextarea, { error: getTranslatedError({ errors, key: "siblings", t }), id: "siblings", info: t("formSiblingsInfo"), label: t("formSiblingsLabel"), onChange: (e) => handleChange("siblings", e.target.value), placeholder: t("formSiblingsPlaceholder"), rows: 3, value: siblings || "" }) })] })] }), _jsx(Separator, {}), _jsxs("section", { className: "space-y-4", children: [_jsx(SectionHeading, { icon: StickyNote, children: t("formSectionOfficeUse") }), _jsxs("div", { className: "grid gap-4 md:grid-cols-2", children: [_jsx(EnhancedTextarea, { error: getTranslatedError({ errors, key: "notes", t }), id: "notes", info: t("formNotesInfo"), label: t("formNotesLabel"), onChange: (e) => handleChange("notes", e.target.value), placeholder: t("formNotesPlaceholder"), rows: 3, value: notes || "" }), _jsx(EnhancedTextarea, { error: getTranslatedError({
|
|
203
|
+
errors,
|
|
204
|
+
key: "admissionNotes",
|
|
205
|
+
t,
|
|
206
|
+
}), id: "admissionNotes", info: t("formAdmissionNotesInfo"), label: t("formAdmissionNotesLabel"), onChange: (e) => handleChange("admissionNotes", e.target.value), placeholder: t("formAdmissionNotesPlaceholder"), rows: 3, value: admissionNotes || "" })] })] }), _jsx(Separator, {}), _jsxs("section", { className: "space-y-4", children: [_jsx(SectionHeading, { icon: FileText, children: t("formSectionDocumentsLabel") }), _jsx(EnhancedDropzone, { accept: [
|
|
207
|
+
"application/pdf",
|
|
208
|
+
"image/jpeg",
|
|
209
|
+
"image/png",
|
|
210
|
+
"image/webp",
|
|
211
|
+
"application/msword",
|
|
212
|
+
"application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
|
213
|
+
], className: DOCUMENT_DROPZONE_CLASS, error: undefined, id: "documents", info: t("formDocumentsInfo"), label: t("formDocumentsLabel"), maxFiles: 10, maxSize: 10 * 1024 * 1024, onChange: (files) => dispatch({
|
|
214
|
+
type: ADMISSION_ACTION_TYPES.SET_INPUT_FIELD,
|
|
215
|
+
payload: { key: "documentsFiles", value: files },
|
|
216
|
+
}), value: documents || [] })] })] }));
|
|
154
217
|
};
|