@appcorp/fusion-storybook 0.2.93 → 0.2.95

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.
Files changed (32) hide show
  1. package/base-modules/admission/context/use-admission-module.js +17 -16
  2. package/base-modules/admission/validate.d.ts +2 -2
  3. package/base-modules/admission/validate.js +9 -2
  4. package/base-modules/campus/context.js +40 -21
  5. package/base-modules/campus/form.js +5 -1
  6. package/base-modules/campus/validate.d.ts +1 -1
  7. package/base-modules/campus/validate.js +3 -1
  8. package/base-modules/family-member/context.js +26 -22
  9. package/base-modules/family-member/form.js +8 -1
  10. package/base-modules/family-member/validate.d.ts +2 -2
  11. package/base-modules/family-member/validate.js +3 -2
  12. package/base-modules/school/context.js +24 -19
  13. package/base-modules/school/form.js +5 -1
  14. package/base-modules/school/validate.d.ts +1 -1
  15. package/base-modules/school/validate.js +6 -1
  16. package/base-modules/student-fee/context/use-student-fee-module.js +34 -28
  17. package/base-modules/student-fee/form.js +1 -1
  18. package/base-modules/student-profile/context/use-student-profile-module.js +33 -27
  19. package/base-modules/student-profile/form.js +8 -1
  20. package/base-modules/student-profile/validate.d.ts +2 -2
  21. package/base-modules/student-profile/validate.js +3 -4
  22. package/base-modules/teacher/context.js +1 -1
  23. package/base-modules/teacher/form.js +8 -1
  24. package/base-modules/teacher/validate.d.ts +2 -2
  25. package/base-modules/teacher/validate.js +11 -2
  26. package/base-modules/user/context/use-user-module.js +16 -12
  27. package/base-modules/user/validate.d.ts +1 -1
  28. package/base-modules/user/validate.js +2 -2
  29. package/package.json +1 -1
  30. package/tsconfig.build.tsbuildinfo +1 -1
  31. package/utils/to-e164-phone.d.ts +1 -0
  32. package/utils/to-e164-phone.js +11 -0
@@ -12,12 +12,12 @@ import { admissionFormValidation } from "../validate";
12
12
  import { getCachedWorkspaceSync } from "../../workspace/cache";
13
13
  import { generateAdmissionReceiptPDF, } from "../../../utils/admission-pdf";
14
14
  import { normalizeIdNumber } from "../../../utils/id-number";
15
- import { formatNumber } from "@react-pakistan/util-functions/general/format-number";
15
+ import { toE164Phone } from "../../../utils/to-e164-phone";
16
16
  import { formatPhoneDisplay } from "@react-pakistan/util-functions/general/format-phone-display";
17
17
  import { Filter, Plus } from "lucide-react";
18
18
  import { ADMISSION_DRAWER, ADMISSION_ACTION_TYPES, useAdmissionContext, } from "../context";
