Skip to content

Commit

Permalink
Allow a default group to be set
Browse files Browse the repository at this point in the history
  • Loading branch information
Mongey committed Nov 11, 2022
1 parent c402ebd commit 88a3df6
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
3 changes: 2 additions & 1 deletion app/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ export default class Router extends EmberRouter {
}

Router.map(function () {
this.route('worldcup', { path: ':id' });
this.route('worldcup', { path: '/' });
this.route('worldcup', { path: '/:id' });
});
7 changes: 6 additions & 1 deletion app/routes/worldcup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,20 @@ import { inject as service } from '@ember/service';
import Api from 'worldcup/services/api';
import { taskFor } from 'ember-concurrency-ts';
import Sweepstakes, { Player } from 'worldcup/services/sweepstakes';
import ENV from 'worldcup/config/environment';

export default class WorldCup extends Route {
@service declare api: Api;
@service declare sweepstakes: Sweepstakes;

async model(params: { id: string }) {
var players: Player[];
var id = params.id;
if (id === undefined) {
id = ENV.APP.default_group as string;
}
try {
let response = await fetch(`/players/${params.id}.json`);
let response = await fetch(`/players/${id}.json`);
let loadedData = await response.json();
players = loadedData.players;
} catch {
Expand Down
1 change: 1 addition & 0 deletions config/environment.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ module.exports = function (environment) {
APP: {
// Here you can pass flags/options to your application instance
// when it is created
default_group: process.env.DEFAULT_GROUP,
},
};

Expand Down

0 comments on commit 88a3df6

Please sign in to comment.