Skip to content

Commit 5f6ab34

Browse files
committed
feat: add manage products page placeholder
1 parent 2d92d48 commit 5f6ab34

File tree

7 files changed

+93
-3
lines changed

7 files changed

+93
-3
lines changed

src/app/admin/admin-routing.module.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
11
import { NgModule } from '@angular/core';
22
import { RouterModule, Routes } from '@angular/router';
33
import { OrdersComponent } from './orders/orders.component';
4+
import { ManageProductsComponent } from './manage-products/manage-products.component';
45

56
const routes: Routes = [
67
{
78
path: 'orders',
89
component: OrdersComponent,
910
},
11+
{
12+
path: 'products',
13+
component: ManageProductsComponent,
14+
},
1015
];
1116

1217
@NgModule({

src/app/admin/admin.module.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@ import { AdminRoutingModule } from './admin-routing.module';
55
import { OrdersComponent } from './orders/orders.component';
66
import { MatTableModule } from '@angular/material/table';
77
import { OrdersService } from './orders/orders.service';
8+
import { ManageProductsComponent } from './manage-products/manage-products.component';
9+
import { MatButtonModule } from '@angular/material/button';
810

911
@NgModule({
10-
declarations: [OrdersComponent],
11-
imports: [CommonModule, AdminRoutingModule, MatTableModule],
12+
declarations: [OrdersComponent, ManageProductsComponent],
13+
imports: [CommonModule, AdminRoutingModule, MatTableModule, MatButtonModule],
1214
providers: [OrdersService],
1315
})
1416
export class AdminModule {}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<h1>Manage products</h1>
2+
3+
<table class="w-100" [dataSource]="products$" mat-table>
4+
<ng-container matColumnDef="from">
5+
<th mat-header-cell *matHeaderCellDef>Title</th>
6+
<td mat-cell *matCellDef="let product">
7+
{{ product.title }}
8+
</td>
9+
</ng-container>
10+
<ng-container matColumnDef="description">
11+
<th mat-header-cell *matHeaderCellDef>Description</th>
12+
<td mat-cell *matCellDef="let product">{{ product.description }}</td>
13+
</ng-container>
14+
<ng-container matColumnDef="price">
15+
<th mat-header-cell *matHeaderCellDef>Price</th>
16+
<td mat-cell *matCellDef="let product">
17+
{{ product.price | number: "1.2-2" | currency }}
18+
</td>
19+
</ng-container>
20+
<ng-container matColumnDef="count">
21+
<th mat-header-cell *matHeaderCellDef>Count</th>
22+
<td mat-cell *matCellDef="let product">{{ product.count }}</td>
23+
</ng-container>
24+
<ng-container matColumnDef="action">
25+
<th mat-header-cell *matHeaderCellDef>Action</th>
26+
<td mat-cell *matCellDef="let product">
27+
<button class="text-uppercase mr-2" color="primary" mat-flat-button>
28+
manage
29+
</button>
30+
<button class="text-uppercase" color="warn" mat-flat-button>
31+
delete
32+
</button>
33+
</td>
34+
</ng-container>
35+
36+
<tr mat-header-row *matHeaderRowDef="columns"></tr>
37+
<tr mat-row *matRowDef="let row; columns: columns"></tr>
38+
</table>

src/app/admin/manage-products/manage-products.component.scss

Whitespace-only changes.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { ComponentFixture, TestBed } from '@angular/core/testing';
2+
3+
import { ManageProductsComponent } from './manage-products.component';
4+
5+
describe('ProductsComponent', () => {
6+
let component: ManageProductsComponent;
7+
let fixture: ComponentFixture<ManageProductsComponent>;
8+
9+
beforeEach(async () => {
10+
await TestBed.configureTestingModule({
11+
declarations: [ManageProductsComponent],
12+
}).compileComponents();
13+
});
14+
15+
beforeEach(() => {
16+
fixture = TestBed.createComponent(ManageProductsComponent);
17+
component = fixture.componentInstance;
18+
fixture.detectChanges();
19+
});
20+
21+
it('should create', () => {
22+
expect(component).toBeTruthy();
23+
});
24+
});
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { Component, OnInit } from '@angular/core';
2+
import { Observable } from 'rxjs';
3+
import { Product } from '../../products/product.interface';
4+
import { ProductsService } from '../../products/products.service';
5+
6+
@Component({
7+
selector: 'app-manage-products',
8+
templateUrl: './manage-products.component.html',
9+
styleUrls: ['./manage-products.component.scss'],
10+
})
11+
export class ManageProductsComponent implements OnInit {
12+
readonly columns = ['from', 'description', 'price', 'count', 'action'];
13+
14+
products$!: Observable<Product[]>;
15+
16+
constructor(private readonly productsService: ProductsService) {}
17+
18+
ngOnInit(): void {
19+
this.products$ = this.productsService.getProducts();
20+
}
21+
}

src/app/core/header/header.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,5 @@
2222

2323
<mat-menu #menu="matMenu">
2424
<a routerLink="admin/orders" mat-menu-item>Manage orders</a>
25-
<a routerLink="/" mat-menu-item>Manage products</a>
25+
<a routerLink="admin/products" mat-menu-item>Manage products</a>
2626
</mat-menu>

0 commit comments

Comments
 (0)