Skip to content

Commit

Permalink
Make sure distribution deletion page has an empty state bump 7.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
rcmenno committed Oct 21, 2024
1 parent 42a22cc commit 8fa83fa
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 12 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.6.2",
"version": "0.7.0",
"description": "A tool for managing the distribution of relief items during humanitarian emergencies.",
"main": "index.js",
"scripts": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,15 @@ export class DeleteDistributionRequestHandler extends ActiveSessionContainer {
async handleEvent(event) {
try {
const distributions = await this.activeSession.database.readDistributions();
return ResponseTools.wrapInHTPLTemplateAndReplaceKeysWithValues(RouteEvents.deleteDistribution, {
columns: Distribution.colums,
rows: distributions
});
if (distributions.length > 0) {
return ResponseTools.wrapInHTPLTemplateAndReplaceKeysWithValues(RouteEvents.deleteDistribution, {
columns: Distribution.colums,
rows: distributions
});
}
else {
return ResponseTools.wrapInHtmlTemplate(RouteEvents.listDistributionsEmptyState);
}
}
catch (error) {
console.error(error);
Expand Down
2 changes: 1 addition & 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.6.2</div>
<div class="navbar-item">Alpha 0.7.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 Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,18 @@ export class DeleteDistributionRequestHandler extends ActiveSessionContainer imp

async handleEvent(event: FetchEvent): Promise<Response> {
try {
const distributions: Distribution[] = await this.activeSession.database.readDistributions()
return ResponseTools.wrapInHTPLTemplateAndReplaceKeysWithValues(
RouteEvents.deleteDistribution, {
columns: Distribution.colums,
rows: distributions
})
const distributions: Distribution[] = await this.activeSession.database.readDistributions()
if(distributions.length > 0) {
return ResponseTools.wrapInHTPLTemplateAndReplaceKeysWithValues(
RouteEvents.deleteDistribution, {
columns: Distribution.colums,
rows: distributions
})
} else {
return ResponseTools.wrapInHtmlTemplate(
RouteEvents.listDistributionsEmptyState
)
}
} catch (error) {
console.error(error)
}
Expand Down

0 comments on commit 8fa83fa

Please sign in to comment.