Skip to content

Commit e6007cd

Browse files
committed
feat: placeholder for manage orders page
1 parent c2a2235 commit e6007cd

12 files changed

+169
-1
lines changed

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { NgModule } from '@angular/core';
2+
import { RouterModule, Routes } from '@angular/router';
3+
import { OrdersComponent } from './orders/orders.component';
4+
5+
const routes: Routes = [
6+
{
7+
path: 'orders',
8+
component: OrdersComponent,
9+
},
10+
];
11+
12+
@NgModule({
13+
imports: [RouterModule.forChild(routes)],
14+
exports: [RouterModule],
15+
})
16+
export class AdminRoutingModule {}

src/app/admin/admin.module.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { NgModule } from '@angular/core';
2+
import { CommonModule } from '@angular/common';
3+
4+
import { AdminRoutingModule } from './admin-routing.module';
5+
import { OrdersComponent } from './orders/orders.component';
6+
import { MatTableModule } from '@angular/material/table';
7+
import { OrdersService } from './orders/orders.service';
8+
9+
@NgModule({
10+
declarations: [OrdersComponent],
11+
imports: [CommonModule, AdminRoutingModule, MatTableModule],
12+
providers: [OrdersService],
13+
})
14+
export class AdminModule {}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { ShippingInfo } from '../../cart/shipping-info.interface';
2+
3+
export enum OrderStatus {
4+
open = 'open',
5+
approved = 'approved',
6+
confirmed = 'confirmed',
7+
sent = 'sent',
8+
completed = 'completed',
9+
cancelled = 'cancelled',
10+
}
11+
12+
export interface StatusHistory {
13+
status: OrderStatus;
14+
timestamp: string;
15+
comment: string;
16+
}
17+
18+
export interface Order {
19+
id?: string;
20+
address: ShippingInfo;
21+
items: unknown[]; // TODO: find exact
22+
statusHistory: StatusHistory[];
23+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<div class="container py-3 py-md-5">
2+
<h1>Manage orders</h1>
3+
4+
<table class="w-100" [dataSource]="orders$" mat-table>
5+
<ng-container matColumnDef="from">
6+
<th mat-header-cell *matHeaderCellDef>From</th>
7+
<td mat-cell *matCellDef="let order">
8+
{{ order.address.firstName }} {{ order.address.firstName }}
9+
</td>
10+
</ng-container>
11+
<ng-container matColumnDef="count">
12+
<th mat-header-cell *matHeaderCellDef>Count</th>
13+
<td mat-cell *matCellDef="let order">{{ order.items.length }}</td>
14+
</ng-container>
15+
<ng-container matColumnDef="address">
16+
<th mat-header-cell *matHeaderCellDef>Address</th>
17+
<td mat-cell *matCellDef="let order">{{ order.address.address }}</td>
18+
</ng-container>
19+
<ng-container matColumnDef="status">
20+
<th mat-header-cell *matHeaderCellDef>Status</th>
21+
<td mat-cell *matCellDef="let order">{{ order.items.length }}</td>
22+
</ng-container>
23+
<ng-container matColumnDef="action">
24+
<th mat-header-cell *matHeaderCellDef>Action</th>
25+
<td mat-cell *matCellDef="let order">{{ order.items.length }}</td>
26+
</ng-container>
27+
28+
<tr mat-header-row *matHeaderRowDef="columns"></tr>
29+
<tr mat-row *matRowDef="let row; columns: columns"></tr>
30+
</table>
31+
</div>

src/app/admin/orders/orders.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 { OrdersComponent } from './orders.component';
4+
5+
describe('ManageOrdersComponent', () => {
6+
let component: OrdersComponent;
7+
let fixture: ComponentFixture<OrdersComponent>;
8+
9+
beforeEach(async () => {
10+
await TestBed.configureTestingModule({
11+
declarations: [OrdersComponent],
12+
}).compileComponents();
13+
});
14+
15+
beforeEach(() => {
16+
fixture = TestBed.createComponent(OrdersComponent);
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 { OrdersService } from './orders.service';
3+
import { Observable } from 'rxjs';
4+
import { Order } from './order.interface';
5+
6+
@Component({
7+
selector: 'app-orders',
8+
templateUrl: './orders.component.html',
9+
styleUrls: ['./orders.component.scss'],
10+
})
11+
export class OrdersComponent implements OnInit {
12+
readonly columns = ['from', 'count', 'address', 'status', 'action'];
13+
14+
orders$!: Observable<Order[]>;
15+
16+
constructor(private readonly ordersService: OrdersService) {}
17+
18+
ngOnInit(): void {
19+
this.orders$ = this.ordersService.getOrders();
20+
}
21+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { TestBed } from '@angular/core/testing';
2+
3+
import { OrdersService } from './orders.service';
4+
5+
describe('OrdersService', () => {
6+
let service: OrdersService;
7+
8+
beforeEach(() => {
9+
TestBed.configureTestingModule({});
10+
service = TestBed.inject(OrdersService);
11+
});
12+
13+
it('should be created', () => {
14+
expect(service).toBeTruthy();
15+
});
16+
});
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { Injectable } from '@angular/core';
2+
import { Observable, of } from 'rxjs';
3+
import { Order } from './order.interface';
4+
5+
@Injectable()
6+
export class OrdersService {
7+
constructor() {}
8+
9+
getOrders(): Observable<Order[]> {
10+
return of([]);
11+
}
12+
}

src/app/app-routing.module.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ const routes: Routes = [
1111
path: 'cart',
1212
loadChildren: () => import('./cart/cart.module').then((m) => m.CartModule),
1313
},
14+
{
15+
path: 'admin',
16+
loadChildren: () =>
17+
import('./admin/admin.module').then((m) => m.AdminModule),
18+
},
1419
];
1520

1621
@NgModule({

0 commit comments

Comments
 (0)