Skip to content

Commit

Permalink
Revert "Day 3: Set up the project to illustrate error and loading tem…
Browse files Browse the repository at this point in the history
…plates"
  • Loading branch information
ijlee2 committed Aug 14, 2024
1 parent 896e7d6 commit 98796b5
Show file tree
Hide file tree
Showing 9 changed files with 14 additions and 46 deletions.
3 changes: 0 additions & 3 deletions my-app/app/controllers/products/error.css

This file was deleted.

5 changes: 0 additions & 5 deletions my-app/app/controllers/products/error.css.d.ts

This file was deleted.

7 changes: 0 additions & 7 deletions my-app/app/controllers/products/error.ts

This file was deleted.

3 changes: 0 additions & 3 deletions my-app/app/controllers/products/loading.css

This file was deleted.

5 changes: 0 additions & 5 deletions my-app/app/controllers/products/loading.css.d.ts

This file was deleted.

7 changes: 0 additions & 7 deletions my-app/app/controllers/products/loading.ts

This file was deleted.

24 changes: 11 additions & 13 deletions my-app/app/routes/products/product.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import { type Registry as Services, service } from '@ember/service';

import type { ModelFrom } from '../../utils/routes';
import type { Product } from '../../utils/routes/products';
import type ProductsRoute from '../products';

export default class ProductsProductRoute extends Route {
@service declare api: Services['api'];
@service declare experiments: Services['experiments'];
@service declare router: Services['router'];

Expand All @@ -23,23 +23,21 @@ export default class ProductsProductRoute extends Route {
}
}

model(params: { id: string }): Promise<Product> {
model(params: { id: string }): Product {
const { id } = params;
const products = this.modelFor('products') as ModelFrom<ProductsRoute>;

/*
Uncomment the next line to render products/error.hbs.
*/
// throw new Error('Some server error.');
const product = products.find((product) => product.id === id);

return this.api.get<Product>(`/products/${id}`);
}

@action error(error: any /*, transition */) {
console.error(error);
if (!product) {
throw new Error(`Could not find the product with ID ${id}.`);
}

return true;
return product;
}

// this.router.replaceWith('products');
@action error(/* error, transition */) {
this.router.replaceWith('products');
}
}

Expand Down
4 changes: 2 additions & 2 deletions my-app/app/utils/services/experiments.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const experimentsForProduction = {
'nest-product-details': {
control: 0,
v1: 1,
control: 0.5,
v1: 0.5,
},
'subscribe-to-ember-times': {
control: 0.7,
Expand Down
2 changes: 1 addition & 1 deletion my-app/mirage/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ function routes() {
Uncomment the next line to make the loading spinner
visible for some time.
*/
this.timing = 1000;
// this.timing = 1000;

/*
Shorthand cheatsheet:
Expand Down

0 comments on commit 98796b5

Please sign in to comment.