Skip to content

Commit 0906909

Browse files
authored
Merge pull request #1469 from bcgov/stories/ecer-5117
Stories/ecer 5117: ICRA eligibility submission
2 parents 292454a + 88b49e5 commit 0906909

36 files changed

+350
-68
lines changed

src/ECER.Clients.RegistryPortal/ECER.Clients.RegistryPortal.Server/ICRA/ICRAEligibilitiesEndpoints.cs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using ECER.Utilities.Security;
66
using MediatR;
77
using Microsoft.AspNetCore.Http.HttpResults;
8+
using Microsoft.AspNetCore.Mvc;
89

910
namespace ECER.Clients.RegistryPortal.Server.ICRA;
1011

@@ -58,6 +59,36 @@ public void Register(IEndpointRouteBuilder endpointRouteBuilder)
5859
.WithOpenApi("Handles icra queries", string.Empty, "icra_get")
5960
.RequireAuthorization()
6061
.WithParameterValidation();
62+
63+
endpointRouteBuilder.MapPost("/api/icra", async Task<Results<Ok<SubmitICRAEligibilityResponse>, BadRequest<ProblemDetails>, NotFound>> (ICRAEligibilitySubmissionRequest request, HttpContext ctx, IMediator messageBus, IMapper mapper, CancellationToken ct) =>
64+
{
65+
var userId = ctx.User.GetUserContext()?.UserId;
66+
bool IdIsNotGuid = !Guid.TryParse(request.Id, out _); if (IdIsNotGuid)
67+
{
68+
return TypedResults.BadRequest(new ProblemDetails() { Title = "ICRAEligibilityId is not valid" });
69+
}
70+
71+
var cmd = new SubmitICRAEligibilityCommand(request.Id!, userId!);
72+
var result = await messageBus.Send(cmd, ct);
73+
if (!result.IsSuccess && result.Error == Managers.Registry.Contract.ICRA.SubmissionError.DraftIcraEligibilityNotFound)
74+
{
75+
return TypedResults.NotFound();
76+
}
77+
if (!result.IsSuccess && result.Error == Managers.Registry.Contract.ICRA.SubmissionError.DraftIcraEligibilityValidationFailed)
78+
{
79+
var problemDetails = new ProblemDetails
80+
{
81+
Status = StatusCodes.Status400BadRequest,
82+
Title = "ICRA Eligibility submission failed",
83+
Extensions = { ["errors"] = result.ValidationErrors }
84+
};
85+
return TypedResults.BadRequest(problemDetails);
86+
}
87+
return TypedResults.Ok(new SubmitICRAEligibilityResponse(mapper.Map<ICRAEligibility>(result.Eligibility)));
88+
})
89+
.WithOpenApi("Submit an ICRA Eligibility", string.Empty, "icra_post")
90+
.RequireAuthorization()
91+
.WithParameterValidation();
6192
}
6293
}
6394

@@ -128,3 +159,6 @@ public enum ICRAStatus
128159
ReadyforReview,
129160
Submitted
130161
}
162+
163+
public record ICRAEligibilitySubmissionRequest(string Id);
164+
public record SubmitICRAEligibilityResponse(ICRAEligibility Eligibility);

src/ECER.Clients.RegistryPortal/ecer.clients.registryportal.client/src/api/icra.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,16 @@ const createOrUpdateDraftIcraEligibility = async (
3030
});
3131
};
3232

