@eeplatform/basic-edu 1.3.11 → 1.3.12

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/dist/index.mjs CHANGED
@@ -1864,9 +1864,11 @@ var schemaEnrollment = Joi3.object({
1864
1864
  division: Joi3.string().required(),
1865
1865
  // Changed from hex to string to match frontend
1866
1866
  divisionName: Joi3.string().optional().allow("", null),
1867
- school: Joi3.string().required(),
1867
+ schoolId: Joi3.string().required(),
1868
1868
  // Changed from hex to string to match frontend
1869
- schoolName: Joi3.string().optional().allow("", null),
1869
+ school: Joi3.string().hex().required(),
1870
+ // Added to match frontend
1871
+ schoolName: Joi3.string().required(),
1870
1872
  // Added to match frontend
1871
1873
  schoolYear: Joi3.string().required(),
1872
1874
  gradeLevel: Joi3.string().valid(...gradeLevels).required(),
@@ -1937,6 +1939,7 @@ function MEnrollment(value) {
1937
1939
  division: value.division,
1938
1940
  divisionName: value.divisionName ?? "",
1939
1941
  school: value.school,
1942
+ schoolId: value.schoolId,
1940
1943
  schoolName: value.schoolName ?? "",
1941
1944
  // Added to match frontend
1942
1945
  schoolYear: value.schoolYear ?? "",
@@ -2078,7 +2081,11 @@ function useEnrollmentRepo() {
2078
2081
  status
2079
2082
  };
2080
2083
  if (school) {
2081
- query.school = school;
2084
+ try {
2085
+ query.school = new ObjectId4(school);
2086
+ } catch (error) {
2087
+ throw new BadRequestError5("Invalid school ID.");
2088
+ }
2082
2089
  }
2083
2090
  if (schoolYear) {
2084
2091
  query.schoolYear = schoolYear;
@@ -2125,41 +2132,13 @@ function useEnrollmentRepo() {
2125
2132
  });
2126
2133
  return cached;
2127
2134
  }
2128
- const items = await collection.aggregate([
2129
- { $match: query },
2130
- {
2131
- $lookup: {
2132
- from: "admin.schools",
2133
- localField: "school",
2134
- foreignField: "_id",
2135
- // School collection still uses ObjectId, we'll need to convert during lookup
2136
- as: "schoolInfo"
2137
- }
2138
- },
2139
- {
2140
- $lookup: {
2141
- from: "admin.regions",
2142
- localField: "region",
2143
- foreignField: "_id",
2144
- // Region collection still uses ObjectId, we'll need to convert during lookup
2145
- as: "regionInfo"
2146
- }
2147
- },
2148
- {
2149
- $lookup: {
2150
- from: "admin.divisions",
2151
- localField: "division",
2152
- // Changed from sdo to division to match frontend
2153
- foreignField: "_id",
2154
- // Division collection still uses ObjectId, we'll need to convert during lookup
2155
- as: "divisionInfo"
2156
- // Changed from sdoInfo to divisionInfo
2157
- }
2158
- },
2159
- { $sort: sort },
2160
- { $skip: page * limit },
2161
- { $limit: limit }
2162
- ]).toArray();
2135
+ const pipeline = [{ $match: query }];
2136
+ if (Object.keys(sort).length) {
2137
+ pipeline.push({ $sort: sort });
2138
+ }
2139
+ pipeline.push({ $skip: page * limit });
2140
+ pipeline.push({ $limit: limit });
2141
+ const items = await collection.aggregate(pipeline).toArray();
2163
2142
  const length = await collection.countDocuments(query);
2164
2143
  const data = paginate2(items, page, limit, length);
2165
2144
  setCache(cacheKey, data, 600).then(() => {
@@ -2478,7 +2457,7 @@ function useEnrollmentService() {
2478
2457
  placeOfBirth: value.learnerInfo.placeOfBirth,
2479
2458
  gradeLevel: value.gradeLevel,
2480
2459
  schoolYear: value.schoolYear,
2481
- school: value.school
2460
+ school: value.schoolId
2482
2461
  });
2483
2462
  if (applicantInfo.accepted) {
2484
2463
  throw new BadRequestError6(