-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
93 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
PWA/public/Services/FetchEventHandlers/ContinueDistributionHandler.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { RouteEvents } from "../../RouteEvents.js"; | ||
import { ResponseTools } from "../ResponseTools.js"; | ||
export class ContinueDistributionHandler { | ||
canHandleEvent(event) { | ||
return event.request.url.includes(RouteEvents.continueDistribution); | ||
} | ||
async handleEvent(event) { | ||
//TODO this should be context aware | ||
return await ResponseTools.wrapInHtmlTemplate(this.templatepageForInputMethod("text")); | ||
} | ||
templatepageForInputMethod(inputMethod) { | ||
if (inputMethod == "video") { | ||
return RouteEvents.codeInputUsingCamera; | ||
} | ||
else if (inputMethod == "text") { | ||
return RouteEvents.codeinputUsingTextField; | ||
} | ||
else { | ||
throw "Unexpected input method: " + inputMethod; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
PWA/public/Services/FetchEventHandlers/SelectBenificiaryCodeInputMethodHandler copy.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { RouteEvents } from "../../RouteEvents.js"; | ||
import { DeserialisationService } from "../DeserialisationService.js"; | ||
import { ResponseTools } from "../ResponseTools.js"; | ||
export class SelectBenificiaryCodeInputMethodHandler { | ||
canHandleEvent(event) { | ||
return event.request.url.endsWith(RouteEvents.selectBenificiaryCodeInputMethod); | ||
} | ||
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) { | ||
if (inputMethod == "video") { | ||
return RouteEvents.codeInputUsingCamera; | ||
} | ||
else if (inputMethod == "text") { | ||
return RouteEvents.codeinputUsingTextField; | ||
} | ||
else { | ||
throw "Unexpected input method: " + inputMethod; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
PWA/src/Services/FetchEventHandlers/ContinueDistributionHandler.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { FetchEvent } from "../../Interfaces/FetchEvent.js"; | ||
import { FetchEventHandler } from "../../Interfaces/FetchEventHandler.js"; | ||
import { BeneficiaryCodeInputMethodPost } from "../../Models/BeneficiaryCodeInputMethodPost.js"; | ||
import { RouteEvents } from "../../RouteEvents.js"; | ||
import { DeserialisationService } from "../DeserialisationService.js"; | ||
import { ResponseTools } from "../ResponseTools.js"; | ||
|
||
export class ContinueDistributionHandler implements FetchEventHandler { | ||
canHandleEvent(event: FetchEvent): boolean { | ||
return event.request.url.includes(RouteEvents.continueDistribution) | ||
} | ||
|
||
async handleEvent(event: FetchEvent): Promise<Response> { | ||
//TODO this should be context aware | ||
return await ResponseTools.wrapInHtmlTemplate(this.templatepageForInputMethod("text")) | ||
} | ||
|
||
private templatepageForInputMethod(inputMethod: string): string { | ||
if(inputMethod == "video") { | ||
return RouteEvents.codeInputUsingCamera | ||
} else if(inputMethod == "text") { | ||
return RouteEvents.codeinputUsingTextField | ||
} else { | ||
throw "Unexpected input method: " + inputMethod | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters