Skip to content

Commit

Permalink
#2836 - Change Requests: Error Message Details on Multiple Requests (#…
Browse files Browse the repository at this point in the history
…3400)

### As a part of this PR, the following were completed:

- Changed the validation to allow only one pending Request a Change per
application from one per student.
- Updated the error message whenever a duplicate Change Request is
submitted for an application that already has one pending. The new error
message is: **"Only one change request can be submitted at a time for
each application. When your current request is approved or denied by
StudentAid BC, you will be able to submit a new one".**
- Added the loader when the appeal request is in progress (for the
period when the response is returned for the API call).
- Updated the e2e tests.

### Screenshots:

**Error message when there is an existing pending appeal for an
application.**

<img width="1920" alt="image"
src="https://github.com/bcgov/SIMS/assets/7859295/22bf423b-6896-4776-b939-b394854e1a3e">

-----------------------------------------------------------------

**Added loader when the appeal request is in progress**

<img width="1921" alt="image"
src="https://github.com/bcgov/SIMS/assets/7859295/84d49b96-cd09-438f-b14b-48ae68bbdd8f">
  • Loading branch information
sh16011993 authored Jun 12, 2024
1 parent 1dc7498 commit 6f5c263
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ export const INVALID_STUDY_DATES = "INVALID_STUDY_DATES";
export const OFFERING_INTENSITY_MISMATCH = "OFFERING_INTENSITY_MISMATCH";
export const MISSING_STUDENT_ACCOUNT = "MISSING_STUDENT_ACCOUNT";
export const INVALID_APPLICATION_NUMBER = "INVALID_APPLICATION_NUMBER";
/**
* An application can have only one pending appeal at a time.
*/
export const APPLICATION_HAS_PENDING_APPEAL = "APPLICATION_HAS_PENDING_APPEAL";
export const APPLICATION_CHANGE_NOT_ELIGIBLE =
"APPLICATION_CHANGE_NOT_ELIGIBLE";
// A STUDENT_APPLICATION_EXCEPTION_* referer to when a full-time/part-time
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import { AppStudentsModule } from "../../../../app.students.module";
import { FormService } from "../../../../services";
import {
APPLICATION_CHANGE_NOT_ELIGIBLE,
APPLICATION_HAS_PENDING_APPEAL,
INVALID_APPLICATION_NUMBER,
} from "../../../../constants";

Expand Down Expand Up @@ -210,9 +211,9 @@ describe("StudentAppealStudentsController(e2e)-submitStudentAppeal", () => {
.auth(studentToken, BEARER_AUTH_TYPE)
.expect(HttpStatus.UNPROCESSABLE_ENTITY)
.expect({
statusCode: HttpStatus.UNPROCESSABLE_ENTITY,
message: "There is already a pending appeal for this student.",
error: "Unprocessable Entity",
message:
"Only one change request can be submitted at a time for each application. When your current request is approved or denied by StudentAid BC, you will be able to submit a new one.",
errorType: APPLICATION_HAS_PENDING_APPEAL,
});
},
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import {
} from "../../types";
import {
APPLICATION_CHANGE_NOT_ELIGIBLE,
APPLICATION_HAS_PENDING_APPEAL,
INVALID_APPLICATION_NUMBER,
} from "../../constants";
import { StudentAppealRequestModel } from "../../services/student-appeal/student-appeal.model";
Expand Down Expand Up @@ -74,7 +75,7 @@ export class StudentAppealStudentsController extends BaseController {
})
@ApiUnprocessableEntityResponse({
description:
"There is either an existing appeal for this student or this application is no longer eligible to request changes.",
"There is either an existing appeal for this application or this application is no longer eligible to request changes.",
})
@ApiBadRequestResponse({
description: "Not able to submit student appeal due to invalid request.",
Expand Down Expand Up @@ -108,11 +109,14 @@ export class StudentAppealStudentsController extends BaseController {
),
);
}
const existingStudentAppeal =
await this.studentAppealService.hasExistingAppeal(userToken.userId);
if (existingStudentAppeal) {
const existingApplicationAppeal =
await this.studentAppealService.hasExistingAppeal(applicationId);
if (existingApplicationAppeal) {
throw new UnprocessableEntityException(
"There is already a pending appeal for this student.",
new ApiProcessError(
"Only one change request can be submitted at a time for each application. When your current request is approved or denied by StudentAid BC, you will be able to submit a new one.",
APPLICATION_HAS_PENDING_APPEAL,
),
);
}
let dryRunSubmissionResults: DryRunSubmissionResult[] = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,19 +129,17 @@ export class StudentAppealService extends RecordDataModelService<StudentAppeal>
}

