Skip to content

Commit

Permalink
feat: no orders message
Browse files Browse the repository at this point in the history
  • Loading branch information
stardustmeg committed Sep 3, 2024
1 parent ebfc5cd commit 7508f3c
Show file tree
Hide file tree
Showing 8 changed files with 67 additions and 5 deletions.
File renamed without changes
Binary file added public/img/png/no-results.webp
Binary file not shown.
27 changes: 27 additions & 0 deletions src/app/admin/pages/carriages/carriages.component.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { provideHttpClient } from '@angular/common/http';
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { ActivatedRoute } from '@angular/router';

import { of } from 'rxjs';

import { CarriagesComponent } from './carriages.component';

describe('CarriagesComponent', () => {
let component: CarriagesComponent;
let fixture: ComponentFixture<CarriagesComponent>;

beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [CarriagesComponent],
providers: [provideHttpClient(), { provide: ActivatedRoute, useValue: { queryParams: of({}) } }],
}).compileComponents();

fixture = TestBed.createComponent(CarriagesComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,11 @@

transition:
border-color 0.2s,
box-shadow 0.2s,
filter 0.2s;

&:hover {
filter: brightness(1.01);
border: $three solid $main-color;
box-shadow: $shadow-100;
}

@media (width <=1024px) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { ResultListService } from '../../services/result-list/result-list.servic
import { TripDetailsComponent } from '../trip-details/trip-details.component';
import { ResultItemComponent } from './components/result-item/result-item.component';

const imgUrl = '/img/no-results.png';
const imgUrl = '/img/png/no-results.png';

@Component({
selector: 'app-result-list',
Expand Down
8 changes: 7 additions & 1 deletion src/app/orders/pages/orders/orders.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@
<div class="wrapper">
@if (authService.isAdmin$$() && userOrderService.currentOrders$$().length) {
<app-orders-list [users]="users"></app-orders-list>
} @else {
} @else if (userOrderService.currentOrders$$().length) {
<app-orders-list></app-orders-list>
} @else {
<div class="no-result">
<h1 class="description">You don't have any orders yet.<br />Time to choose where you want to go.</h1>
<p-button class="to-main-button" label="Choose a trip" routerLink="/" icon="pi pi-globe"></p-button>
<img class="image" [src]="imageUrl" alt="No result" />
</div>
}
</div>
25 changes: 25 additions & 0 deletions src/app/orders/pages/orders/orders.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,28 @@
flex-direction: column;
padding: $offset-l;
}

.no-result {
display: flex;
flex-direction: column;
gap: $offset-xs;
align-items: center;
justify-content: center;

padding: $offset-m;

text-align: center;
}

.description {
font-size: $font-size-m;
color: $gray-500;
}

.to-main-button {
margin-top: $offset-s;
}

.image {
max-width: 50dvw;
}
8 changes: 7 additions & 1 deletion src/app/orders/pages/orders/orders.component.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { ChangeDetectionStrategy, Component, inject, OnDestroy, OnInit } from '@angular/core';
import { RouterLink } from '@angular/router';

import { ButtonModule } from 'primeng/button';
import { Subscription } from 'rxjs';

import { CarriageService } from '@/app/api/carriagesService/carriage.service';
Expand All @@ -10,10 +12,12 @@ import { UserOrderService } from '@/app/shared/services/data/userOrder/user-orde

import { OrdersListComponent } from '../../components/orders-list/orders-list.component';

const imgUrl = '/img/png/no-results.webp';

@Component({
selector: 'app-orders',
standalone: true,
imports: [OrdersListComponent],
imports: [OrdersListComponent, ButtonModule, RouterLink],
templateUrl: './orders.component.html',
styleUrl: './orders.component.scss',
providers: [],
Expand All @@ -29,6 +33,8 @@ export class OrdersComponent implements OnInit, OnDestroy {
public userOrderService = inject(UserOrderService);
public authService = inject(AuthService);

public imageUrl = imgUrl;

public ngOnInit(): void {
if (this.authService.isAdmin$$()) {
this.ordersService.getAllUsers().subscribe();
Expand Down

1 comment on commit 7508f3c

@stardustmeg
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.