19
19
  export const useAdmissionModule = () => {
20
- var _a, _b, _c, _d, _e, _f;
20
+ var _a, _b, _c, _d, _e, _f, _g;
21
21
  // ============================================================================
22
22
  // 1.4.1 STATE & CORE HOOKS
23
23
  // ============================================================================
@@ -52,7 +52,7 @@ export const useAdmissionModule = () => {
52
52
  (_a = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _a === void 0 ? void 0 : _a.id,
53
53
  ]);
54
54
  const updateParams = useMemo(() => {
55
- var _a, _b, _c, _d;
55
+ var _a, _b, _c, _d, _e, _f;
56
56
  return ({
57
57
  address: state.address || "",
58
58
  admissionNotes: state.admissionNotes || "",
@@ -68,32 +68,30 @@ export const useAdmissionModule = () => {
68
68
  fatherIdNumber: state.fatherIdNumber || "",
69
69
  fatherFirstName: state.fatherFirstName || "",
70
70
  fatherLastName: state.fatherLastName || "",
71
- fatherMobile: formatNumber(state.fatherMobile),
71
+ fatherMobile: toE164Phone(state.fatherMobile, (_b = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _b === void 0 ? void 0 : _b.country),
72
72
  fatherOccupation: state.fatherOccupation || "",
73
73
  fatherOrganization: state.fatherOrganization || "",
74
74
  firstName: state.firstName || "",
75
75
  gender: state.gender || null,
76
- hafiz: (_b = state.hafiz) !== null && _b !== void 0 ? _b : false,
76
+ hafiz: (_c = state.hafiz) !== null && _c !== void 0 ? _c : false,
77
77
  id: state.id || "",
78
78
  lastName: state.lastName || "",
79
79
  motherIdNumber: state.motherIdNumber || "",
80
80
  motherFirstName: state.motherFirstName || "",
81
81
  motherLastName: state.motherLastName || "",
82
- motherMobile: formatNumber(state.motherMobile),
82
+ motherMobile: toE164Phone(state.motherMobile, (_d = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _d === void 0 ? void 0 : _d.country),
83
83
  notes: state.notes || "",
84
- orphan: (_c = state.orphan) !== null && _c !== void 0 ? _c : false,
84
+ orphan: (_e = state.orphan) !== null && _e !== void 0 ? _e : false,
85
85
  postalCode: state.postalCode || "",
86
86
  previousSchool: state.previousSchool || "",
87
87
  registrationCode: state.registrationCode || "",
88
- schoolId: ((_d = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _d === void 0 ? void 0 : _d.id) || "",
88
+ schoolId: ((_f = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _f === void 0 ? void 0 : _f.id) || "",
89
89
  siblings: state.siblings || "",
90
90
  state: state.state || "",
91
91
  });
92
92
  }, [
93
93
  state.address,
94
94
  state.admissionNotes,
95
- state.status,
96
- state.studentIdNumber,
97
95
  state.city,
98
96
  state.classForAdmission,
99
97
  state.country,
@@ -101,8 +99,8 @@ export const useAdmissionModule = () => {
101
99
  state.dob,
102
100
  state.emergencyContact,
103
101
  state.enabled,
104
- state.fatherIdNumber,
105
102
  state.fatherFirstName,
103
+ state.fatherIdNumber,
106
104
  state.fatherLastName,
107
105
  state.fatherMobile,
108
106
  state.fatherOccupation,
@@ -112,8 +110,8 @@ export const useAdmissionModule = () => {
112
110
  state.hafiz,
113
111
  state.id,
114
112
  state.lastName,
115
- state.motherIdNumber,
116
113
  state.motherFirstName,
114
+ state.motherIdNumber,
117
115
  state.motherLastName,
118
116
  state.motherMobile,
119
117
  state.notes,
@@ -123,7 +121,10 @@ export const useAdmissionModule = () => {
123
121
  state.registrationCode,
124
122
  state.siblings,
125
123
  state.state,
126
- (_b = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _b === void 0 ? void 0 : _b.id,
124
+ state.status,
125
+ state.studentIdNumber,
126
+ (_b = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _b === void 0 ? void 0 : _b.country,
127
+ (_c = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _c === void 0 ? void 0 : _c.id,
127
128
  ]);
128
129
  const byIdParams = useMemo(() => ({ id: state.id }), [state.id]);
129
130
  const deleteParams = useMemo(() => ({ id: state.id }), [state.id]);
@@ -537,7 +538,7 @@ export const useAdmissionModule = () => {
537
538
  description: `${t("messagesAnalyzeSuccess")} ${(_c = result === null || result === void 0 ? void 0 : result.score) !== null && _c !== void 0 ? _c : "N/A"} — ${(_d = result === null || result === void 0 ? void 0 : result.status) !== null && _d !== void 0 ? _d : ""}`,
538
539
  variant: TOAST_VARIANT.SUCCESS,
539
540
  });
540
- }, [(_c = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _c === void 0 ? void 0 : _c.id, t, showToast, byIdFetchNow, dispatch]);
541
+ }, [(_d = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _d === void 0 ? void 0 : _d.id, t, showToast, byIdFetchNow, dispatch]);
541
542
  const handleSubmit = useCallback(() => {
542
543
  dispatch({
543
544
  type: ADMISSION_ACTION_TYPES.SET_DISABLE_SAVE_BUTTON,
@@ -615,12 +616,12 @@ export const useAdmissionModule = () => {
615
616
  t,
616
617
  showToast,
617
618
  updateFetchNow,
618
- (_d = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _d === void 0 ? void 0 : _d.id,
619
+ (_e = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _e === void 0 ? void 0 : _e.id,
619
620
  ]);
620
621
  // ============================================================================
621
622
  // 1.4.8 HEADER & ROW ACTIONS
622
623
  // ============================================================================
623
- const hasGeminiSecrets = Boolean(((_e = workspace === null || workspace === void 0 ? void 0 : workspace.secrets) === null || _e === void 0 ? void 0 : _e.GEMINI_API_KEY) && ((_f = workspace === null || workspace === void 0 ? void 0 : workspace.secrets) === null || _f === void 0 ? void 0 : _f.GEMINI_MODEL));
624
+ const hasGeminiSecrets = Boolean(((_f = workspace === null || workspace === void 0 ? void 0 : workspace.secrets) === null || _f === void 0 ? void 0 : _f.GEMINI_API_KEY) && ((_g = workspace === null || workspace === void 0 ? void 0 : workspace.secrets) === null || _g === void 0 ? void 0 : _g.GEMINI_MODEL));
624
625
  const headerActions = useMemo(() => [
625
626
  {
626
627
  enabled: true,
@@ -18,13 +18,13 @@ export declare const admissionFormValidation: z.ZodObject<{
18
18
  fatherFirstName: z.ZodString;
19
19
  fatherLastName: z.ZodString;
20
20
  fatherIdNumber: z.ZodPipe<z.ZodString, z.ZodTransform<string | null | undefined, string>>;
21
- fatherMobile: z.ZodString;
21
+ fatherMobile: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
22
22
  fatherOccupation: z.ZodOptional<z.ZodString>;
23
23
  fatherOrganization: z.ZodOptional<z.ZodString>;
24
24
  motherFirstName: z.ZodString;
25
25
  motherLastName: z.ZodString;
26
26
  motherIdNumber: z.ZodPipe<z.ZodString, z.ZodTransform<string | null | undefined, string>>;
27
- motherMobile: z.ZodString;
27
+ motherMobile: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
28
28
  address: z.ZodString;
29
29
  city: z.ZodString;
30
30
  state: z.ZodString;
@@ -6,6 +6,7 @@
6
6
  import { z } from "zod";
7
7
  import { GENDER } from "../../type";
8
8
  import { normalizeIdNumber } from "../../utils/id-number";
9
+ import { toE164Phone } from "../../utils/to-e164-phone";
9
10
  export const admissionFormValidation = z.object({
10
11
  // Student Information
11
12
  registrationCode: z.string().min(1, "Registration code is required"),
@@ -35,14 +36,20 @@ export const admissionFormValidation = z.object({
35
36
  fatherFirstName: z.string().min(1, "Father's first name is required"),
36
37
  fatherLastName: z.string().min(1, "Father's last name is required"),
37
38
  fatherIdNumber: z.string().min(1, "Father's ID number is required").transform(normalizeIdNumber),
38
- fatherMobile: z.string().min(1, "Father's mobile number is required"),
39
+ fatherMobile: z
40
+ .string()
41
+ .min(1, "Father's mobile number is required")
42
+ .transform((val) => { var _a; return (_a = toE164Phone(val)) !== null && _a !== void 0 ? _a : val; }),
39
43
  fatherOccupation: z.string().optional(),
40
44
  fatherOrganization: z.string().optional(),
41
45
  // Mother Information
42
46
  motherFirstName: z.string().min(1, "Mother's first name is required"),
43
47
  motherLastName: z.string().min(1, "Mother's last name is required"),
44
48
  motherIdNumber: z.string().min(1, "Mother's ID number is required").transform(normalizeIdNumber),
45
- motherMobile: z.string().min(1, "Mother's mobile number is required"),
49
+ motherMobile: z
50
+ .string()
51
+ .min(1, "Mother's mobile number is required")
52
+ .transform((val) => { var _a; return (_a = toE164Phone(val)) !== null && _a !== void 0 ? _a : val; }),
46
53
  // Home Information
47
54
  address: z.string().min(1, "Home address is required"),
48
55
  city: z.string().min(1, "City is required"),
@@ -21,8 +21,8 @@ import { useDebounce } from "@react-pakistan/util-functions/hooks/use-debounce";
21
21
  import { createGenericModule } from "@react-pakistan/util-functions/factory/generic-module-factory";
22
22
  import { DRAWER_TYPES } from "@react-pakistan/util-functions/factory/generic-component-factory";
23
23
  import { generateThemeToast, TOAST_VARIANT, } from "@appcorp/shadcn/lib/toast-utils";
24
- import { formatNumber } from "@react-pakistan/util-functions/general/format-number";
25
24
  import { formatPhoneDisplay } from "@react-pakistan/util-functions/general/format-phone-display";
25
+ import { toE164Phone } from "../../utils/to-e164-phone";
26
26
  import { pageLimit } from "./constants";
27
27
  import { CAMPUS_API_ROUTES } from "../../constants";
28
28
  import { campusFormValidation } from "./validate";
@@ -75,7 +75,7 @@ export const { actionTypes: CAMPUS_ACTION_TYPES, config: campusModuleConfig, ini
75
75
  // 1.4 ENHANCED CAMPUS HOOK WITH API INTEGRATION
76
76
  // ============================================================================
77
77
  export const useCampusModule = () => {
78
- var _a;
78
+ var _a, _b, _c, _d;
79
79
  // ============================================================================
80
80
  // 1.4.1 STATE & CORE HOOKS
81
81
  // ============================================================================
@@ -85,33 +85,51 @@ export const useCampusModule = () => {
85
85
  const t = useTranslations("campus");
86
86
  const { theme } = useTheme();
87
87
  const workspace = getCachedWorkspaceSync();
88
- const schoolId = ((_a = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _a === void 0 ? void 0 : _a.id) || "";
89
88
  const debouncedQuery = useDebounce(state.searchQuery, 800);
90
89
  const listFetchNowRef = useRef(null);
91
90
  // ============================================================================
92
91
  // 1.4.2 API PARAMETERS
93
92
  // ============================================================================
94
- const listParams = useMemo(() => (Object.assign(Object.assign({ currentPage: state.currentPage, pageLimit: state.pageLimit, schoolId }, (debouncedQuery ? { searchQuery: debouncedQuery } : {})), (state.filterEnabled !== undefined
95
- ? { filterEnabled: String(state.filterEnabled) }
96
- : {}))), [
93
+ const listParams = useMemo(() => {
94
+ var _a;
95
+ return (Object.assign(Object.assign({ currentPage: state.currentPage, pageLimit: state.pageLimit, schoolId: ((_a = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _a === void 0 ? void 0 : _a.id) || "" }, (debouncedQuery ? { searchQuery: debouncedQuery } : {})), (state.filterEnabled !== undefined
96
+ ? { filterEnabled: String(state.filterEnabled) }
97
+ : {})));
98
+ }, [
97
99
  state.currentPage,
98
100
  state.filterEnabled,
99
101
  state.pageLimit,
100
102
  debouncedQuery,
101
- schoolId,
103
+ (_a = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _a === void 0 ? void 0 : _a.id,
104
+ ]);
105
+ const updateParams = useMemo(() => {
106
+ var _a, _b;
107
+ return ({
108
+ address: state.address,
109
+ city: state.city,
110
+ code: state.code,
111
+ country: state.country,
112
+ enabled: state.enabled,
113
+ id: state.id,
114
+ name: state.name,
115
+ phone: toE164Phone(state.phone, (_a = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _a === void 0 ? void 0 : _a.country),
116
+ schoolId: state.schoolId || ((_b = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _b === void 0 ? void 0 : _b.id) || "",
117
+ state: state.state,
118
+ });
119
+ }, [
120
+ state.address,
121
+ state.city,
122
+ state.code,
123
+ state.country,
124
+ state.enabled,
125
+ state.id,
126
+ state.name,
127
+ state.phone,
128
+ state.schoolId,
129
+ state.state,
130
+ (_b = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _b === void 0 ? void 0 : _b.country,
131
+ (_c = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _c === void 0 ? void 0 : _c.id,
102
132
  ]);
103
- const updateParams = useMemo(() => ({
104
- address: state.address,
105
- city: state.city,
106
- code: state.code,
107
- country: state.country,
108
- enabled: state.enabled,
109
- id: state.id,
110
- name: state.name,
111
- phone: formatNumber(state.phone),
112
- schoolId: state.schoolId || schoolId,
113
- state: state.state,
114
- }), [state, schoolId]);
115
133
  const byIdParams = useMemo(() => ({ id: state.id }), [state.id]);
116
134
  const deleteParams = useMemo(() => ({ id: state.id }), [state.id]);
117
135
  // ============================================================================
@@ -140,6 +158,7 @@ export const useCampusModule = () => {
140
158
  });
141
159
  }, [dispatch]);
142
160
  const resetRecordFormState = useCallback(() => {
161
+ var _a;
143
162
  dispatch({
144
163
  type: CAMPUS_ACTION_TYPES.SET_ERRORS,
145
164
  payload: { errors: {} },
@@ -161,12 +180,12 @@ export const useCampusModule = () => {
161
180
  id: "",
162
181
  name: "",
163
182
  phone: null,
164
- schoolId,
183
+ schoolId: ((_a = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _a === void 0 ? void 0 : _a.id) || "",
165
184
  state: null,
166
185
  },
167
186
  },
168
187
  });
169
- }, [dispatch, schoolId]);
188
+ }, [dispatch, (_d = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _d === void 0 ? void 0 : _d.id]);
170
189
  // ============================================================================
171
190
  // 1.4.4 API CALLBACKS
172
191
  // ============================================================================
@@ -9,10 +9,14 @@ import { EnhancedInput } from "@appcorp/shadcn/components/enhanced-input";
9
9
  import { EnhancedCheckbox } from "@appcorp/shadcn/components/enhanced-checkbox";
10
10
  import { useCampusModule } from "./context";
11
11
  import { useTranslations } from "next-intl";
12
+ import { formatPhone } from "@react-pakistan/util-functions/general/format-phone";
12
13
  import { getTranslatedError } from "../../utils/get-translated-error";
13
14
  export const CampusForm = () => {
14
15
  const { state, handleChange } = useCampusModule();
15
16
  const { address, city, code, country, enabled, errors, name, phone, state: campusState, } = state;
16
17
  const t = useTranslations("campus");
17
- return (_jsxs("div", { className: "grid grid-cols-1 gap-4", children: [_jsx(EnhancedInput, { error: getTranslatedError({ errors, key: "name", t }), id: "name", info: t("formCampusNameInfo"), label: t("formCampusNameLabel"), onChange: (e) => handleChange("name", e.target.value), placeholder: t("formCampusNamePlaceholder"), required: true, value: name }), _jsx(EnhancedInput, { error: getTranslatedError({ errors, key: "code", t }), id: "code", info: t("formCampusCodeInfo"), label: t("formCampusCodeLabel"), onChange: (e) => handleChange("code", e.target.value), placeholder: t("formCampusCodePlaceholder"), required: true, value: code }), _jsx(EnhancedInput, { error: getTranslatedError({ errors, key: "address", t }), id: "address", info: t("formAddressInfo"), label: t("formAddressLabel"), onChange: (e) => handleChange("address", e.target.value), placeholder: t("formAddressPlaceholder"), 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"), 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"), value: campusState || "" }), _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"), value: country || "" }), _jsx(EnhancedInput, { error: getTranslatedError({ errors, key: "phone", t }), id: "phone", info: t("formPhoneInfo"), label: t("formPhoneLabel"), onChange: (e) => handleChange("phone", e.target.value), placeholder: t("formPhonePlaceholder"), value: phone || "" }), _jsx(EnhancedCheckbox, { info: t("formActiveCampusInfo"), label: t("formActiveCampusLabel"), defaultChecked: enabled, onCheckedChange: (checked) => handleChange("enabled", checked) })] }));
18
+ return (_jsxs("div", { className: "grid grid-cols-1 gap-4", children: [_jsx(EnhancedInput, { error: getTranslatedError({ errors, key: "name", t }), id: "name", info: t("formCampusNameInfo"), label: t("formCampusNameLabel"), onChange: (e) => handleChange("name", e.target.value), placeholder: t("formCampusNamePlaceholder"), required: true, value: name }), _jsx(EnhancedInput, { error: getTranslatedError({ errors, key: "code", t }), id: "code", info: t("formCampusCodeInfo"), label: t("formCampusCodeLabel"), onChange: (e) => handleChange("code", e.target.value), placeholder: t("formCampusCodePlaceholder"), required: true, value: code }), _jsx(EnhancedInput, { error: getTranslatedError({ errors, key: "address", t }), id: "address", info: t("formAddressInfo"), label: t("formAddressLabel"), onChange: (e) => handleChange("address", e.target.value), placeholder: t("formAddressPlaceholder"), 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"), 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"), value: campusState || "" }), _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"), value: country || "" }), _jsx(EnhancedInput, { error: getTranslatedError({ errors, key: "phone", t }), id: "phone", info: t("formPhoneInfo"), label: t("formPhoneLabel"), onChange: (e) => {
19
+ var _a;
20
+ return handleChange("phone", ((_a = formatPhone(e.target.value)) === null || _a === void 0 ? void 0 : _a.international) || e.target.value);
21
+ }, placeholder: t("formPhonePlaceholder"), value: phone || "" }), _jsx(EnhancedCheckbox, { info: t("formActiveCampusInfo"), label: t("formActiveCampusLabel"), defaultChecked: enabled, onCheckedChange: (checked) => handleChange("enabled", checked) })] }));
18
22
  };
@@ -19,6 +19,6 @@ export declare const campusFormValidation: z.ZodObject<{
19
19
  city: z.ZodNullable<z.ZodOptional<z.ZodString>>;
20
20
  state: z.ZodNullable<z.ZodOptional<z.ZodString>>;
21
21
  country: z.ZodNullable<z.ZodOptional<z.ZodString>>;
22
- phone: z.ZodNullable<z.ZodOptional<z.ZodString>>;
22
+ phone: z.ZodPipe<z.ZodNullable<z.ZodOptional<z.ZodString>>, z.ZodTransform<string | null | undefined, string | null | undefined>>;
23
23
  enabled: z.ZodOptional<z.ZodBoolean>;
24
24
  }, z.core.$strip>;
@@ -1,4 +1,5 @@
1
1
  import { z } from "zod";
2
+ import { toE164Phone } from "../../utils/to-e164-phone";
2
3
  export const VALIDATION_KEYS = {
3
4
  nameRequired: "validationCampusNameRequired",
4
5
  nameMaxLength: "validationCampusNameMaxLength",
@@ -47,6 +48,7 @@ export const campusFormValidation = z.object({
47
48
  .string()
48
49
  .max(30, VALIDATION_KEYS.phoneMaxLength)
49
50
  .optional()
50
- .nullable(),
51
+ .nullable()
52
+ .transform((val) => { var _a; return (val ? (_a = toE164Phone(val)) !== null && _a !== void 0 ? _a : val : val); }),
51
53
  enabled: z.boolean().optional(),
52
54
  });
@@ -30,8 +30,8 @@ import { normalizeIdNumber } from "../../utils/id-number";
30
30
  import { FAMILY_MEMBER_API_ROUTES } from "../../constants";
31
31
  import { familyMemberFormValidation } from "./validate";
32
32
  import { generateThemeToast, TOAST_VARIANT, } from "@appcorp/shadcn/lib/toast-utils";
33
- import { formatNumber } from "@react-pakistan/util-functions/general/format-number";
34
33
  import { formatPhoneDisplay } from "@react-pakistan/util-functions/general/format-phone-display";
34
+ import { toE164Phone } from "../../utils/to-e164-phone";
35
35
  import { useTranslations } from "next-intl";
36
36
  import { getCachedWorkspaceSync } from "../workspace/cache";
37
37
  import { Eye, Filter, MoreHorizontal, Pencil, Plus } from "lucide-react";
@@ -96,7 +96,7 @@ export const useFamilyMemberModule = () => {
96
96
  // ============================================================================
97
97
  // 1.4.1 STATE & CORE HOOKS
98
98
  // ============================================================================
99
- var _a, _b;
99
+ var _a, _b, _c;
100
100
  const context = useFamilyMemberContext();
101
101
  const { dispatch } = context;
102
102
  const state = context.state;
@@ -121,25 +121,28 @@ export const useFamilyMemberModule = () => {
121
121
  debouncedQuery,
122
122
  (_a = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _a === void 0 ? void 0 : _a.id,
123
123
  ]);
124
- const updateParams = useMemo(() => ({
125
- id: state.id,
126
- familyId: state.familyId,
127
- role: state.role,
128
- firstName: state.firstName,
129
- lastName: state.lastName,
130
- dateOfBirth: state.dateOfBirth,
131
- gender: state.gender,
132
- bloodGroup: state.bloodGroup,
133
- phone: formatNumber(state.phone),
134
- email: state.email,
135
- relationship: state.relationship,
136
- occupation: state.occupation,
137
- emergencyPhone: formatNumber(state.emergencyPhone),
138
- idNumber: state.idNumber,
139
- avatar: state.avatar,
140
- isPrimary: state.isPrimary,
141
- enabled: state.enabled,
142
- }), [
124
+ const updateParams = useMemo(() => {
125
+ var _a, _b;
126
+ return ({
127
+ id: state.id,
128
+ familyId: state.familyId,
129
+ role: state.role,
130
+ firstName: state.firstName,
131
+ lastName: state.lastName,
132
+ dateOfBirth: state.dateOfBirth,
133
+ gender: state.gender,
134
+ bloodGroup: state.bloodGroup,
135
+ phone: toE164Phone(state.phone, (_a = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _a === void 0 ? void 0 : _a.country),
136
+ email: state.email,
137
+ relationship: state.relationship,
138
+ occupation: state.occupation,
139
+ emergencyPhone: toE164Phone(state.emergencyPhone, (_b = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _b === void 0 ? void 0 : _b.country),
140
+ idNumber: state.idNumber,
141
+ avatar: state.avatar,
142
+ isPrimary: state.isPrimary,
143
+ enabled: state.enabled,
144
+ });
145
+ }, [
143
146
  state.avatar,
144
147
  state.bloodGroup,
145
148
  state.dateOfBirth,
@@ -157,6 +160,7 @@ export const useFamilyMemberModule = () => {
157
160
  state.phone,
158
161
  state.relationship,
159
162
  state.role,
163
+ (_b = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _b === void 0 ? void 0 : _b.country,
160
164
  ]);
161
165
  const byIdParams = useMemo(() => ({ id: state.id }), [state.id]);
162
166
  const deleteParams = useMemo(() => ({ id: state.id }), [state.id]);
@@ -477,7 +481,7 @@ export const useFamilyMemberModule = () => {
477
481
  if (!((_a = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _a === void 0 ? void 0 : _a.id))
478
482
  return;
479
483
  (_b = listFetchNowRef.current) === null || _b === void 0 ? void 0 : _b.call(listFetchNowRef);
480
- }, [listParams, (_b = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _b === void 0 ? void 0 : _b.id]);
484
+ }, [listParams, (_c = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _c === void 0 ? void 0 : _c.id]);
481
485
  // ============================================================================
482
486
  // 1.4.10 RETURN
483
487
  // ============================================================================
@@ -9,10 +9,17 @@ import { EnhancedCheckbox } from "@appcorp/shadcn/components/enhanced-checkbox";
9
9
  import { EnhancedInput } from "@appcorp/shadcn/components/enhanced-input";
10
10
  import { useFamilyMemberModule } from "./context";
11
11
  import { useTranslations } from "next-intl";
12
+ import { formatPhone } from "@react-pakistan/util-functions/general/format-phone";
12
13
  import { getTranslatedError } from "../../utils/get-translated-error";
13
14
  export const FamilyMemberForm = () => {
14
15
  const { handleChange, state } = useFamilyMemberModule();
15
16
  const { bloodGroup, dateOfBirth, email, emergencyPhone, enabled, errors, firstName, gender, idNumber, isPrimary, lastName, occupation, phone, relationship, role, } = state;
16
17
  const t = useTranslations("familyMember");
17
- return (_jsxs("div", { className: "space-y-4", children: [_jsxs("div", { className: "space-y-4", children: [_jsx("h3", { className: "text-lg font-semibold", children: t("formSectionPersonalInformation") }), _jsxs("div", { className: "grid grid-cols-1 gap-4 md: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, 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, value: lastName })] }), _jsxs("div", { className: "grid grid-cols-1 gap-4 md:grid-cols-2", children: [_jsx(EnhancedInput, { error: getTranslatedError({ errors, key: "role", t }), id: "role", info: t("formRoleInfo"), label: t("formRoleLabel"), onChange: (e) => handleChange("role", e.target.value), placeholder: t("formRolePlaceholder"), required: true, value: role }), _jsx(EnhancedInput, { error: getTranslatedError({ errors, key: "dateOfBirth", t }), id: "dateOfBirth", info: t("formDateOfBirthInfo"), label: t("formDateOfBirthLabel"), onChange: (e) => handleChange("dateOfBirth", e.target.value), placeholder: "YYYY-MM-DD", type: "date", value: dateOfBirth })] }), _jsxs("div", { className: "grid grid-cols-1 gap-4 md:grid-cols-2", children: [_jsx(EnhancedInput, { error: getTranslatedError({ errors, key: "gender", t }), id: "gender", info: t("formGenderInfo"), label: t("formGenderLabel"), onChange: (e) => handleChange("gender", e.target.value), placeholder: t("formGenderPlaceholder"), value: gender }), _jsx(EnhancedInput, { error: getTranslatedError({ errors, key: "bloodGroup", t }), id: "bloodGroup", info: t("formBloodGroupInfo"), label: t("formBloodGroupLabel"), onChange: (e) => handleChange("bloodGroup", e.target.value), placeholder: t("formBloodGroupPlaceholder"), value: bloodGroup })] }), _jsx(EnhancedInput, { error: getTranslatedError({ errors, key: "idNumber", t }), id: "idNumber", info: t("formIdNumberInfo"), label: t("formIdNumberLabel"), onChange: (e) => handleChange("idNumber", e.target.value), placeholder: t("formIdNumberPlaceholder"), value: idNumber })] }), _jsxs("div", { className: "space-y-4", children: [_jsx("h3", { className: "text-lg font-semibold", children: t("formSectionContactInformation") }), _jsxs("div", { className: "grid grid-cols-1 gap-4 md:grid-cols-2", children: [_jsx(EnhancedInput, { error: getTranslatedError({ errors, key: "phone", t }), id: "phone", info: t("formPhoneInfo"), label: t("formPhoneLabel"), onChange: (e) => handleChange("phone", e.target.value), placeholder: t("formPhonePlaceholder"), type: "tel", value: phone }), _jsx(EnhancedInput, { error: getTranslatedError({ errors, key: "email", t }), id: "email", info: t("formEmailInfo"), label: t("formEmailLabel"), onChange: (e) => handleChange("email", e.target.value), placeholder: t("formEmailPlaceholder"), type: "email", value: email })] }), _jsx(EnhancedInput, { error: getTranslatedError({ errors, key: "emergencyPhone", t }), id: "emergencyPhone", info: t("formEmergencyPhoneInfo"), label: t("formEmergencyPhoneLabel"), onChange: (e) => handleChange("emergencyPhone", e.target.value), placeholder: t("formEmergencyPhonePlaceholder"), type: "tel", value: emergencyPhone })] }), _jsxs("div", { className: "space-y-4", children: [_jsx("h3", { className: "text-lg font-semibold", children: t("formSectionAdditionalInformation") }), _jsx(EnhancedInput, { error: getTranslatedError({ errors, key: "relationship", t }), id: "relationship", info: t("formRelationshipInfo"), label: t("formRelationshipLabel"), onChange: (e) => handleChange("relationship", e.target.value), placeholder: t("formRelationshipPlaceholder"), value: relationship }), _jsx(EnhancedInput, { error: getTranslatedError({ errors, key: "occupation", t }), id: "occupation", info: t("formOccupationInfo"), label: t("formOccupationLabel"), onChange: (e) => handleChange("occupation", e.target.value), placeholder: t("formOccupationPlaceholder"), value: occupation })] }), _jsxs("div", { className: "space-y-4", children: [_jsx("h3", { className: "text-lg font-semibold", children: t("formSectionStatus") }), _jsxs("div", { className: "flex items-center gap-4", children: [_jsx(EnhancedCheckbox, { checked: isPrimary, id: "isPrimary", label: t("formPrimaryContactLabel"), onCheckedChange: (checked) => handleChange("isPrimary", checked === true) }), _jsx(EnhancedCheckbox, { checked: enabled, id: "enabled", label: t("badgeActive"), onCheckedChange: (checked) => handleChange("enabled", checked === true) })] })] })] }));
18
+ return (_jsxs("div", { className: "space-y-4", children: [_jsxs("div", { className: "space-y-4", children: [_jsx("h3", { className: "text-lg font-semibold", children: t("formSectionPersonalInformation") }), _jsxs("div", { className: "grid grid-cols-1 gap-4 md: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, 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, value: lastName })] }), _jsxs("div", { className: "grid grid-cols-1 gap-4 md:grid-cols-2", children: [_jsx(EnhancedInput, { error: getTranslatedError({ errors, key: "role", t }), id: "role", info: t("formRoleInfo"), label: t("formRoleLabel"), onChange: (e) => handleChange("role", e.target.value), placeholder: t("formRolePlaceholder"), required: true, value: role }), _jsx(EnhancedInput, { error: getTranslatedError({ errors, key: "dateOfBirth", t }), id: "dateOfBirth", info: t("formDateOfBirthInfo"), label: t("formDateOfBirthLabel"), onChange: (e) => handleChange("dateOfBirth", e.target.value), placeholder: "YYYY-MM-DD", type: "date", value: dateOfBirth })] }), _jsxs("div", { className: "grid grid-cols-1 gap-4 md:grid-cols-2", children: [_jsx(EnhancedInput, { error: getTranslatedError({ errors, key: "gender", t }), id: "gender", info: t("formGenderInfo"), label: t("formGenderLabel"), onChange: (e) => handleChange("gender", e.target.value), placeholder: t("formGenderPlaceholder"), value: gender }), _jsx(EnhancedInput, { error: getTranslatedError({ errors, key: "bloodGroup", t }), id: "bloodGroup", info: t("formBloodGroupInfo"), label: t("formBloodGroupLabel"), onChange: (e) => handleChange("bloodGroup", e.target.value), placeholder: t("formBloodGroupPlaceholder"), value: bloodGroup })] }), _jsx(EnhancedInput, { error: getTranslatedError({ errors, key: "idNumber", t }), id: "idNumber", info: t("formIdNumberInfo"), label: t("formIdNumberLabel"), onChange: (e) => handleChange("idNumber", e.target.value), placeholder: t("formIdNumberPlaceholder"), value: idNumber })] }), _jsxs("div", { className: "space-y-4", children: [_jsx("h3", { className: "text-lg font-semibold", children: t("formSectionContactInformation") }), _jsxs("div", { className: "grid grid-cols-1 gap-4 md:grid-cols-2", children: [_jsx(EnhancedInput, { error: getTranslatedError({ errors, key: "phone", t }), id: "phone", info: t("formPhoneInfo"), label: t("formPhoneLabel"), onChange: (e) => {
19
+ var _a;
20
+ return handleChange("phone", ((_a = formatPhone(e.target.value)) === null || _a === void 0 ? void 0 : _a.international) || e.target.value);
21
+ }, placeholder: t("formPhonePlaceholder"), type: "tel", value: phone }), _jsx(EnhancedInput, { error: getTranslatedError({ errors, key: "email", t }), id: "email", info: t("formEmailInfo"), label: t("formEmailLabel"), onChange: (e) => handleChange("email", e.target.value), placeholder: t("formEmailPlaceholder"), type: "email", value: email })] }), _jsx(EnhancedInput, { error: getTranslatedError({ errors, key: "emergencyPhone", t }), id: "emergencyPhone", info: t("formEmergencyPhoneInfo"), label: t("formEmergencyPhoneLabel"), onChange: (e) => {
22
+ var _a;
23
+ return handleChange("emergencyPhone", ((_a = formatPhone(e.target.value)) === null || _a === void 0 ? void 0 : _a.international) || e.target.value);
24
+ }, placeholder: t("formEmergencyPhonePlaceholder"), type: "tel", value: emergencyPhone })] }), _jsxs("div", { className: "space-y-4", children: [_jsx("h3", { className: "text-lg font-semibold", children: t("formSectionAdditionalInformation") }), _jsx(EnhancedInput, { error: getTranslatedError({ errors, key: "relationship", t }), id: "relationship", info: t("formRelationshipInfo"), label: t("formRelationshipLabel"), onChange: (e) => handleChange("relationship", e.target.value), placeholder: t("formRelationshipPlaceholder"), value: relationship }), _jsx(EnhancedInput, { error: getTranslatedError({ errors, key: "occupation", t }), id: "occupation", info: t("formOccupationInfo"), label: t("formOccupationLabel"), onChange: (e) => handleChange("occupation", e.target.value), placeholder: t("formOccupationPlaceholder"), value: occupation })] }), _jsxs("div", { className: "space-y-4", children: [_jsx("h3", { className: "text-lg font-semibold", children: t("formSectionStatus") }), _jsxs("div", { className: "flex items-center gap-4", children: [_jsx(EnhancedCheckbox, { checked: isPrimary, id: "isPrimary", label: t("formPrimaryContactLabel"), onCheckedChange: (checked) => handleChange("isPrimary", checked === true) }), _jsx(EnhancedCheckbox, { checked: enabled, id: "enabled", label: t("badgeActive"), onCheckedChange: (checked) => handleChange("enabled", checked === true) })] })] })] }));
18
25
  };
@@ -20,11 +20,11 @@ export declare const familyMemberFormValidation: z.ZodObject<{
20
20
  dateOfBirth: z.ZodOptional<z.ZodString>;
21
21
  gender: z.ZodOptional<z.ZodString>;
22
22
  bloodGroup: z.ZodOptional<z.ZodString>;
23
- phone: z.ZodOptional<z.ZodString>;
23
+ phone: z.ZodPipe<z.ZodOptional<z.ZodString>, z.ZodTransform<string | undefined, string | undefined>>;
24
24
  email: z.ZodUnion<[z.ZodOptional<z.ZodString>, z.ZodLiteral<"">]>;
25
25
  relationship: z.ZodOptional<z.ZodString>;
26
26
  occupation: z.ZodOptional<z.ZodString>;
27
- emergencyPhone: z.ZodOptional<z.ZodString>;
27
+ emergencyPhone: z.ZodPipe<z.ZodOptional<z.ZodString>, z.ZodTransform<string | undefined, string | undefined>>;
28
28
  idNumber: z.ZodPipe<z.ZodOptional<z.ZodString>, z.ZodTransform<string | null | undefined, string | undefined>>;
29
29
  avatar: z.ZodOptional<z.ZodString>;
30
30
  isPrimary: z.ZodOptional<z.ZodBoolean>;
@@ -5,6 +5,7 @@
5
5
  */
6
6
  import { z } from "zod";
7
7
  import { normalizeIdNumber } from "../../utils/id-number";
8
+ import { toE164Phone } from "../../utils/to-e164-phone";
8
9
  // ============================================================================
9
10
  // VALIDATION KEYS (used as Zod error messages, translated via getTranslatedError)
10
11
  // ============================================================================
@@ -27,7 +28,7 @@ export const familyMemberFormValidation = z.object({
27
28
  dateOfBirth: z.string().optional(),
28
29
  gender: z.string().optional(),
29
30
  bloodGroup: z.string().optional(),
30
- phone: z.string().optional(),
31
+ phone: z.string().optional().transform((val) => { var _a; return (val ? (_a = toE164Phone(val)) !== null && _a !== void 0 ? _a : val : val); }),
31
32
  email: z
32
33
  .string()
33
34
  .email(VALIDATION_KEYS.emailInvalid)
@@ -35,7 +36,7 @@ export const familyMemberFormValidation = z.object({
35
36
  .or(z.literal("")),
36
37
  relationship: z.string().optional(),
37
38
  occupation: z.string().optional(),
38
- emergencyPhone: z.string().optional(),
39
+ emergencyPhone: z.string().optional().transform((val) => { var _a; return (val ? (_a = toE164Phone(val)) !== null && _a !== void 0 ? _a : val : val); }),
39
40
  idNumber: z.string().optional().transform((val) => (val ? normalizeIdNumber(val) : val)),
40
41
  avatar: z.string().optional(),
41
42
  isPrimary: z.boolean().optional(),
@@ -29,8 +29,8 @@ import { SCHOOL_API_ROUTES } from "../../constants";
29
29
  import { invalidateSchoolCache } from "./cache";
30
30
  import { schoolFormValidation } from "./validate";
31
31
  import { getCachedWorkspaceSync } from "../workspace/cache";
32
- import { formatNumber } from "@react-pakistan/util-functions/general/format-number";
33
32
  import { formatPhoneDisplay } from "@react-pakistan/util-functions/general/format-phone-display";
33
+ import { toE164Phone } from "../../utils/to-e164-phone";
34
34
  // ============================================================================
35
35
  // 1.1 DRAWER TYPES
36
36
  // ============================================================================
@@ -79,6 +79,7 @@ export const { actionTypes: SCHOOL_ACTION_TYPES, config: schoolModuleConfig, ini
79
79
  // 1.4 ENHANCED SCHOOL HOOK WITH API INTEGRATION
80
80
  // ============================================================================
81
81
  export const useSchoolModule = () => {
82
+ var _a;
82
83
  // ============================================================================
83
84
  // 1.4.1 STATE & CORE HOOKS
84
85
  // ============================================================================
@@ -91,24 +92,27 @@ export const useSchoolModule = () => {
91
92
  // ============================================================================
92
93
  // 1.4.2 API PARAMETERS
93
94
  // ============================================================================
94
- const updateParams = useMemo(() => ({
95
- address: state.address,
96
- city: state.city,
97
- code: state.code,
98
- country: state.country,
99
- currency: state.currency,
100
- email: state.email,
101
- enabled: state.enabled,
102
- id: state.id,
103
- logo: state.logo,
104
- name: state.name,
105
- phone: formatNumber(state.phone),
106
- postalCode: state.postalCode,
107
- principalId: state.principalId,
108
- state: state.state,
109
- website: state.website,
110
- workspaceId: (workspace === null || workspace === void 0 ? void 0 : workspace.id) || "",
111
- }), [
95
+ const updateParams = useMemo(() => {
96
+ var _a;
97
+ return ({
98
+ address: state.address,
99
+ city: state.city,
100
+ code: state.code,
101
+ country: state.country,
102
+ currency: state.currency,
103
+ email: state.email,
104
+ enabled: state.enabled,
105
+ id: state.id,
106
+ logo: state.logo,
107
+ name: state.name,
108
+ phone: toE164Phone(state.phone, (_a = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _a === void 0 ? void 0 : _a.country),
109
+ postalCode: state.postalCode,
110
+ principalId: state.principalId,
111
+ state: state.state,
112
+ website: state.website,
113
+ workspaceId: (workspace === null || workspace === void 0 ? void 0 : workspace.id) || "",
114
+ });
115
+ }, [
112
116
  state.address,
113
117
  state.city,
114
118
  state.code,
@@ -125,6 +129,7 @@ export const useSchoolModule = () => {
125
129
  state.state,
126
130
  state.website,
127
131
  workspace === null || workspace === void 0 ? void 0 : workspace.id,
132
+ (_a = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _a === void 0 ? void 0 : _a.country,
128
133
  ]);
129
134
  const byIdParams = useMemo(() => ({}), []);
130
135
  const deleteParams = useMemo(() => ({}), []);
@@ -12,6 +12,7 @@ import { useSchoolModule } from "./context";
12
12
  import { CURRENCY } from "../../type";
13
13
  import { SCHOOL_API_ROUTES } from "../../constants";
14
14
  import { useTranslations } from "next-intl";
15
+ import { formatPhone } from "@react-pakistan/util-functions/general/format-phone";
15
16
  import { getTranslatedError } from "../../utils/get-translated-error";
16
17
  export const SchoolForm = () => {
17
18
  const t = useTranslations("school");
@@ -57,5 +58,8 @@ export const SchoolForm = () => {
57
58
  // searchPlaceholder: t("formPrincipalSearchPlaceholder"),
58
59
  // value: principalId || "",
59
60
  // });
60
- return (_jsxs("div", { className: "space-y-6", children: [_jsxs("div", { className: "grid grid-cols-1 gap-4", children: [_jsx(EnhancedInput, { id: "name", label: t("formNameLabel"), value: name, onChange: (e) => handleChange("name", e.target.value), error: getTranslatedError({ errors, key: "name", t }), placeholder: t("formNamePlaceholder"), required: true }), _jsx(EnhancedInput, { id: "code", label: t("formCodeLabel"), value: code, onChange: (e) => handleChange("code", e.target.value), error: getTranslatedError({ errors, key: "code", t }), placeholder: t("formCodePlaceholder"), required: true, info: t("formCodeInfo") }), currencyCombo, _jsx(EnhancedInput, { id: "address", label: t("formAddressLabel"), value: address || "", onChange: (e) => handleChange("address", e.target.value), error: getTranslatedError({ errors, key: "address", t }), placeholder: t("formAddressPlaceholder") }), _jsx(EnhancedInput, { id: "city", label: t("formCityLabel"), value: city || "", onChange: (e) => handleChange("city", e.target.value), error: getTranslatedError({ errors, key: "city", t }), placeholder: t("formCityPlaceholder") }), _jsx(EnhancedInput, { id: "state", label: t("formStateLabel"), value: stateField || "", onChange: (e) => handleChange("state", e.target.value), error: getTranslatedError({ errors, key: "state", t }), placeholder: t("formStatePlaceholder") }), _jsx(EnhancedInput, { id: "country", label: t("formCountryLabel"), value: country || "", onChange: (e) => handleChange("country", e.target.value), error: getTranslatedError({ errors, key: "country", t }), placeholder: t("formCountryPlaceholder") }), _jsx(EnhancedInput, { id: "postalCode", label: t("formPostalCodeLabel"), value: postalCode || "", onChange: (e) => handleChange("postalCode", e.target.value), error: getTranslatedError({ errors, key: "postalCode", t }), placeholder: t("formPostalCodePlaceholder") }), _jsx(EnhancedInput, { id: "phone", label: t("formPhoneLabel"), value: phone || "", onChange: (e) => handleChange("phone", e.target.value), error: getTranslatedError({ errors, key: "phone", t }), placeholder: t("formPhonePlaceholder"), type: "tel" }), _jsx(EnhancedInput, { id: "email", label: t("formEmailLabel"), value: email || "", onChange: (e) => handleChange("email", e.target.value), error: getTranslatedError({ errors, key: "email", t }), placeholder: t("formEmailPlaceholder"), type: "email" })] }), _jsx(EnhancedInput, { id: "website", label: t("formWebsiteLabel"), value: website || "", onChange: (e) => handleChange("website", e.target.value), error: getTranslatedError({ errors, key: "website", t }), placeholder: t("formWebsitePlaceholder"), type: "url" }), _jsx(EnhancedInput, { id: "logo", label: t("formLogoLabel"), value: logo || "", onChange: (e) => handleChange("logo", e.target.value), error: getTranslatedError({ errors, key: "logo", t }), placeholder: t("formLogoPlaceholder"), type: "url" }), _jsx(EnhancedCheckbox, { id: "enabled", label: t("formEnabledLabel"), checked: enabled, error: getTranslatedError({ errors, key: "enabled", t }), onCheckedChange: (checked) => handleChange("enabled", checked), info: t("formEnabledInfo") })] }));
61
+ return (_jsxs("div", { className: "space-y-6", children: [_jsxs("div", { className: "grid grid-cols-1 gap-4", children: [_jsx(EnhancedInput, { id: "name", label: t("formNameLabel"), value: name, onChange: (e) => handleChange("name", e.target.value), error: getTranslatedError({ errors, key: "name", t }), placeholder: t("formNamePlaceholder"), required: true }), _jsx(EnhancedInput, { id: "code", label: t("formCodeLabel"), value: code, onChange: (e) => handleChange("code", e.target.value), error: getTranslatedError({ errors, key: "code", t }), placeholder: t("formCodePlaceholder"), required: true, info: t("formCodeInfo") }), currencyCombo, _jsx(EnhancedInput, { id: "address", label: t("formAddressLabel"), value: address || "", onChange: (e) => handleChange("address", e.target.value), error: getTranslatedError({ errors, key: "address", t }), placeholder: t("formAddressPlaceholder") }), _jsx(EnhancedInput, { id: "city", label: t("formCityLabel"), value: city || "", onChange: (e) => handleChange("city", e.target.value), error: getTranslatedError({ errors, key: "city", t }), placeholder: t("formCityPlaceholder") }), _jsx(EnhancedInput, { id: "state", label: t("formStateLabel"), value: stateField || "", onChange: (e) => handleChange("state", e.target.value), error: getTranslatedError({ errors, key: "state", t }), placeholder: t("formStatePlaceholder") }), _jsx(EnhancedInput, { id: "country", label: t("formCountryLabel"), value: country || "", onChange: (e) => handleChange("country", e.target.value), error: getTranslatedError({ errors, key: "country", t }), placeholder: t("formCountryPlaceholder") }), _jsx(EnhancedInput, { id: "postalCode", label: t("formPostalCodeLabel"), value: postalCode || "", onChange: (e) => handleChange("postalCode", e.target.value), error: getTranslatedError({ errors, key: "postalCode", t }), placeholder: t("formPostalCodePlaceholder") }), _jsx(EnhancedInput, { id: "phone", label: t("formPhoneLabel"), value: phone || "", onChange: (e) => {
62
+ var _a;
63
+ return handleChange("phone", ((_a = formatPhone(e.target.value)) === null || _a === void 0 ? void 0 : _a.international) || e.target.value);
64
+ }, error: getTranslatedError({ errors, key: "phone", t }), placeholder: t("formPhonePlaceholder"), type: "tel" }), _jsx(EnhancedInput, { id: "email", label: t("formEmailLabel"), value: email || "", onChange: (e) => handleChange("email", e.target.value), error: getTranslatedError({ errors, key: "email", t }), placeholder: t("formEmailPlaceholder"), type: "email" })] }), _jsx(EnhancedInput, { id: "website", label: t("formWebsiteLabel"), value: website || "", onChange: (e) => handleChange("website", e.target.value), error: getTranslatedError({ errors, key: "website", t }), placeholder: t("formWebsitePlaceholder"), type: "url" }), _jsx(EnhancedInput, { id: "logo", label: t("formLogoLabel"), value: logo || "", onChange: (e) => handleChange("logo", e.target.value), error: getTranslatedError({ errors, key: "logo", t }), placeholder: t("formLogoPlaceholder"), type: "url" }), _jsx(EnhancedCheckbox, { id: "enabled", label: t("formEnabledLabel"), checked: enabled, error: getTranslatedError({ errors, key: "enabled", t }), onCheckedChange: (checked) => handleChange("enabled", checked), info: t("formEnabledInfo") })] }));
61
65
  };
@@ -21,7 +21,7 @@ export declare const schoolFormValidation: z.ZodObject<{
21
21
  state: z.ZodOptional<z.ZodNullable<z.ZodString>>;
22
22
  country: z.ZodOptional<z.ZodNullable<z.ZodString>>;
23
23
  postalCode: z.ZodOptional<z.ZodNullable<z.ZodString>>;
24
- phone: z.ZodOptional<z.ZodNullable<z.ZodString>>;
24
+ phone: z.ZodPipe<z.ZodOptional<z.ZodNullable<z.ZodString>>, z.ZodTransform<string | null | undefined, string | null | undefined>>;
25
25
  email: z.ZodOptional<z.ZodNullable<z.ZodString>>;
26
26
  website: z.ZodOptional<z.ZodNullable<z.ZodString>>;
27
27
  logo: z.ZodOptional<z.ZodNullable<z.ZodString>>;