/**
* Find any pending appeal for a student if exists.
* @param userId of student.
* Find any pending appeal for the application if exists.
* @param applicationId application id related to the appeal.
* @returns exist status
*/
async hasExistingAppeal(userId: number): Promise<boolean> {
async hasExistingAppeal(applicationId: number): Promise<boolean> {
const existingAppeal = await this.repo
.createQueryBuilder("appeal")
.select("1")
.innerJoin("appeal.appealRequests", "appealRequests")
.innerJoin("appeal.application", "application")
.innerJoin("application.student", "student")
.innerJoin("student.user", "user")
.where("user.id = :userId", { userId })
.where("application.id = :applicationId", { applicationId })
.andWhere("appealRequests.appealStatus = :pending", {
pending: StudentAppealStatus.Pending,
})
Expand Down
4 changes: 4 additions & 0 deletions sources/packages/web/src/constants/error-code.constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ export const ACTIVE_STUDENT_RESTRICTION = "ACTIVE_STUDENT_RESTRICTION";
export const MISSING_STUDENT_ACCOUNT = "MISSING_STUDENT_ACCOUNT";
export const APPLICATION_CHANGE_NOT_ELIGIBLE =
"APPLICATION_CHANGE_NOT_ELIGIBLE";
/**
* An application can have only one pending appeal at a time.
*/
export const APPLICATION_HAS_PENDING_APPEAL = "APPLICATION_HAS_PENDING_APPEAL";
export const INVALID_APPLICATION_NUMBER = "INVALID_APPLICATION_NUMBER";
export const FIRST_COE_NOT_COMPLETE = "FIRST_COE_NOT_COMPLETE";
export const INVALID_TUITION_REMITTANCE_AMOUNT =
Expand Down
29 changes: 19 additions & 10 deletions sources/packages/web/src/views/student/StudentAppealRequest.vue
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,11 @@
>Back
</v-btn>

<v-btn color="primary" class="ml-2 float-right" @click="submit"
<v-btn
color="primary"
class="ml-2 float-right"
@click="submit"
:loading="processing"
>Submit for review</v-btn
>
</template>
Expand All @@ -52,6 +56,7 @@ import AppealRequestsForm from "@/components/common/AppealRequestsForm.vue";
import { useSnackBar } from "@/composables";
import {
APPLICATION_CHANGE_NOT_ELIGIBLE,
APPLICATION_HAS_PENDING_APPEAL,
INVALID_APPLICATION_NUMBER,
} from "@/constants";
Expand All @@ -67,6 +72,7 @@ export default defineComponent({
},
setup() {
const snackBar = useSnackBar();
const processing = ref(false);
const appealRequestsForms = ref([] as StudentAppealRequest[]);
let applicationId: number;
const showRequestForAppeal = computed(
Expand Down Expand Up @@ -107,6 +113,7 @@ export default defineComponent({
const submitAppeal = async (appealRequests: StudentAppealRequest[]) => {
try {
processing.value = true;
await StudentAppealService.shared.submitStudentAppeal(
applicationId,
appealRequests,
Expand All @@ -118,17 +125,18 @@ export default defineComponent({
backToRequestForm();
} catch (error: unknown) {
if (error instanceof ApiProcessError) {
if (
[
INVALID_APPLICATION_NUMBER,
APPLICATION_CHANGE_NOT_ELIGIBLE,
].includes(error.errorType)
) {
snackBar.warn(`Not able to submit. ${error.message}`);
return;
switch (error.errorType) {
case INVALID_APPLICATION_NUMBER:
case APPLICATION_CHANGE_NOT_ELIGIBLE:
snackBar.warn(`Not able to submit. ${error.message}`);
break;
case APPLICATION_HAS_PENDING_APPEAL:
snackBar.error(`${error.message}`);
break;
}
}
snackBar.error("An unexpected error happened during the submission.");
} finally {
processing.value = false;
}
};
Expand All @@ -138,6 +146,7 @@ export default defineComponent({
showRequestForAppeal,
backToRequestForm,
submitAppeal,
processing,
};
},
});
Expand Down

0 comments on commit 6f5c263

Please sign in to comment.