33-
export { createOrUpdateDraftIcraEligibility, getIcraEligibilities };
33+
const submitIcraEligibilityApplication = async (eligibilityId: string): Promise<ApiResponse<Components.Schemas.SubmitICRAEligibilityResponse | null | undefined>> => {
34+
const client = await getClient();
35+
const body: Components.Schemas.ICRAEligibilitySubmissionRequest = {
36+
id: eligibilityId,
37+
};
38+
39+
return apiResultHandler.execute<Components.Schemas.SubmitICRAEligibilityResponse | null | undefined>({
40+
request: client.icra_post(null, body),
41+
key: "icra_post",
42+
});
43+
};
44+
45+
export { createOrUpdateDraftIcraEligibility, getIcraEligibilities, submitIcraEligibilityApplication };

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,13 +172,13 @@ export default defineComponent({
172172
}
173173
} else if (this.certification.certificatePDFGeneration === "Yes") {
174174
const file = await getCertificateFileById(this.certification.id ?? "");
175-
this.pdfUrl = window.URL.createObjectURL(file.data);
175+
this.pdfUrl = globalThis.URL.createObjectURL(file.data);
176176
this.fileSize = humanFileSize(file.data.size);
177177
}
178178
}
179179
},
180180
unmounted() {
181-
window.URL.revokeObjectURL(this.pdfUrl);
181+
globalThis.URL.revokeObjectURL(this.pdfUrl);
182182
},
183183
methods: {
184184
generateFileDisplayName() {

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,15 @@ export default defineComponent({
2525
};
2626
},
2727
unmounted() {
28-
window.URL.revokeObjectURL(this.documentUrl);
28+
globalThis.URL.revokeObjectURL(this.documentUrl);
2929
},
3030
methods: {
3131
async downloadFile() {
3232
this.loading = true;
3333
3434
try {
3535
const response = await this.getFileFunction();
36-
this.documentUrl = window.URL.createObjectURL(response.data);
36+
this.documentUrl = globalThis.URL.createObjectURL(response.data);
3737
3838
const anchor = document.createElement("a");
3939
anchor.href = this.documentUrl;
Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
1-
<template></template>
1+
<template>Not implemented you are viewing eligibility application id: {{ icraEligibilityId }}</template>
22

33
<script lang="ts">
44
import { defineComponent } from "vue";
55
66
export default defineComponent({
77
name: "IcraEligibilitySummary",
8+
props: {
9+
icraEligibilityId: {
10+
type: String,
11+
required: true,
12+
},
13+
},
814
});
915
</script>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ export default defineComponent({
184184
185185
//reset grecaptcha after success, token cannot be reused
186186
this.recaptchaToken = "";
187-
window.grecaptcha.reset();
187+
globalThis.grecaptcha.reset();
188188
await this.$nextTick();
189189
(this.$refs.lookupForm as VForm).resetValidation();
190190
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ export default defineComponent({
6363
this.messages = response.data?.communications || [];
6464
this.messageCount = response.data?.totalMessagesCount || 0;
6565
66-
window.scrollTo({ top: 0, behavior: "smooth" });
66+
globalThis.scrollTo({ top: 0, behavior: "smooth" });
6767
6868
// After the list is rendered, select/load the first message if available
6969
await nextTick();

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ export default defineComponent({
5858
async loadChildMessages(messageId: string) {
5959
this.messageStore.currentThread = (await getChildMessages({ parentId: messageId })).data?.communications;
6060
this.messageStore.currentMessage = this.message;
61-
window.scrollTo({
61+
globalThis.scrollTo({
6262
top: 0,
6363
behavior: "smooth",
6464
});

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ export default defineComponent({
125125
if (refSet.has(`${this.formStore.formData.firstName.toLowerCase()} ${this.formStore.formData.lastName.toLowerCase()}`)) {
126126
this.isDuplicateReference = true;
127127
//scroll to top of page
128-
window.scrollTo({
128+
globalThis.scrollTo({
129129
top: 0,
130130
behavior: "smooth",
131131
});

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ export default defineComponent({
129129
if (refSet.has(`${this.formStore.formData.firstName.toLowerCase()} ${this.formStore.formData.lastName.toLowerCase()}`)) {
130130
this.isDuplicateReference = true;
131131
//scroll to top of page
132-
window.scrollTo({
132+
globalThis.scrollTo({
133133
top: 0,
134134
behavior: "smooth",
135135
});

0 commit comments

Comments
 (0)