Skip to content

Commit

Permalink
Rename incorrect spelling of beneficiary
Browse files Browse the repository at this point in the history
  • Loading branch information
rcmenno committed Sep 19, 2024
1 parent 8e449d6 commit 03ba2e9
Show file tree
Hide file tree
Showing 25 changed files with 93 additions and 57 deletions.
12 changes: 6 additions & 6 deletions PWA/public/Services/BeneficiariesService.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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();
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion PWA/public/Services/BeneficiaryEligilityService.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions PWA/public/Services/BeneficiaryEligilityService.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
8 changes: 4 additions & 4 deletions PWA/public/Services/BeneficiaryInfoService.js
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
8 changes: 4 additions & 4 deletions PWA/public/Services/CacheFilePathService.js
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions PWA/public/Services/Database.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ export class Database {
return undefined;
}
}
async addBenificiary(beneficiary) {
async addBeneficiary(beneficiary) {
return this.addElement(ObjectStoreName.beneficiary, beneficiary);
}
async setActiveDistribution(activeDistribution) {
Expand Down Expand Up @@ -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));
}
Expand Down
2 changes: 1 addition & 1 deletion PWA/public/Services/Database.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
@@ -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);
}
Expand Down
8 changes: 4 additions & 4 deletions PWA/public/Services/FetchEventHandlers/FetchEventHandlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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),
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
}
}
}
3 changes: 3 additions & 0 deletions PWA/public/sw.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
Expand Down
12 changes: 6 additions & 6 deletions PWA/src/Services/BeneficiariesService.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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()
Expand All @@ -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)

Expand Down
6 changes: 3 additions & 3 deletions PWA/src/Services/BeneficiaryEligilityService.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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");
Expand Down
2 changes: 1 addition & 1 deletion PWA/src/Services/BeneficiaryEligilityService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export class BeneficiaryEligilityService {
this.activeSession = activeSession
}

async isBenificiaryEligibleForCurrentDistribution(beneficiaryCode: string | undefined): Promise<boolean> {
async isBeneficiaryEligibleForCurrentDistribution(beneficiaryCode: string | undefined): Promise<boolean> {
const nameOfActiveDistribution = this.activeSession.nameOfLastViewedDistribution
if(nameOfActiveDistribution) {
const distribution = await this.activeSession.database.distributionWithName(nameOfActiveDistribution)
Expand Down
8 changes: 4 additions & 4 deletions PWA/src/Services/BeneficiaryInfoService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ export class BeneficiaryInfoService {
}

async beneficiaryInfoTextFromDistribution(distribution: Distribution): Promise<string> {
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"
}
Expand Down
Loading

0 comments on commit 03ba2e9

Please sign in to comment.