-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add start time and station in order
- Loading branch information
Showing
12 changed files
with
194 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
import { Order } from '@/app/api/models/order'; | ||
|
||
export const ordersDummyData: Order[] = [ | ||
{ | ||
id: 64, | ||
rideId: 45, | ||
routeId: 18, | ||
seatId: 33, | ||
userId: 3, | ||
status: 'active', | ||
path: [33, 5, 62, 11, 48, 34], | ||
carriages: [ | ||
'carriage_type_2', | ||
'carriage_type_2', | ||
'carriage_type_2', | ||
'carriage_type_2', | ||
'carriage_type_7', | ||
'carriage_type_7', | ||
'carriage_type_7', | ||
'carriage_type_7', | ||
], | ||
schedule: { | ||
segments: [ | ||
{ | ||
time: ['2021-08-10T08:00:00', '2021-08-10T08:30:00'], | ||
price: { | ||
adult: 1000, | ||
child: 500, | ||
student: 700, | ||
}, | ||
occupiedSeats: [32], | ||
}, | ||
{ | ||
time: ['2021-08-10T08:30:00', '2021-08-10T09:00:00'], | ||
price: { | ||
adult: 1000, | ||
child: 500, | ||
student: 700, | ||
}, | ||
occupiedSeats: [32], | ||
}, | ||
], | ||
}, | ||
}, | ||
{ | ||
id: 65, | ||
rideId: 46, | ||
routeId: 19, | ||
seatId: 34, | ||
userId: 3, | ||
status: 'active', | ||
path: [33, 5, 62, 11, 48, 34], | ||
carriages: [ | ||
'carriage_type_2', | ||
'carriage_type_2', | ||
'carriage_type_2', | ||
'carriage_type_2', | ||
'carriage_type_7', | ||
'carriage_type_7', | ||
'carriage_type_7', | ||
'carriage_type_7', | ||
], | ||
schedule: { | ||
segments: [ | ||
{ | ||
time: ['2021-08-11T08:00:00', '2021-08-11T08:30:00'], | ||
price: { | ||
adult: 1000, | ||
child: 500, | ||
student: 700, | ||
}, | ||
occupiedSeats: [33], | ||
}, | ||
{ | ||
time: ['2021-08-11T08:30:00', '2021-08-11T09:00:00'], | ||
price: { | ||
adult: 1000, | ||
child: 500, | ||
student: 700, | ||
}, | ||
occupiedSeats: [33], | ||
}, | ||
], | ||
}, | ||
}, | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<hr /> | ||
<div class="wrapper"> | ||
<p>Order ID: {{ order.id }}</p> | ||
<p> | ||
Start Time: <b>{{ order.schedule.segments[0].time[0] | date: 'MMMM dd HH:mm' }}</b> | ||
</p> | ||
<p> | ||
Start Station: | ||
@if (stationsService.findStationById(order.path[0]); as startStation) { | ||
<b>{{ startStation.city }}</b> | ||
} | ||
</p> | ||
</div> |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { DatePipe } from '@angular/common'; | ||
import { ChangeDetectionStrategy, Component, inject, Input, OnDestroy } from '@angular/core'; | ||
|
||
import { ButtonModule } from 'primeng/button'; | ||
import { RippleModule } from 'primeng/ripple'; | ||
import { Subscription } from 'rxjs'; | ||
|
||
import { Order } from '@/app/api/models/order'; | ||
import { StationsService } from '@/app/api/stationsService/stations.service'; | ||
|
||
@Component({ | ||
selector: 'app-order', | ||
standalone: true, | ||
imports: [ButtonModule, RippleModule, DatePipe], | ||
templateUrl: './order.component.html', | ||
styleUrl: './order.component.scss', | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
}) | ||
export class OrderComponent implements OnDestroy { | ||
@Input() public order!: Order; | ||
public stationsService = inject(StationsService); | ||
private subsciption = new Subscription(); | ||
|
||
public ngOnDestroy(): void { | ||
this.subsciption.unsubscribe(); | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
src/app/orders/components/orders-list/orders-list.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<div> | ||
orders-list works! | ||
<div> | ||
@for (order of orders; track order.id) { | ||
<app-order [order]="order"></app-order> | ||
} | ||
</div> | ||
</div> |
Empty file.
17 changes: 17 additions & 0 deletions
17
src/app/orders/components/orders-list/orders-list.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { ChangeDetectionStrategy, Component, Input } from '@angular/core'; | ||
|
||
import { Order } from '@/app/api/models/order'; | ||
|
||
import { OrderComponent } from '../order/order.component'; | ||
|
||
@Component({ | ||
selector: 'app-orders-list', | ||
standalone: true, | ||
imports: [OrderComponent], | ||
templateUrl: './orders-list.component.html', | ||
styleUrl: './orders-list.component.scss', | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
}) | ||
export class OrdersListComponent { | ||
@Input() public orders!: Order[]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,8 @@ | ||
<p>orders works!</p> | ||
|
||
<div class="wrapper"> | ||
@let orders = ordersService.allOrders(); | ||
@if (orders.length) { | ||
<app-orders-list [orders]="orders"></app-orders-list> | ||
} | ||
</div> |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,33 @@ | ||
import { ChangeDetectionStrategy, Component } from '@angular/core'; | ||
import { CommonModule, DatePipe } from '@angular/common'; | ||
import { ChangeDetectionStrategy, Component, inject, OnDestroy, OnInit } from '@angular/core'; | ||
|
||
import { Subscription } from 'rxjs'; | ||
|
||
import { OrdersService } from '@/app/api/ordersService/orders.service'; | ||
import { StationsService } from '@/app/api/stationsService/stations.service'; | ||
|
||
import { OrdersListComponent } from '../../components/orders-list/orders-list.component'; | ||
|
||
@Component({ | ||
selector: 'app-orders', | ||
standalone: true, | ||
imports: [], | ||
imports: [CommonModule, OrdersListComponent], | ||
templateUrl: './orders.component.html', | ||
styleUrl: './orders.component.scss', | ||
providers: [DatePipe], | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
}) | ||
export class OrdersComponent {} | ||
export class OrdersComponent implements OnInit, OnDestroy { | ||
public ordersService = inject(OrdersService); | ||
public stationsService = inject(StationsService); | ||
private subsciption = new Subscription(); | ||
|
||
public ngOnInit(): void { | ||
this.subsciption.add(this.ordersService.getOrders().subscribe()); | ||
this.subsciption.add(this.stationsService.getStations().subscribe()); | ||
} | ||
|
||
public ngOnDestroy(): void { | ||
this.subsciption.unsubscribe(); | ||
} | ||
} |