@eeplatform/basic-edu 1.8.2 → 1.8.4

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
@@ -4047,6 +4047,13 @@ function useBasicEduCountRepo() {
4047
4047
  import { BadRequestError as BadRequestError13 } from "@eeplatform/nodejs-utils";
4048
4048
  import Joi10 from "joi";
4049
4049
  import { ObjectId as ObjectId9 } from "mongodb";
4050
+ var statusesProgramScreening = [
4051
+ "pending",
4052
+ "passed",
4053
+ "failed",
4054
+ "reclassified",
4055
+ "withdrawn"
4056
+ ];
4050
4057
  var schemaProgramScreening = Joi10.object({
4051
4058
  _id: Joi10.string().hex().optional().allow(null, ""),
4052
4059
  school: Joi10.string().hex().required(),
@@ -4065,7 +4072,7 @@ var schemaProgramScreening = Joi10.object({
4065
4072
  grade: Joi10.number().min(0).max(100).required()
4066
4073
  })
4067
4074
  ).optional(),
4068
- status: Joi10.string().valid("pending", "pass", "failed").optional(),
4075
+ status: Joi10.string().valid(...statusesProgramScreening).optional(),
4069
4076
  createdAt: Joi10.string().isoDate().optional(),
4070
4077
  updatedAt: Joi10.string().isoDate().optional(),
4071
4078
  deletedAt: Joi10.string().isoDate().optional().allow(null, "")
@@ -4472,10 +4479,7 @@ import Joi11 from "joi";
4472
4479
  // src/resources/program-screening/program.screening.service.ts
4473
4480
  import { AppError as AppError8, useAtlas as useAtlas8 } from "@eeplatform/nodejs-utils";
4474
4481
  function useProgramScreeningService() {
4475
- const {
4476
- updateStatusById: updateEnrollmentStatusById,
4477
- getById: getEnrollmentById
4478
- } = useEnrollmentRepo();
4482
+ const { updateStatusById: updateEnrollmentStatusById } = useEnrollmentRepo();
4479
4483
  const { updateFieldById, getById: getProgramScreeningById } = useProgramScreeningRepo();
4480
4484
  async function updateStatusById(id, status) {
4481
4485
  const session = useAtlas8.getClient()?.startSession();
@@ -4485,20 +4489,21 @@ function useProgramScreeningService() {
4485
4489
  if (!application) {
4486
4490
  throw new AppError8("Application not found", 404);
4487
4491
  }
4488
- if (application.status !== "pending") {
4489
- throw new AppError8("Only pending applications can be updated", 400);
4490
- }
4491
4492
  await updateFieldById(
4492
4493
  { _id: id, field: "status", value: status },
4493
4494
  session
4494
4495
  );
4495
4496
  let enrollmentStatus = "pending";
4496
- if (status === "passed") {
4497
+ const ReclassifyCond = status === "reclassified" && application.status && ["failed", "withdrawn"].includes(application.status);
4498
+ if (status === "passed" && application.status === "pending" || ReclassifyCond) {
4497
4499
  enrollmentStatus = "pending";
4498
4500
  }
4499
- if (status === "failed") {
4501
+ if (status === "failed" && application.status === "pending") {
4500
4502
  enrollmentStatus = "failed-screening";
4501
4503
  }
4504
+ if (status === "withdrawn" && application.status === "pending") {
4505
+ enrollmentStatus = "withdrawn-screening";
4506
+ }
4502
4507
  await updateEnrollmentStatusById(
4503
4508
  application.applicant,
4504
4509
  enrollmentStatus,
@@ -4726,7 +4731,7 @@ function useProgramScreeningController() {
4726
4731
  }
4727
4732
  const value = req.body;
4728
4733
  const { error: updatePayloadError } = Joi11.object({
4729
- status: Joi11.string().valid("passed", "failed").required()
4734
+ status: Joi11.string().valid(...statusesProgramScreening).required()
4730
4735
  }).validate(value);
4731
4736
  if (updatePayloadError) {
4732
4737
  next(new BadRequestError15(updatePayloadError.message));
@@ -44177,6 +44182,7 @@ export {
44177
44182
  schemaTeachingLoadSlot,
44178
44183
  schemaUpdateOptions,
44179
44184
  schemaUpdateStatus,
44185
+ statusesProgramScreening,
44180
44186
  useAssetController,
44181
44187
  useAssetRepo,
44182
44188
  useBasicEduCountRepo,