Blacked and isorted the python files
Prettied and eslinted the typescript/html files
This commit is contained in:
@ -1,18 +1,17 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { ActivatedRouteSnapshot, Resolve, Router, RouterStateSnapshot } from '@angular/router';
|
||||
import { ActivatedRouteSnapshot, Resolve, Router } from '@angular/router';
|
||||
import { Observable } from 'rxjs';
|
||||
|
||||
import { Product } from '../../core/product';
|
||||
import { ProductService } from '../../product/product.service';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class ProductsResolver implements Resolve<Product[]> {
|
||||
constructor(private ser: ProductService, private router: Router) {}
|
||||
|
||||
constructor(private ser: ProductService, private router: Router) {
|
||||
}
|
||||
|
||||
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<Product[]> {
|
||||
resolve(route: ActivatedRouteSnapshot): Observable<Product[]> {
|
||||
const id = route.paramMap.get('id');
|
||||
return this.ser.listIsActiveOfCategory(id);
|
||||
}
|
||||
|
||||
@ -1,12 +1,24 @@
|
||||
<mat-card>
|
||||
<mat-card-content fxLayout="row wrap" fxLayoutGap="grid 20px">
|
||||
<mat-card fxLayout="column" class="square-button" matRipple *ngFor="let item of list" (click)="addProduct(item)"
|
||||
[class.yellow300]="item.hasHappyHour" [class.grey800]="item.isNotAvailable">
|
||||
<h3 class="item-name">{{item.name}}</h3>
|
||||
<mat-card-subtitle class="center">{{item.price | currency:'INR'}}</mat-card-subtitle>
|
||||
<mat-card
|
||||
fxLayout="column"
|
||||
class="square-button"
|
||||
matRipple
|
||||
*ngFor="let item of list"
|
||||
(click)="addProduct(item)"
|
||||
[class.yellow300]="item.hasHappyHour"
|
||||
[class.grey800]="item.isNotAvailable"
|
||||
>
|
||||
<h3 class="item-name">{{ item.name }}</h3>
|
||||
<mat-card-subtitle class="center">{{ item.price | currency: 'INR' }}</mat-card-subtitle>
|
||||
</mat-card>
|
||||
<mat-card fxLayout="column" class="square-button red700" matRipple [routerLink]="['../../menu-categories']"
|
||||
queryParamsHandling="preserve">
|
||||
<mat-card
|
||||
fxLayout="column"
|
||||
class="square-button red700"
|
||||
matRipple
|
||||
[routerLink]="['../../menu-categories']"
|
||||
queryParamsHandling="preserve"
|
||||
>
|
||||
<h3 class="item-name">Back</h3>
|
||||
</mat-card>
|
||||
</mat-card-content>
|
||||
|
||||
@ -8,9 +8,8 @@ describe('ProductsComponent', () => {
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ ProductsComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
declarations: [ProductsComponent],
|
||||
}).compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
|
||||
@ -1,28 +1,26 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { ActivatedRoute } from '@angular/router';
|
||||
|
||||
import { Product } from '../../core/product';
|
||||
import { BillService } from '../bill.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-products',
|
||||
templateUrl: './products.component.html',
|
||||
styleUrls: ['./products.component.css']
|
||||
styleUrls: ['./products.component.css'],
|
||||
})
|
||||
export class ProductsComponent implements OnInit {
|
||||
list: Product[];
|
||||
|
||||
constructor(private route: ActivatedRoute, private bs: BillService) {
|
||||
}
|
||||
constructor(private route: ActivatedRoute, private bs: BillService) {}
|
||||
|
||||
ngOnInit() {
|
||||
this.route.data
|
||||
.subscribe((data: { list: Product[] }) => {
|
||||
this.list = data.list;
|
||||
});
|
||||
this.route.data.subscribe((data: { list: Product[] }) => {
|
||||
this.list = data.list;
|
||||
});
|
||||
}
|
||||
|
||||
addProduct(product: Product): void {
|
||||
this.bs.addProduct(product);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user