Skip to content

Commit

Permalink
Results not found working
Browse files Browse the repository at this point in the history
  • Loading branch information
LuisLeandro94 committed Jun 17, 2021
1 parent 115f0fd commit 3042853
Show file tree
Hide file tree
Showing 7 changed files with 91 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { NotFoundComponent } from './not-found/not-found.component';
import { ImageService } from './services/image.service';
import { FormsModule } from '@angular/forms';
import { HttpClientModule } from '@angular/common/http';
import { ErrorComponent } from './error/error.component';

@NgModule({
declarations: [
Expand All @@ -22,6 +23,7 @@ import { HttpClientModule } from '@angular/common/http';
ImageListComponent,
NavbarComponent,
NotFoundComponent,
ErrorComponent,
],
imports: [
BrowserModule,
Expand Down
33 changes: 33 additions & 0 deletions src/app/error/error.component.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
h1 {
font-size: 3em;
margin-bottom: 20px;
font-weight: var(--fw-bold);
font-family: var(--ff-primary);
color: var(--clr-accent);
text-shadow: 2px 2px var(--clr-dark);
}

h2 {
margin-top: 20px;
font-size: 1.3em;
font-weight: var(--fw-reg);
font-family: var(--ff-primary);
color: var(--clr-dark);
}

.noresults {
display: flex;
flex-direction: column;
text-align: center;
}

a {
text-decoration: none;
}

.img-not-found {
width: 500px;
align-self: center;
margin-top: 100px;
cursor: pointer;
}
10 changes: 10 additions & 0 deletions src/app/error/error.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<a (click)="returnList()">
<div class="noresults">
<img
src="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQRLmDDGhuBgwDmBdnqVqGZ--vODJf3fkw_MIqhYxm4mGT1tzM&s"
alt="Not Found Image"
class="img-not-found"
/>
<h2>A pesquisa não encontrou resultados!</h2>
</div>
</a>
25 changes: 25 additions & 0 deletions src/app/error/error.component.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';

import { ErrorComponent } from './error.component';

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

beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ ErrorComponent ]
})
.compileComponents();
});

beforeEach(() => {
fixture = TestBed.createComponent(ErrorComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
19 changes: 19 additions & 0 deletions src/app/error/error.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router';
import { DatastoreService } from '../services/datastore.service';

@Component({
selector: 'app-error',
templateUrl: './error.component.html',
styleUrls: ['./error.component.css'],
})
export class ErrorComponent implements OnInit {
constructor(private dataStore: DatastoreService, private router: Router) {}

ngOnInit(): void {}

returnList() {
this.dataStore.getImages(1);
this.router.navigate(['']);
}
}
2 changes: 1 addition & 1 deletion src/app/navbar/navbar.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@
Search
</button>
</form>
<app-modal *ngIf="searchInput == '' || null"></app-modal>
</div>
</nav>
<ng-template #data let-modal>
Expand Down Expand Up @@ -90,3 +89,4 @@ <h6 class="modal-title">Search Error</h6>
</button>
</div>
</ng-template>
<app-error *ngIf="dataStore.Images.length == 0"></app-error>
2 changes: 1 addition & 1 deletion src/app/navbar/navbar.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export class NavbarComponent implements OnInit {
isMenuCollapsed = true;

constructor(
private dataStore: DatastoreService,
public dataStore: DatastoreService,
private modalService: NgbModal,
private router: Router
) {}
Expand Down

0 comments on commit 3042853

Please sign in to comment.