From 03ba2e9251f491bb2d33c11f8aef04472df5fb34 Mon Sep 17 00:00:00 2001 From: rcmenno <129762469+rcmenno@users.noreply.github.com> Date: Thu, 19 Sep 2024 15:37:03 +0200 Subject: [PATCH] Rename incorrect spelling of beneficiary --- .../Services/BeneficiariesService.test.js | 12 +++---- .../Services/BeneficiaryEligilityService.js | 2 +- .../BeneficiaryEligilityService.test.js | 6 ++-- PWA/public/Services/BeneficiaryInfoService.js | 8 ++--- PWA/public/Services/CacheFilePathService.js | 8 ++--- PWA/public/Services/Database.js | 4 +-- PWA/public/Services/Database.test.js | 2 +- .../BeneficiaryCodePostHandler.js | 2 +- .../BeneficiaryDataUploadHandler.js | 2 +- ...eBeneficiaryCodeInputMethodPageHandler.js} | 2 +- .../FetchEventHandlers/FetchEventHandlers.js | 8 ++--- ...SelectBeneficiaryCodeInputMethodHandler.js | 33 +++++++++++++++++++ PWA/public/sw.js | 3 ++ PWA/src/Services/BeneficiariesService.test.ts | 12 +++---- .../BeneficiaryEligilityService.test.ts | 6 ++-- .../Services/BeneficiaryEligilityService.ts | 2 +- PWA/src/Services/BeneficiaryInfoService.ts | 8 ++--- PWA/src/Services/CacheFilePathService.ts | 8 ++--- PWA/src/Services/Database.test.ts | 2 +- PWA/src/Services/Database.ts | 4 +-- .../BeneficiaryCodePostHandler.ts | 2 +- .../BeneficiaryDataUploadHandler.ts | 2 +- ...eBeneficiaryCodeInputMethodPageHandler.ts} | 2 +- .../FetchEventHandlers/FetchEventHandlers.ts | 8 ++--- ...electBeneficiaryCodeInputMethodHandler.ts} | 2 +- 25 files changed, 93 insertions(+), 57 deletions(-) rename PWA/public/Services/FetchEventHandlers/{ChooseBenificiaryCodeInputMethodPageHandler.js => ChooseBeneficiaryCodeInputMethodPageHandler.js} (86%) create mode 100644 PWA/public/Services/FetchEventHandlers/SelectBeneficiaryCodeInputMethodHandler.js rename PWA/src/Services/FetchEventHandlers/{ChooseBenificiaryCodeInputMethodPageHandler.ts => ChooseBeneficiaryCodeInputMethodPageHandler.ts} (90%) rename PWA/src/Services/FetchEventHandlers/{SelectBenificiaryCodeInputMethodHandler.ts => SelectBeneficiaryCodeInputMethodHandler.ts} (96%) diff --git a/PWA/public/Services/BeneficiariesService.test.js b/PWA/public/Services/BeneficiariesService.test.js index 8826784..a04b0ab 100644 --- a/PWA/public/Services/BeneficiariesService.test.js +++ b/PWA/public/Services/BeneficiariesService.test.js @@ -52,8 +52,8 @@ describe('BeneficiariesService', () => { const distributions = await database.readDistributions(); console.log(distributions); await database.addDistribution(existingDistribution); - await database.addBenificiary(beneficiary1); - await database.addBenificiary(beneficiary2); + await database.addBeneficiary(beneficiary1); + await database.addBeneficiary(beneficiary2); await database.addBeneficiaryToDistribution(beneficiary1, existingDistribution); await database.addBeneficiaryToDistribution(beneficiary2, existingDistribution); const beneficiaries = await sut.beneficiariesForActiveDistribution(); @@ -66,8 +66,8 @@ describe('BeneficiariesService', () => { const distributions = await database.readDistributions(); console.log(distributions); await database.addDistribution(existingDistribution); - await database.addBenificiary(beneficiary1); - await database.addBenificiary(beneficiary2); + await database.addBeneficiary(beneficiary1); + await database.addBeneficiary(beneficiary2); await database.addBeneficiaryToDistribution(beneficiary1, existingDistribution); await database.addBeneficiaryToDistribution(beneficiary2, existingDistribution); const eligibleBeneficiaries = await sut.eligibleBeneficiariesForActiveDistribution(); @@ -78,8 +78,8 @@ describe('BeneficiariesService', () => { const distributions = await database.readDistributions(); console.log(distributions); await database.addDistribution(existingDistribution); - await database.addBenificiary(beneficiary1); - await database.addBenificiary(beneficiary2); + await database.addBeneficiary(beneficiary1); + await database.addBeneficiary(beneficiary2); await database.addBeneficiaryToDistribution(beneficiary1, existingDistribution); await database.addBeneficiaryToDistribution(beneficiary2, existingDistribution); await database.markBeneficiaryAsReceived(beneficiary1.code, existingDistributionName); diff --git a/PWA/public/Services/BeneficiaryEligilityService.js b/PWA/public/Services/BeneficiaryEligilityService.js index a368e54..8b27064 100644 --- a/PWA/public/Services/BeneficiaryEligilityService.js +++ b/PWA/public/Services/BeneficiaryEligilityService.js @@ -2,7 +2,7 @@ export class BeneficiaryEligilityService { constructor(activeSession) { this.activeSession = activeSession; } - async isBenificiaryEligibleForCurrentDistribution(beneficiaryCode) { + async isBeneficiaryEligibleForCurrentDistribution(beneficiaryCode) { const nameOfActiveDistribution = this.activeSession.nameOfLastViewedDistribution; if (nameOfActiveDistribution) { const distribution = await this.activeSession.database.distributionWithName(nameOfActiveDistribution); diff --git a/PWA/public/Services/BeneficiaryEligilityService.test.js b/PWA/public/Services/BeneficiaryEligilityService.test.js index d923940..7e70cdb 100644 --- a/PWA/public/Services/BeneficiaryEligilityService.test.js +++ b/PWA/public/Services/BeneficiaryEligilityService.test.js @@ -26,20 +26,20 @@ describe("BeneficiaryEligilityService", () => { const activeSession = await new ActiveSession(await setupDatabase()); activeSession.nameOfLastViewedDistribution = activeDistribution.distrib_name; const sut = new BeneficiaryEligilityService(activeSession); - expect(await sut.isBenificiaryEligibleForCurrentDistribution(inActiveEligibleBeneficiaryCode)).toEqual(false); + expect(await sut.isBeneficiaryEligibleForCurrentDistribution(inActiveEligibleBeneficiaryCode)).toEqual(false); }); test("When checking elible code from active distribution during active distrubtion Then eligible", async () => { const activeSession = await new ActiveSession(await setupDatabase()); activeSession.nameOfLastViewedDistribution = activeDistribution.distrib_name; const sut = new BeneficiaryEligilityService(activeSession); - expect(await sut.isBenificiaryEligibleForCurrentDistribution(activeEligibleBeneficiaryCode)).toEqual(true); + expect(await sut.isBeneficiaryEligibleForCurrentDistribution(activeEligibleBeneficiaryCode)).toEqual(true); }); test("When checking code from any distribution during inactive distrubtion Then error is thrown", async () => { const activeSession = await new ActiveSession(await setupDatabase()); activeSession.nameOfLastViewedDistribution = undefined; const sut = new BeneficiaryEligilityService(activeSession); try { - const result = await sut.isBenificiaryEligibleForCurrentDistribution("could have been any code"); + const result = await sut.isBeneficiaryEligibleForCurrentDistribution("could have been any code"); fail("Expected error"); } catch (error) { diff --git a/PWA/public/Services/BeneficiaryInfoService.js b/PWA/public/Services/BeneficiaryInfoService.js index d666ae4..bf0994b 100644 --- a/PWA/public/Services/BeneficiaryInfoService.js +++ b/PWA/public/Services/BeneficiaryInfoService.js @@ -3,10 +3,10 @@ export class BeneficiaryInfoService { this.database = database; } async beneficiaryInfoTextFromDistribution(distribution) { - const benificiaries = await this.database.benificiariesForDistribution(distribution); - const numberOfServedBenificiaries = benificiaries.filter(benificiary => benificiary.hasBeenMarkedAsReceived).length; - if (benificiaries.length > 0) { - return "Beneficiaries served: " + numberOfServedBenificiaries + " / " + benificiaries.length; + const beneficiaries = await this.database.benificiariesForDistribution(distribution); + const numberOfServedBeneficiaries = beneficiaries.filter(beneficiary => beneficiary.hasBeenMarkedAsReceived).length; + if (beneficiaries.length > 0) { + return "Beneficiaries served: " + numberOfServedBeneficiaries + " / " + beneficiaries.length; } else { return "No beneficiary data found"; diff --git a/PWA/public/Services/CacheFilePathService.js b/PWA/public/Services/CacheFilePathService.js index 8bfb566..97c9943 100644 --- a/PWA/public/Services/CacheFilePathService.js +++ b/PWA/public/Services/CacheFilePathService.js @@ -1,11 +1,11 @@ import { BeneficiaryDataUploadHandler } from "./FetchEventHandlers/BeneficiaryDataUploadHandler.js"; -import { ChooseBenificiaryCodeInputMethodPageHandler } from "./FetchEventHandlers/ChooseBenificiaryCodeInputMethodPageHandler.js"; +import { ChooseBeneficiaryCodeInputMethodPageHandler } from "./FetchEventHandlers/ChooseBeneficiaryCodeInputMethodPageHandler.js"; import { CreateDistributionRequestHandler } from "./FetchEventHandlers/CreateDistributionRequestHandler.js"; import { DeleteDistributionPostHandler } from "./FetchEventHandlers/DeleteDistributionPostHandler.js"; import { FetchEventHandlers } from "./FetchEventHandlers/FetchEventHandlers.js"; import { ListDistributionRequestHandler } from "./FetchEventHandlers/ListDistributionRequestHandler.js"; import { NameDistributionRequestHandler } from "./FetchEventHandlers/NameDistributionRequestHandler.js"; -import { SelectBenificiaryCodeInputMethodHandler } from "./FetchEventHandlers/SelectBenificiaryCodeInputMethodHandler.js"; +import { SelectBeneficiaryCodeInputMethodHandler } from "./FetchEventHandlers/SelectBeneficiaryCodeInputMethodHandler.js"; import { SelectDistributionRequestHandler } from "./FetchEventHandlers/SelectDistributionRequestHandler.js"; import { UploadDataHandler } from "./FetchEventHandlers/UploadDataHandler.js"; import { Beneficiary } from "../Models/Beneficiary.js"; @@ -124,8 +124,8 @@ export class CacheFilePathService { NameDistributionRequestHandler.name, SelectDistributionRequestHandler.name, UploadDataHandler.name, - ChooseBenificiaryCodeInputMethodPageHandler.name, - SelectBenificiaryCodeInputMethodHandler.name, + ChooseBeneficiaryCodeInputMethodPageHandler.name, + SelectBeneficiaryCodeInputMethodHandler.name, BeneficiaryCodePostHandler.name, ViewDistributionDataHandler.name, CheckWhosMissingPageHandler.name, diff --git a/PWA/public/Services/Database.js b/PWA/public/Services/Database.js index 96a7b74..00f7644 100644 --- a/PWA/public/Services/Database.js +++ b/PWA/public/Services/Database.js @@ -119,7 +119,7 @@ export class Database { return undefined; } } - async addBenificiary(beneficiary) { + async addBeneficiary(beneficiary) { return this.addElement(ObjectStoreName.beneficiary, beneficiary); } async setActiveDistribution(activeDistribution) { @@ -147,7 +147,7 @@ export class Database { }); const existingBeneficiary = await this.beneficiaryWithCode(beneficiary.code); if (!existingBeneficiary) { - this.addBenificiary(beneficiary); + this.addBeneficiary(beneficiary); } return this.addElement(ObjectStoreName.distributionBeneficiaries, new DistributionBeneficiary(beneficiary.code, distribution.distrib_name)); } diff --git a/PWA/public/Services/Database.test.js b/PWA/public/Services/Database.test.js index 0ef0a6c..0230869 100644 --- a/PWA/public/Services/Database.test.js +++ b/PWA/public/Services/Database.test.js @@ -26,7 +26,7 @@ describe('Database', () => { } }); test("When adding a beneficiary, it can be retrieved", async () => { - await sut.addBenificiary(beneficiary); + await sut.addBeneficiary(beneficiary); const receivedBeneficiary = await sut.beneficiaryWithCode(beneficiaryCode); expect(receivedBeneficiary.code).toEqual(beneficiaryCode); }); diff --git a/PWA/public/Services/FetchEventHandlers/BeneficiaryCodePostHandler.js b/PWA/public/Services/FetchEventHandlers/BeneficiaryCodePostHandler.js index fe80b9c..ebf33d3 100644 --- a/PWA/public/Services/FetchEventHandlers/BeneficiaryCodePostHandler.js +++ b/PWA/public/Services/FetchEventHandlers/BeneficiaryCodePostHandler.js @@ -51,7 +51,7 @@ export class BeneficiaryCodePostHandler extends ActiveSessionContainer { const beneficiary = await this.activeSession.database.beneficiaryWithCode(beneficiaryCode); if (beneficiary) { return ResponseTools.wrapInHTPLTemplateAndReplaceKeysWithValues(RouteEvents.codeInputFound, { - eligibility_info_box_id: await this.eligebilityService.isBenificiaryEligibleForCurrentDistribution(beneficiaryCode) ? "eligible" : "noteligible", + eligibility_info_box_id: await this.eligebilityService.isBeneficiaryEligibleForCurrentDistribution(beneficiaryCode) ? "eligible" : "noteligible", eligibility_info_name: beneficiary.code, eligibility_info_values: beneficiary.values, }); diff --git a/PWA/public/Services/FetchEventHandlers/BeneficiaryDataUploadHandler.js b/PWA/public/Services/FetchEventHandlers/BeneficiaryDataUploadHandler.js index b04b785..db3e39e 100644 --- a/PWA/public/Services/FetchEventHandlers/BeneficiaryDataUploadHandler.js +++ b/PWA/public/Services/FetchEventHandlers/BeneficiaryDataUploadHandler.js @@ -15,7 +15,7 @@ export class BeneficiaryDataUploadHandler extends ActiveSessionContainer { if (distributionName) { const distribution = await database.distributionWithName(distributionName); if (distribution) { - await beneficiaries.forEach(async (beneficiary) => await database.addBenificiary(beneficiary)); + await beneficiaries.forEach(async (beneficiary) => await database.addBeneficiary(beneficiary)); await beneficiaries.forEach(async (beneficiary) => await database.addBeneficiaryToDistribution(beneficiary, distribution)); this.activeSession.nameOfLastViewedDistribution = distributionName; const benificiaryInfoService = new BeneficiaryInfoService(this.activeSession.database); diff --git a/PWA/public/Services/FetchEventHandlers/ChooseBenificiaryCodeInputMethodPageHandler.js b/PWA/public/Services/FetchEventHandlers/ChooseBeneficiaryCodeInputMethodPageHandler.js similarity index 86% rename from PWA/public/Services/FetchEventHandlers/ChooseBenificiaryCodeInputMethodPageHandler.js rename to PWA/public/Services/FetchEventHandlers/ChooseBeneficiaryCodeInputMethodPageHandler.js index c6102c6..64dafd0 100644 --- a/PWA/public/Services/FetchEventHandlers/ChooseBenificiaryCodeInputMethodPageHandler.js +++ b/PWA/public/Services/FetchEventHandlers/ChooseBeneficiaryCodeInputMethodPageHandler.js @@ -1,6 +1,6 @@ import { RouteEvents } from "../../RouteEvents.js"; import { ResponseTools } from "../ResponseTools.js"; -export class ChooseBenificiaryCodeInputMethodPageHandler { +export class ChooseBeneficiaryCodeInputMethodPageHandler { canHandleEvent(event) { return event.request.url.endsWith(RouteEvents.chooseBeneficiaryCodeInputMethod); } diff --git a/PWA/public/Services/FetchEventHandlers/FetchEventHandlers.js b/PWA/public/Services/FetchEventHandlers/FetchEventHandlers.js index aee2c70..ecc98c4 100644 --- a/PWA/public/Services/FetchEventHandlers/FetchEventHandlers.js +++ b/PWA/public/Services/FetchEventHandlers/FetchEventHandlers.js @@ -6,8 +6,8 @@ import { DeleteDistributionRequestHandler } from "./DeleteDistributionRequestHan import { UploadDataHandler } from "./UploadDataHandler.js"; import { BeneficiaryDataUploadHandler } from "./BeneficiaryDataUploadHandler.js"; import { DeleteDistributionPostHandler } from "./DeleteDistributionPostHandler.js"; -import { ChooseBenificiaryCodeInputMethodPageHandler } from "./ChooseBenificiaryCodeInputMethodPageHandler.js"; -import { SelectBenificiaryCodeInputMethodHandler } from "./SelectBenificiaryCodeInputMethodHandler.js"; +import { ChooseBeneficiaryCodeInputMethodPageHandler } from "./ChooseBeneficiaryCodeInputMethodPageHandler.js"; +import { SelectBeneficiaryCodeInputMethodHandler } from "./SelectBeneficiaryCodeInputMethodHandler.js"; import { ViewDistributionDataHandler } from "./ViewDistributionDataHandler.js"; import { ActiveSessionContainer } from "../ActiveSession.js"; import { BeneficiaryCodePostHandler } from "./BeneficiaryCodePostHandler.js"; @@ -28,8 +28,8 @@ export class FetchEventHandlers extends ActiveSessionContainer { new DeleteDistributionPostHandler(this.activeSession), new UploadDataHandler(), new BeneficiaryDataUploadHandler(this.activeSession), - new ChooseBenificiaryCodeInputMethodPageHandler(), - new SelectBenificiaryCodeInputMethodHandler(this.activeSession), + new ChooseBeneficiaryCodeInputMethodPageHandler(), + new SelectBeneficiaryCodeInputMethodHandler(this.activeSession), new BeneficiaryCodePostHandler(this.activeSession), new ViewDistributionDataHandler(this.activeSession), new CheckWhosMissingPageHandler(this.activeSession), diff --git a/PWA/public/Services/FetchEventHandlers/SelectBeneficiaryCodeInputMethodHandler.js b/PWA/public/Services/FetchEventHandlers/SelectBeneficiaryCodeInputMethodHandler.js new file mode 100644 index 0000000..f10977d --- /dev/null +++ b/PWA/public/Services/FetchEventHandlers/SelectBeneficiaryCodeInputMethodHandler.js @@ -0,0 +1,33 @@ +import { RouteEvents } from "../../RouteEvents.js"; +import { ActiveSessionContainer } from "../ActiveSession.js"; +import { DeserialisationService } from "../DeserialisationService.js"; +import { ResponseTools } from "../ResponseTools.js"; +export class SelectBeneficiaryCodeInputMethodHandler extends ActiveSessionContainer { + canHandleEvent(event) { + return event.request.url.endsWith(RouteEvents.selectBeneficiaryCodeInputMethod); + } + async handleEvent(event) { + try { + const post = await DeserialisationService.deserializeFormDataFromRequest(event.request); + return ResponseTools.wrapInHtmlTemplate(this.templatepageForInputMethod(post.input_method)); + } + catch (error) { + console.error(error); + return fetch(RouteEvents.home); + } + } + templatepageForInputMethod(inputMethod) { + this.activeSession.nameOfLastUsedDistributionInputMethod = inputMethod; + if (inputMethod == "video") { + this.activeSession.nameOfLastUsedDistributionInputMethod = inputMethod; + return RouteEvents.codeInputUsingCamera; + } + else if (inputMethod == "text") { + this.activeSession.nameOfLastUsedDistributionInputMethod = inputMethod; + return RouteEvents.codeinputUsingTextField; + } + else { + throw "Unexpected input method: " + inputMethod; + } + } +} diff --git a/PWA/public/sw.js b/PWA/public/sw.js index 33ff7d3..538af96 100644 --- a/PWA/public/sw.js +++ b/PWA/public/sw.js @@ -50,6 +50,9 @@ self.addEventListener("activate", function (event) { return caches.delete(key); } })); + }) + .catch((error) => { + console.error("Promise rejected with:", error); })); return self.clients.claim(); }); diff --git a/PWA/src/Services/BeneficiariesService.test.ts b/PWA/src/Services/BeneficiariesService.test.ts index 7001712..c7ffacf 100644 --- a/PWA/src/Services/BeneficiariesService.test.ts +++ b/PWA/src/Services/BeneficiariesService.test.ts @@ -57,8 +57,8 @@ describe('BeneficiariesService', () => { const distributions = await database.readDistributions() console.log(distributions) await database.addDistribution(existingDistribution) - await database.addBenificiary(beneficiary1) - await database.addBenificiary(beneficiary2) + await database.addBeneficiary(beneficiary1) + await database.addBeneficiary(beneficiary2) await database.addBeneficiaryToDistribution(beneficiary1, existingDistribution) await database.addBeneficiaryToDistribution(beneficiary2, existingDistribution) const beneficiaries = await sut.beneficiariesForActiveDistribution() @@ -72,8 +72,8 @@ describe('BeneficiariesService', () => { const distributions = await database.readDistributions() console.log(distributions) await database.addDistribution(existingDistribution) - await database.addBenificiary(beneficiary1) - await database.addBenificiary(beneficiary2) + await database.addBeneficiary(beneficiary1) + await database.addBeneficiary(beneficiary2) await database.addBeneficiaryToDistribution(beneficiary1, existingDistribution) await database.addBeneficiaryToDistribution(beneficiary2, existingDistribution) const eligibleBeneficiaries = await sut.eligibleBeneficiariesForActiveDistribution() @@ -86,8 +86,8 @@ describe('BeneficiariesService', () => { const distributions = await database.readDistributions() console.log(distributions) await database.addDistribution(existingDistribution) - await database.addBenificiary(beneficiary1) - await database.addBenificiary(beneficiary2) + await database.addBeneficiary(beneficiary1) + await database.addBeneficiary(beneficiary2) await database.addBeneficiaryToDistribution(beneficiary1, existingDistribution) await database.addBeneficiaryToDistribution(beneficiary2, existingDistribution) diff --git a/PWA/src/Services/BeneficiaryEligilityService.test.ts b/PWA/src/Services/BeneficiaryEligilityService.test.ts index 417e1c4..b31b13e 100644 --- a/PWA/src/Services/BeneficiaryEligilityService.test.ts +++ b/PWA/src/Services/BeneficiaryEligilityService.test.ts @@ -55,7 +55,7 @@ describe("BeneficiaryEligilityService", () => { activeSession.nameOfLastViewedDistribution = activeDistribution.distrib_name; const sut = new BeneficiaryEligilityService(activeSession); expect( - await sut.isBenificiaryEligibleForCurrentDistribution( + await sut.isBeneficiaryEligibleForCurrentDistribution( inActiveEligibleBeneficiaryCode ) ).toEqual(false); @@ -66,7 +66,7 @@ describe("BeneficiaryEligilityService", () => { activeSession.nameOfLastViewedDistribution = activeDistribution.distrib_name; const sut = new BeneficiaryEligilityService(activeSession); expect( - await sut.isBenificiaryEligibleForCurrentDistribution( + await sut.isBeneficiaryEligibleForCurrentDistribution( activeEligibleBeneficiaryCode ) ).toEqual(true); @@ -77,7 +77,7 @@ describe("BeneficiaryEligilityService", () => { activeSession.nameOfLastViewedDistribution = undefined; const sut = new BeneficiaryEligilityService(activeSession); try { - const result = await sut.isBenificiaryEligibleForCurrentDistribution( + const result = await sut.isBeneficiaryEligibleForCurrentDistribution( "could have been any code" ); fail("Expected error"); diff --git a/PWA/src/Services/BeneficiaryEligilityService.ts b/PWA/src/Services/BeneficiaryEligilityService.ts index baf328a..0b959e4 100644 --- a/PWA/src/Services/BeneficiaryEligilityService.ts +++ b/PWA/src/Services/BeneficiaryEligilityService.ts @@ -8,7 +8,7 @@ export class BeneficiaryEligilityService { this.activeSession = activeSession } - async isBenificiaryEligibleForCurrentDistribution(beneficiaryCode: string | undefined): Promise { + async isBeneficiaryEligibleForCurrentDistribution(beneficiaryCode: string | undefined): Promise { const nameOfActiveDistribution = this.activeSession.nameOfLastViewedDistribution if(nameOfActiveDistribution) { const distribution = await this.activeSession.database.distributionWithName(nameOfActiveDistribution) diff --git a/PWA/src/Services/BeneficiaryInfoService.ts b/PWA/src/Services/BeneficiaryInfoService.ts index 4b4a812..0687c75 100644 --- a/PWA/src/Services/BeneficiaryInfoService.ts +++ b/PWA/src/Services/BeneficiaryInfoService.ts @@ -11,10 +11,10 @@ export class BeneficiaryInfoService { } async beneficiaryInfoTextFromDistribution(distribution: Distribution): Promise { - const benificiaries: DistributionBeneficiary[] = await this.database.benificiariesForDistribution(distribution) - const numberOfServedBenificiaries = benificiaries.filter(benificiary => benificiary.hasBeenMarkedAsReceived).length - if(benificiaries.length > 0) { - return "Beneficiaries served: " + numberOfServedBenificiaries +" / " + benificiaries.length + const beneficiaries: DistributionBeneficiary[] = await this.database.benificiariesForDistribution(distribution) + const numberOfServedBeneficiaries = beneficiaries.filter(beneficiary => beneficiary.hasBeenMarkedAsReceived).length + if(beneficiaries.length > 0) { + return "Beneficiaries served: " + numberOfServedBeneficiaries +" / " + beneficiaries.length } else { return "No beneficiary data found" } diff --git a/PWA/src/Services/CacheFilePathService.ts b/PWA/src/Services/CacheFilePathService.ts index af23f0e..5283e48 100644 --- a/PWA/src/Services/CacheFilePathService.ts +++ b/PWA/src/Services/CacheFilePathService.ts @@ -1,11 +1,11 @@ import { BeneficiaryDataUploadHandler } from "./FetchEventHandlers/BeneficiaryDataUploadHandler.js"; -import { ChooseBenificiaryCodeInputMethodPageHandler } from "./FetchEventHandlers/ChooseBenificiaryCodeInputMethodPageHandler.js"; +import { ChooseBeneficiaryCodeInputMethodPageHandler } from "./FetchEventHandlers/ChooseBeneficiaryCodeInputMethodPageHandler.js"; import { CreateDistributionRequestHandler } from "./FetchEventHandlers/CreateDistributionRequestHandler.js"; import { DeleteDistributionPostHandler } from "./FetchEventHandlers/DeleteDistributionPostHandler.js"; import { FetchEventHandlers } from "./FetchEventHandlers/FetchEventHandlers.js"; import { ListDistributionRequestHandler } from "./FetchEventHandlers/ListDistributionRequestHandler.js"; import { NameDistributionRequestHandler } from "./FetchEventHandlers/NameDistributionRequestHandler.js"; -import { SelectBenificiaryCodeInputMethodHandler } from "./FetchEventHandlers/SelectBenificiaryCodeInputMethodHandler.js"; +import { SelectBeneficiaryCodeInputMethodHandler } from "./FetchEventHandlers/SelectBeneficiaryCodeInputMethodHandler.js"; import { SelectDistributionRequestHandler } from "./FetchEventHandlers/SelectDistributionRequestHandler.js"; import { UploadDataHandler } from "./FetchEventHandlers/UploadDataHandler.js"; import { Beneficiary } from "../Models/Beneficiary.js"; @@ -137,8 +137,8 @@ export class CacheFilePathService { NameDistributionRequestHandler.name, SelectDistributionRequestHandler.name, UploadDataHandler.name, - ChooseBenificiaryCodeInputMethodPageHandler.name, - SelectBenificiaryCodeInputMethodHandler.name, + ChooseBeneficiaryCodeInputMethodPageHandler.name, + SelectBeneficiaryCodeInputMethodHandler.name, BeneficiaryCodePostHandler.name, ViewDistributionDataHandler.name, CheckWhosMissingPageHandler.name, diff --git a/PWA/src/Services/Database.test.ts b/PWA/src/Services/Database.test.ts index 871d122..f2ef998 100644 --- a/PWA/src/Services/Database.test.ts +++ b/PWA/src/Services/Database.test.ts @@ -35,7 +35,7 @@ describe('Database', () => { }) test("When adding a beneficiary, it can be retrieved", async () => { - await sut.addBenificiary(beneficiary) + await sut.addBeneficiary(beneficiary) const receivedBeneficiary: any = await sut.beneficiaryWithCode(beneficiaryCode) expect( receivedBeneficiary.code diff --git a/PWA/src/Services/Database.ts b/PWA/src/Services/Database.ts index 494167c..8601881 100644 --- a/PWA/src/Services/Database.ts +++ b/PWA/src/Services/Database.ts @@ -156,7 +156,7 @@ export class Database { } } - async addBenificiary(beneficiary: Beneficiary): Promise { + async addBeneficiary(beneficiary: Beneficiary): Promise { return this.addElement(ObjectStoreName.beneficiary, beneficiary); } @@ -195,7 +195,7 @@ export class Database { beneficiary.code ); if (!existingBeneficiary) { - this.addBenificiary(beneficiary); + this.addBeneficiary(beneficiary); } return this.addElement( diff --git a/PWA/src/Services/FetchEventHandlers/BeneficiaryCodePostHandler.ts b/PWA/src/Services/FetchEventHandlers/BeneficiaryCodePostHandler.ts index 580d3a8..be8fe12 100644 --- a/PWA/src/Services/FetchEventHandlers/BeneficiaryCodePostHandler.ts +++ b/PWA/src/Services/FetchEventHandlers/BeneficiaryCodePostHandler.ts @@ -56,7 +56,7 @@ export class BeneficiaryCodePostHandler extends ActiveSessionContainer implement if(beneficiary) { return ResponseTools.wrapInHTPLTemplateAndReplaceKeysWithValues( RouteEvents.codeInputFound, { - eligibility_info_box_id: await this.eligebilityService.isBenificiaryEligibleForCurrentDistribution(beneficiaryCode) ? "eligible" : "noteligible", + eligibility_info_box_id: await this.eligebilityService.isBeneficiaryEligibleForCurrentDistribution(beneficiaryCode) ? "eligible" : "noteligible", eligibility_info_name: beneficiary.code, eligibility_info_values: beneficiary.values, } diff --git a/PWA/src/Services/FetchEventHandlers/BeneficiaryDataUploadHandler.ts b/PWA/src/Services/FetchEventHandlers/BeneficiaryDataUploadHandler.ts index 72c51da..bb4834c 100644 --- a/PWA/src/Services/FetchEventHandlers/BeneficiaryDataUploadHandler.ts +++ b/PWA/src/Services/FetchEventHandlers/BeneficiaryDataUploadHandler.ts @@ -19,7 +19,7 @@ export class BeneficiaryDataUploadHandler extends ActiveSessionContainer impleme if(distributionName) { const distribution = await database.distributionWithName(distributionName) if(distribution) { - await beneficiaries.forEach(async (beneficiary) => await database.addBenificiary(beneficiary)) + await beneficiaries.forEach(async (beneficiary) => await database.addBeneficiary(beneficiary)) await beneficiaries.forEach(async (beneficiary) => await database.addBeneficiaryToDistribution(beneficiary, distribution)) this.activeSession.nameOfLastViewedDistribution = distributionName const benificiaryInfoService = new BeneficiaryInfoService(this.activeSession.database) diff --git a/PWA/src/Services/FetchEventHandlers/ChooseBenificiaryCodeInputMethodPageHandler.ts b/PWA/src/Services/FetchEventHandlers/ChooseBeneficiaryCodeInputMethodPageHandler.ts similarity index 90% rename from PWA/src/Services/FetchEventHandlers/ChooseBenificiaryCodeInputMethodPageHandler.ts rename to PWA/src/Services/FetchEventHandlers/ChooseBeneficiaryCodeInputMethodPageHandler.ts index 5b5665e..0ff6dab 100644 --- a/PWA/src/Services/FetchEventHandlers/ChooseBenificiaryCodeInputMethodPageHandler.ts +++ b/PWA/src/Services/FetchEventHandlers/ChooseBeneficiaryCodeInputMethodPageHandler.ts @@ -3,7 +3,7 @@ import { FetchEventHandler } from "../../Interfaces/FetchEventHandler.js"; import { RouteEvents } from "../../RouteEvents.js"; import { ResponseTools } from "../ResponseTools.js"; -export class ChooseBenificiaryCodeInputMethodPageHandler implements FetchEventHandler { +export class ChooseBeneficiaryCodeInputMethodPageHandler implements FetchEventHandler { canHandleEvent(event: FetchEvent): boolean { return event.request.url.endsWith(RouteEvents.chooseBeneficiaryCodeInputMethod); } diff --git a/PWA/src/Services/FetchEventHandlers/FetchEventHandlers.ts b/PWA/src/Services/FetchEventHandlers/FetchEventHandlers.ts index 8d2472f..0a8a8ac 100644 --- a/PWA/src/Services/FetchEventHandlers/FetchEventHandlers.ts +++ b/PWA/src/Services/FetchEventHandlers/FetchEventHandlers.ts @@ -8,8 +8,8 @@ import { DeleteDistributionRequestHandler } from "./DeleteDistributionRequestHan import { UploadDataHandler } from "./UploadDataHandler.js"; import { BeneficiaryDataUploadHandler } from "./BeneficiaryDataUploadHandler.js" import { DeleteDistributionPostHandler } from "./DeleteDistributionPostHandler.js"; -import { ChooseBenificiaryCodeInputMethodPageHandler } from "./ChooseBenificiaryCodeInputMethodPageHandler.js"; -import { SelectBenificiaryCodeInputMethodHandler } from "./SelectBenificiaryCodeInputMethodHandler.js"; +import { ChooseBeneficiaryCodeInputMethodPageHandler } from "./ChooseBeneficiaryCodeInputMethodPageHandler.js"; +import { SelectBeneficiaryCodeInputMethodHandler } from "./SelectBeneficiaryCodeInputMethodHandler.js"; import { ViewDistributionDataHandler } from "./ViewDistributionDataHandler.js"; import { ActiveSessionContainer } from "../ActiveSession.js"; import { BeneficiaryCodePostHandler } from "./BeneficiaryCodePostHandler.js"; @@ -29,8 +29,8 @@ export class FetchEventHandlers extends ActiveSessionContainer implements FetchE new DeleteDistributionPostHandler(this.activeSession), new UploadDataHandler(), new BeneficiaryDataUploadHandler(this.activeSession), - new ChooseBenificiaryCodeInputMethodPageHandler(), - new SelectBenificiaryCodeInputMethodHandler(this.activeSession), + new ChooseBeneficiaryCodeInputMethodPageHandler(), + new SelectBeneficiaryCodeInputMethodHandler(this.activeSession), new BeneficiaryCodePostHandler(this.activeSession), new ViewDistributionDataHandler(this.activeSession), new CheckWhosMissingPageHandler(this.activeSession), diff --git a/PWA/src/Services/FetchEventHandlers/SelectBenificiaryCodeInputMethodHandler.ts b/PWA/src/Services/FetchEventHandlers/SelectBeneficiaryCodeInputMethodHandler.ts similarity index 96% rename from PWA/src/Services/FetchEventHandlers/SelectBenificiaryCodeInputMethodHandler.ts rename to PWA/src/Services/FetchEventHandlers/SelectBeneficiaryCodeInputMethodHandler.ts index 6689f3e..51c5124 100644 --- a/PWA/src/Services/FetchEventHandlers/SelectBenificiaryCodeInputMethodHandler.ts +++ b/PWA/src/Services/FetchEventHandlers/SelectBeneficiaryCodeInputMethodHandler.ts @@ -6,7 +6,7 @@ import { ActiveSessionContainer } from "../ActiveSession.js"; import { DeserialisationService } from "../DeserialisationService.js"; import { ResponseTools } from "../ResponseTools.js"; -export class SelectBenificiaryCodeInputMethodHandler extends ActiveSessionContainer implements FetchEventHandler { +export class SelectBeneficiaryCodeInputMethodHandler extends ActiveSessionContainer implements FetchEventHandler { canHandleEvent(event: FetchEvent): boolean { return event.request.url.endsWith(RouteEvents.selectBeneficiaryCodeInputMethod); }