Skip to content

Commit

Permalink
Make sure distributions routes to the distributions page bump
Browse files Browse the repository at this point in the history
  • Loading branch information
rcmenno committed Oct 25, 2024
1 parent 5cc2ab7 commit 8106291
Show file tree
Hide file tree
Showing 12 changed files with 47 additions and 8 deletions.
2 changes: 1 addition & 1 deletion PWA/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ReliefBox",
"version": "0.9.0",
"version": "0.10.0",
"description": "A tool for managing the distribution of relief items during humanitarian emergencies.",
"main": "index.js",
"scripts": {
Expand Down
1 change: 1 addition & 0 deletions PWA/public/RouteEvents.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,4 @@ RouteEvents.received = "/received";
RouteEvents.continueDistribution = "/continueDistribution";
RouteEvents.downloadData = "/download_data";
RouteEvents.downloadSpreadsheetTemplate = "/download_template";
RouteEvents.distributions = "/distributions";
4 changes: 3 additions & 1 deletion PWA/public/Services/CacheFilePathService.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import { BeneficiaryStatusService } from "./BeneficiaryStatusService.js";
import { DownloadSpreadsheetTemplateHandler } from "./FetchEventHandlers/DownloadSpreadsheetTemplateHandler.js";
import { DeleteDistributionsConfirmHandler } from "./FetchEventHandlers/DeleteDistributionsConfirmHandler.js";
import { DistributionResponseProvider } from "./DistributionResponseProvider.js";
import { DistributionsHandler } from "./FetchEventHandlers/DistributionsHandler.js";
// Provides all the files that have to be cached for offline use
export class CacheFilePathService {
pathsOfFilesToCache() {
Expand Down Expand Up @@ -139,7 +140,8 @@ export class CacheFilePathService {
ContinueDistributionHandler.name,
DownloadDataHandler.name,
DownloadSpreadsheetTemplateHandler.name,
DeleteDistributionsConfirmHandler.name
DeleteDistributionsConfirmHandler.name,
DistributionsHandler.name
]);
}
interfacesPaths() {
Expand Down
10 changes: 10 additions & 0 deletions PWA/public/Services/FetchEventHandlers/DistributionsHandler.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { RouteEvents } from "../../RouteEvents.js";
import { ResponseTools } from "../ResponseTools.js";
export class DistributionsHandler {
canHandleEvent(event) {
return event.request.url.endsWith(RouteEvents.distributions);
}
async handleEvent(event) {
return await ResponseTools.fetchFromCacheWithRemoteAsFallBack(RouteEvents.home);
}
}
4 changes: 3 additions & 1 deletion PWA/public/Services/FetchEventHandlers/FetchEventHandlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { ContinueDistributionHandler } from "./ContinueDistributionHandler.js";
import { DownloadDataHandler } from "./DownloadDataHandler.js";
import { DownloadSpreadsheetTemplateHandler } from "./DownloadSpreadsheetTemplateHandler.js";
import { DeleteDistributionsConfirmHandler } from "./DeleteDistributionsConfirmHandler.js";
import { DistributionsHandler } from "./DistributionsHandler.js";
export class FetchEventHandlers extends ActiveSessionContainer {
constructor() {
super(...arguments);
Expand All @@ -40,7 +41,8 @@ export class FetchEventHandlers extends ActiveSessionContainer {
new ContinueDistributionHandler(this.activeSession),
new DownloadDataHandler(this.activeSession),
new DownloadSpreadsheetTemplateHandler(),
new DeleteDistributionsConfirmHandler()
new DeleteDistributionsConfirmHandler(),
new DistributionsHandler()
];
}
handlersForEvent(event) {
Expand Down
5 changes: 4 additions & 1 deletion PWA/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
<!-- <a class="navbar-item">-->
<img src="images/ReliefBox-horizontal-nobackground.png" width="220" height="30">
<!-- </a>-->
<div class="navbar-item">Alpha 0.9.0</div>
<div class="navbar-item">Alpha 0.10.0</div>
<a role="button" class="navbar-burger" aria-label="menu" aria-expanded="false" data-target="navbarBasicExample">
<span aria-hidden="true"></span>
<span aria-hidden="true"></span>
Expand All @@ -52,6 +52,9 @@
<a href="/index.html" class="navbar-item">
Home
</a>
<a href="/distributions" class="navbar-item">
Distributions
</a>
<a href="https://reliefbox.readthedocs.io/" class="navbar-item" target="_blank" rel="noopener noreferrer">
Documentation
</a>
Expand Down
4 changes: 3 additions & 1 deletion PWA/public/template.html
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@
<a href="/index.html" class="navbar-item">
Home
</a>

<a href="/distributions" class="navbar-item">
Distributions
</a>
<a href="https://reliefbox.readthedocs.io/" class="navbar-item" target="_blank" rel="noopener noreferrer">
Documentation
</a>
Expand Down
1 change: 1 addition & 0 deletions PWA/src/RouteEvents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,5 @@ export class RouteEvents {
static continueDistribution = "/continueDistribution"
static downloadData = "/download_data"
static downloadSpreadsheetTemplate = "/download_template"
static distributions = "/distributions"
}
4 changes: 3 additions & 1 deletion PWA/src/Services/CacheFilePathService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import { BeneficiaryStatusService } from "./BeneficiaryStatusService.js";
import { DownloadSpreadsheetTemplateHandler } from "./FetchEventHandlers/DownloadSpreadsheetTemplateHandler.js";
import { DeleteDistributionsConfirmHandler } from "./FetchEventHandlers/DeleteDistributionsConfirmHandler.js";
import { DistributionResponseProvider } from "./DistributionResponseProvider.js";
import { DistributionsHandler } from "./FetchEventHandlers/DistributionsHandler.js";

// Provides all the files that have to be cached for offline use
export class CacheFilePathService {
Expand Down Expand Up @@ -152,7 +153,8 @@ export class CacheFilePathService {
ContinueDistributionHandler.name,
DownloadDataHandler.name,
DownloadSpreadsheetTemplateHandler.name,
DeleteDistributionsConfirmHandler.name
DeleteDistributionsConfirmHandler.name,
DistributionsHandler.name
]);
}

Expand Down
14 changes: 14 additions & 0 deletions PWA/src/Services/FetchEventHandlers/DistributionsHandler.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { FetchEvent } from "../../Interfaces/FetchEvent.js";
import { FetchEventHandler } from "../../Interfaces/FetchEventHandler.js";
import { RouteEvents } from "../../RouteEvents.js";
import { ResponseTools } from "../ResponseTools.js";

export class DistributionsHandler implements FetchEventHandler {
canHandleEvent(event: FetchEvent): boolean {
return event.request.url.endsWith(RouteEvents.distributions);
}

async handleEvent(event: FetchEvent): Promise<Response | undefined> {
return await ResponseTools.fetchFromCacheWithRemoteAsFallBack(RouteEvents.home);
}
}
4 changes: 3 additions & 1 deletion PWA/src/Services/FetchEventHandlers/FetchEventHandlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { ContinueDistributionHandler } from "./ContinueDistributionHandler.js";
import { DownloadDataHandler } from "./DownloadDataHandler.js";
import { DownloadSpreadsheetTemplateHandler } from "./DownloadSpreadsheetTemplateHandler.js";
import { DeleteDistributionsConfirmHandler } from "./DeleteDistributionsConfirmHandler.js";
import { DistributionsHandler } from "./DistributionsHandler.js";

export class FetchEventHandlers extends ActiveSessionContainer implements FetchEventHandler {
all: FetchEventHandler[] = [
Expand All @@ -41,7 +42,8 @@ export class FetchEventHandlers extends ActiveSessionContainer implements FetchE
new ContinueDistributionHandler(this.activeSession),
new DownloadDataHandler(this.activeSession),
new DownloadSpreadsheetTemplateHandler(),
new DeleteDistributionsConfirmHandler()
new DeleteDistributionsConfirmHandler(),
new DistributionsHandler()
];

handlersForEvent(event: FetchEvent): FetchEventHandler[] {
Expand Down
2 changes: 1 addition & 1 deletion PWA/src/Services/FetchEventHandlers/HomepageHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ export class HomepageHandler extends ActiveSessionContainer implements FetchEven
return await ResponseTools.fetchFromCacheWithRemoteAsFallBack(RouteEvents.home)
}
}
}
}

0 comments on commit 8106291

Please sign in to comment.