Skip to content

Commit

Permalink
Merge pull request #190 from Kleostro/fix/tu-02-62/carriage-styles
Browse files Browse the repository at this point in the history
fix(tu-02-62): carriage styles
  • Loading branch information
Kleostro authored Sep 3, 2024
2 parents 08e7e41 + b807b80 commit 0d74478
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 24 deletions.
8 changes: 4 additions & 4 deletions src/app/admin/components/carriage/carriage.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
}
</div>

<div class="car-bottom" [class]="!isInteractive() ? 'disabled' : ''">
<div class="car-bottom">
<div class="seats">
@if (seatsSchema(); as seatsSchema) {
<div class="right-seats">
<div class="right-seats" [class]="!isInteractive() ? 'disabled' : ''">
<div class="left-line"></div>
@for (rightRow of seatsSchema.rightSeats; let i = $index; track i) {
<div class="right-seats-row">
Expand All @@ -44,11 +44,11 @@
}
<div class="right-line"></div>
</div>
<div class="left-seats">
<div class="left-seats" [class]="!isInteractive() ? 'disabled' : ''">
<div class="left-line"></div>
@for (leftRow of seatsSchema.leftSeats; let i = $index; track i) {
<div class="left-seats-row">
@for (leftSeat of leftRow; track leftSeat) {
@for (leftSeat of leftRow; let index = $index; track index) {
@let seatNumber = firstSeat() + leftSeat;
<app-seat
[classes]="['left', i === 0 ? 'first-seat' : '', isInteractive() ? 'interactive' : '']"
Expand Down
6 changes: 3 additions & 3 deletions src/app/admin/components/carriage/carriage.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

max-width: 90dvw;
min-height: 14rem;
padding: 0 2rem 1rem;
padding: 0.5rem 2rem;

border: $three solid $gray-200;
border-radius: 2rem;
Expand All @@ -29,11 +29,11 @@
display: flex;
flex-direction: column;
gap: 3rem;
justify-content: center;
justify-content: space-around;

width: 100%;
max-height: 20rem;
padding-top: 1rem;
padding: 1rem 0;
}

.title {
Expand Down
15 changes: 10 additions & 5 deletions src/app/admin/pages/route-detailed/route-detailed.component.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ChangeDetectionStrategy, Component, inject, input, OnDestroy, OnInit, signal } from '@angular/core';
import { RouterLink } from '@angular/router';
import { Router, RouterLink } from '@angular/router';

import { ButtonModule } from 'primeng/button';
import { ProgressSpinnerModule } from 'primeng/progressspinner';
Expand All @@ -23,6 +23,7 @@ import { RidesListComponent } from '../../components/rides-list/rides-list.compo
export class RouteDetailedComponent implements OnInit, OnDestroy {
public routeService = inject(RideService);
public stationsService = inject(StationsService);
private router = inject(Router);
public id = input<string>('');
public isOpenCreateRideForm = signal(false);
public isDataLoaded = signal(false);
Expand All @@ -32,10 +33,14 @@ export class RouteDetailedComponent implements OnInit, OnDestroy {
this.routeService.currentRouteInfo.set(null);
this.subscribtion.add(
this.stationsService.getStations().subscribe(() => {
this.routeService.getRouteById(+this.id()).subscribe(
// TBD: redirect to 404 if there is no route
() => this.isDataLoaded.set(true),
);
this.routeService.getRouteById(+this.id()).subscribe({
next: () => {
this.isDataLoaded.set(true);
},
error: () => {
this.router.navigate(['404']);
},
});
}),
);
}
Expand Down
2 changes: 2 additions & 0 deletions src/app/auth/services/auth-service/auth.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ export class AuthService {
this.isLoggedIn$$.set(true);
if (userData.email === ADMIN_CREDENTIALS.email) {
this.isAdmin$$.set(true);
} else {
this.isAdmin$$.set(false);
}
}

Expand Down
19 changes: 12 additions & 7 deletions src/app/orders/components/orders-list/orders-list.component.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { NgTemplateOutlet } from '@angular/common';
import { ChangeDetectionStrategy, Component, inject, Input, OnInit, signal } from '@angular/core';
import { ChangeDetectionStrategy, Component, inject, Input, OnDestroy, OnInit, signal } from '@angular/core';

import { PaginatorModule, PaginatorState } from 'primeng/paginator';

Expand All @@ -18,7 +18,7 @@ import { OrderComponent } from '../order/order.component';
styleUrl: './orders-list.component.scss',
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class OrdersListComponent implements OnInit {
export class OrdersListComponent implements OnInit, OnDestroy {
@Input() public users!: User[];

public userOrderService = inject(UserOrderService);
Expand All @@ -28,15 +28,20 @@ export class OrdersListComponent implements OnInit {
public rowsCount = 10;

public ngOnInit(): void {
this.orders.set(
this.userOrderService
.currentOrders$$()
.sort((a, b) => new Date(a.tripDepartureDate).getTime() - new Date(b.tripDepartureDate).getTime()),
);
this.userOrderService.createUserOrders();
const orders = this.userOrderService.currentOrders$$();
if (orders?.length) {
orders.sort((a, b) => new Date(a.tripDepartureDate).getTime() - new Date(b.tripDepartureDate).getTime());
this.orders.set(orders);
}
}

public onPageChange(event: PaginatorState): void {
this.firstPage = event.first ?? 0;
this.rowsCount = event.rows ?? 10;
}

public ngOnDestroy(): void {
this.userOrderService.currentOrders$$.set(null);
}
}
10 changes: 6 additions & 4 deletions src/app/orders/pages/orders/orders.component.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
@let users = ordersService.allUsers();

<div class="wrapper">
@if (authService.isAdmin$$() && userOrderService.currentOrders$$().length) {
<app-orders-list [users]="users"></app-orders-list>
} @else {
<app-orders-list></app-orders-list>
@if (userOrderService.currentOrders$$(); as orders) {
@if (authService.isAdmin$$() && orders.length) {
<app-orders-list [users]="users"></app-orders-list>
} @else {
<app-orders-list></app-orders-list>
}
}
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export class UserOrderService {
private tripCarriagesService = inject(TripCarriagesService);

private currentOrders: UserOrder[] = [];
public currentOrders$$ = signal<UserOrder[]>([]);
public currentOrders$$ = signal<UserOrder[] | null>(null);

public createUserOrders(): void {
this.currentOrders = [];
Expand Down

0 comments on commit 0d74478

Please sign in to comment.