Skip to content

Commit cb6b206

Browse files
authored
Merge pull request #1450 from bcgov/bugs/ecer-5464-release-master
ECER-5464: Better handling of multiple application submissions
2 parents 9999df0 + c341704 commit cb6b206

File tree

70 files changed

+8633
-1895
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+8633
-1895
lines changed

src/ECER.Clients.RegistryPortal/ECER.Clients.RegistryPortal.Server/Applications/ApplicationsEndpoints.cs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
using System.ComponentModel;
2-
using System.ComponentModel.DataAnnotations;
3-
using AutoMapper;
1+
using AutoMapper;
42
using ECER.Infrastructure.Common;
53
using ECER.Managers.Registry.Contract.Applications;
64
using ECER.Utilities.Hosting;
75
using ECER.Utilities.Security;
86
using MediatR;
97
using Microsoft.AspNetCore.Http.HttpResults;
108
using Microsoft.AspNetCore.Mvc;
9+
using System.ComponentModel;
10+
using System.ComponentModel.DataAnnotations;
1111

1212
namespace ECER.Clients.RegistryPortal.Server.Applications;
1313

@@ -57,7 +57,7 @@ public void Register(IEndpointRouteBuilder endpointRouteBuilder)
5757
{
5858
return TypedResults.NotFound();
5959
}
60-
if (!result.IsSuccess && result.Error == SubmissionError.DraftApplicationValidationFailed)
60+
if (!result.IsSuccess && result.Error == SubmissionError.DraftApplicationValidationFailed || result.Error == SubmissionError.SubmittedApplicationAlreadyExists)
6161
{
6262
var problemDetails = new ProblemDetails
6363
{
@@ -67,6 +67,7 @@ public void Register(IEndpointRouteBuilder endpointRouteBuilder)
6767
};
6868
return TypedResults.BadRequest(problemDetails);
6969
}
70+
7071
return TypedResults.Ok(new SubmitApplicationResponse(mapper.Map<Application>(result.Application)));
7172
})
7273
.WithOpenApi("Submit an application", string.Empty, "application_post")
@@ -485,7 +486,8 @@ public enum ApplicationStatus
485486
InProgress,
486487
PendingQueue,
487488
ReconsiderationDecision,
488-
AppealDecision
489+
AppealDecision,
490+
PendingPSPConsultationNeeded
489491
}
490492

491493
public enum ApplicationOrigin
@@ -519,6 +521,7 @@ public enum ApplicationTypes
519521
New,
520522
Renewal,
521523
LabourMobility,
524+
ICRA
522525
}
523526

524527
public enum EducationOrigin

src/ECER.Clients.RegistryPortal/ecer.clients.registryportal.client/src/components/pages/Dashboard.vue

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -307,12 +307,7 @@ export default defineComponent({
307307
return (
308308
this.applicationStore.applicationStatus === undefined ||
309309
this.applicationStore.applicationStatus === "Draft" ||
310-
this.applicationStore.applicationStatus === "Submitted" ||
311-
this.applicationStore.applicationStatus === "Ready" ||
312-
this.applicationStore.applicationStatus === "InProgress" ||
313-
this.applicationStore.applicationStatus === "PendingQueue" ||
314-
this.applicationStore.applicationStatus === "Pending" ||
315-
this.applicationStore.applicationStatus === "Escalated"
310+
this.applicationStore.hasSubmittedApplication
316311
);
317312
},
318313
showTransferCard(): boolean {

src/ECER.Clients.RegistryPortal/ecer.clients.registryportal.client/src/router.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { useCertificationStore } from "./store/certification";
77
import { useFormStore } from "./store/form";
88
import { useMessageStore } from "./store/message";
99
import { useWizardStore } from "./store/wizard";
10+
import { useConfigStore } from "./store/config";
1011

1112
const router = createRouter({
1213
history: createWebHistory(),
@@ -297,7 +298,7 @@ const router = createRouter({
297298
],
298299
});
299300

300-
// Gaurd for authenticated routes
301+
// Guard for authenticated routes
301302
router.beforeEach(async (to, _) => {
302303
const oidcStore = useOidcStore();
303304
const userStore = useUserStore();
@@ -390,4 +391,13 @@ router.beforeEach((to, _, next) => {
390391
} else next();
391392
});
392393

394+
// Guard to prevent users from accessing /application if they have already submitted an application
395+
router.beforeEach((to, _, next) => {
396+
const applicationStore = useApplicationStore();
397+
if (to.path === "/application" && applicationStore.hasSubmittedApplication) {
398+
console.warn("User has already submitted an application, redirecting to home page.");
399+
next({ path: "/" });
400+
} else next();
401+
});
402+
393403
export default router;

src/ECER.Clients.RegistryPortal/ecer.clients.registryportal.client/src/store/application.ts

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,17 @@ export const useApplicationStore = defineStore("application", {
7979
hasDraftApplication(state): boolean {
8080
return state.draftApplication.id !== undefined;
8181
},
82+
hasSubmittedApplication(state): boolean {
83+
return (
84+
state.application?.status === "Submitted" ||
85+
state.application?.status === "Ready" ||
86+
state.application?.status === "InProgress" ||
87+
state.application?.status === "PendingQueue" ||
88+
state.application?.status === "Pending" ||
89+
state.application?.status === "PendingPSPConsultationNeeded" ||
90+
state.application?.status === "Escalated"
91+
);
92+
},
8293
hasApplication(state): boolean {
8394
return state.application !== null;
8495
},
@@ -302,18 +313,14 @@ export const useApplicationStore = defineStore("application", {
302313

303314
// One year renewal explanation letter
304315
if (oneYearRenewalExplanationId && oneYearRenewalExplanationOtherId) {
305-
this.draftApplication.oneYearRenewalExplanationChoice =
306-
wizardStore.wizardData[wizardStore.wizardConfig.steps.oneYearRenewalExplanation.form.inputs.oneYearRenewalExplanation.id];
307-
this.draftApplication.renewalExplanationOther =
308-
wizardStore.wizardData[wizardStore.wizardConfig.steps.oneYearRenewalExplanation.form.inputs.renewalExplanationOther.id];
316+
this.draftApplication.oneYearRenewalExplanationChoice = wizardStore.wizardData[oneYearRenewalExplanationId];
317+
this.draftApplication.renewalExplanationOther = wizardStore.wizardData[oneYearRenewalExplanationOtherId];
309318
}
310319

311320
// Five year renewal explanation letter
312321
if (fiveYearRenewalExplanationId && fiveYearRenewalExplanationOtherId) {
313-
this.draftApplication.fiveYearRenewalExplanationChoice =
314-
wizardStore.wizardData[wizardStore.wizardConfig.steps.fiveYearRenewalExplanation.form.inputs.fiveYearRenewalExplanation.id];
315-
this.draftApplication.renewalExplanationOther =
316-
wizardStore.wizardData[wizardStore.wizardConfig.steps.fiveYearRenewalExplanation.form.inputs.renewalExplanationOther.id];
322+
this.draftApplication.fiveYearRenewalExplanationChoice = wizardStore.wizardData[fiveYearRenewalExplanationId];
323+
this.draftApplication.renewalExplanationOther = wizardStore.wizardData[fiveYearRenewalExplanationOtherId];
317324
}
318325

319326
// Character References step data

0 commit comments

Comments
 (0)