Skip to content

Commit 2e9aef9

Browse files
committed
fix: #87 fixed issues and remove search component
1 parent 2cc4c8c commit 2e9aef9

File tree

18 files changed

+57
-87
lines changed

18 files changed

+57
-87
lines changed

src/app/app.module.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ import { environment } from '../environments/environment';
3939
import { CustomerComponent } from './modules/customer-management/pages/customer.component';
4040
// tslint:disable-next-line: max-line-length
4141
import { CustomerListComponent } from './modules/customer-management/components/customer-info/components/customer-list/customer-list.component';
42-
import { SearchComponent } from './modules/customer-management/components/search/search.component';
4342
// tslint:disable-next-line: max-line-length
4443
import { ManagementCustomerProjectsComponent } from './modules/customer-management/components/management-customer-projects/management-customer-projects.component';
4544
import { CreateCustomerComponent } from './modules/customer-management/components/customer-info/components/create-customer/create-customer';
@@ -78,7 +77,6 @@ import { CustomerEffects } from './modules/customer-management/store/customer-ma
7877
SearchProjectComponent,
7978
CustomerComponent,
8079
CustomerListComponent,
81-
SearchComponent,
8280
ManagementCustomerProjectsComponent,
8381
CreateCustomerComponent,
8482
CreateProjectComponent,

src/app/modules/customer-management/components/customer-info/components/create-customer/create-customer.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<div class="form-group">
44
<div
55
*ngIf="showAlert && messageToShow !== ''"
6-
[ngClass]="{'bg-secondary': messageToShow == 'Customer create successfully!', 'bg-primary': messageToShow != 'Customer create successfully!'}"
6+
[ngClass]="{'bg-secondary': messageToShow == 'Customer created successfully!', 'bg-primary': messageToShow != 'Customer created successfully!'}"
77
class="alert alert-dismissible fade fade-in show text-white"
88
role="alert"
99
>

src/app/modules/customer-management/components/customer-info/components/create-customer/create-customer.spec.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
2+
import { FormBuilder } from '@angular/forms';
3+
import { MockStore, provideMockStore } from '@ngrx/store/testing';
24

35
import { CreateCustomerComponent } from './create-customer';
4-
import { MockStore, provideMockStore } from '@ngrx/store/testing';
56
import { CustomerState, CreateCustomer } from 'src/app/modules/customer-management/store';
6-
import { FormBuilder } from '@angular/forms';
7-
import { Customer } from 'src/app/modules/shared/models/customer.model';
7+
import * as models from 'src/app/modules/shared/models/index';
88

99
describe('CreateCustomerComponent', () => {
1010
let component: CreateCustomerComponent;
@@ -17,7 +17,7 @@ describe('CreateCustomerComponent', () => {
1717
message: '',
1818
};
1919

20-
const customerData: Customer = {
20+
const customerData: models.Customer = {
2121
name: 'aa',
2222
description: 'bb',
2323
tenant_id: 'cc',
@@ -72,8 +72,8 @@ describe('CreateCustomerComponent', () => {
7272
expect(component.customerForm.reset).toHaveBeenCalled();
7373
});
7474

75-
it('should be enable tabs and show message Customer create successfully! ', () => {
76-
component.isActiveItemTabs = false;
75+
it('should be enable tabs and show message Customer created successfully! ', () => {
76+
component.areTabsActive = false;
7777
component.messageToShow = '';
7878

7979
spyOn(store, 'dispatch');
@@ -82,14 +82,14 @@ describe('CreateCustomerComponent', () => {
8282

8383
component.onSubmit(customerData);
8484

85-
component.setStatusOnScreen('Customer create successfully!');
85+
component.setStatusOnScreen('Customer created successfully!');
8686

87-
expect(component.messageToShow).toEqual('Customer create successfully!');
88-
expect(component.isActiveItemTabs).toBeTrue();
87+
expect(component.messageToShow).toEqual('Customer created successfully!');
88+
expect(component.areTabsActive).toBeTrue();
8989
});
9090

91-
it('should be disabled tabs and show message Something went wrong creating customer! ', () => {
92-
component.isActiveItemTabs = false;
91+
it('should be disabled tabs and show message An error occurred, try again later. ', () => {
92+
component.areTabsActive = false;
9393
component.messageToShow = '';
9494

9595
spyOn(store, 'dispatch');
@@ -98,9 +98,9 @@ describe('CreateCustomerComponent', () => {
9898

9999
component.onSubmit(customerData);
100100

101-
component.setStatusOnScreen('Something went wrong creating customer!');
101+
component.setStatusOnScreen('An error occurred, try again later.');
102102

103-
expect(component.messageToShow).toEqual('Something went wrong creating customer!');
104-
expect(component.isActiveItemTabs).toBeFalse();
103+
expect(component.messageToShow).toEqual('An error occurred, try again later.');
104+
expect(component.areTabsActive).toBeFalse();
105105
});
106106
});

src/app/modules/customer-management/components/customer-info/components/create-customer/create-customer.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import { Component, Input, Output, EventEmitter, OnDestroy, OnInit } from '@angular/core';
2-
import { Store, select } from '@ngrx/store';
3-
import { CustomerState, CreateCustomer } from 'src/app/modules/customer-management/store';
42
import { FormGroup, FormBuilder, Validators } from '@angular/forms';
3+
import { Store, select } from '@ngrx/store';
4+
55
import { Subscription } from 'rxjs';
6+
import { CustomerState, CreateCustomer } from 'src/app/modules/customer-management/store';
67
import { getStatusMessage } from 'src/app/modules/customer-management/store/customer-management.selectors';
78

89
@Component({
@@ -12,8 +13,8 @@ import { getStatusMessage } from 'src/app/modules/customer-management/store/cust
1213
})
1314
export class CreateCustomerComponent implements OnInit, OnDestroy {
1415
customerForm: FormGroup;
15-
@Input() isActiveItemTabs: boolean;
16-
@Output() changeValueIsActiveItemTabs = new EventEmitter<boolean>();
16+
@Input() areTabsActive: boolean;
17+
@Output() changeValueAreTabsActives = new EventEmitter<boolean>();
1718
showAlert = false;
1819
messageToShow = '';
1920
saveSubscription: Subscription;
@@ -29,12 +30,11 @@ export class CreateCustomerComponent implements OnInit, OnDestroy {
2930
const messages$ = this.store.pipe(select(getStatusMessage));
3031
this.saveSubscription = messages$.subscribe((valueMessage) => {
3132
this.setStatusOnScreen(valueMessage);
32-
console.log(valueMessage);
3333
});
3434
}
3535

3636
ngOnDestroy() {
37-
this.isActiveItemTabs = false;
37+
this.areTabsActive = false;
3838
this.saveSubscription.unsubscribe();
3939
}
4040

@@ -44,14 +44,14 @@ export class CreateCustomerComponent implements OnInit, OnDestroy {
4444
}
4545

4646
setStatusOnScreen(message: string) {
47-
if (message === 'Customer create successfully!') {
47+
if (message === 'Customer created successfully!') {
4848
this.messageToShow = message;
49-
this.isActiveItemTabs = true;
50-
this.changeValueIsActiveItemTabs.emit(this.isActiveItemTabs);
51-
} else if (message === 'Something went wrong creating customer!') {
49+
this.areTabsActive = true;
50+
this.changeValueAreTabsActives.emit(this.areTabsActive);
51+
} else if (message === 'An error occurred, try again later.') {
5252
this.messageToShow = message;
53-
this.isActiveItemTabs = false;
54-
this.changeValueIsActiveItemTabs.emit(this.isActiveItemTabs);
53+
this.areTabsActive = false;
54+
this.changeValueAreTabsActives.emit(this.areTabsActive);
5555
}
5656
}
5757

src/app/modules/customer-management/components/management-customer-projects/management-customer-projects.component.html

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,9 @@
1212
>
1313
</li>
1414
<li class="nav-item">
15-
<!--nav-active-->
1615
<a
1716
class="nav-link text-black font-weight-bold"
18-
[ngClass]="{ 'nav-active': isActiveNavsItemTabs, disabled: !isActiveNavsItemTabs }"
17+
[ngClass]="{ 'nav-active': areTabsActive, disabled: !areTabsActive }"
1918
id="projects-type-tab"
2019
data-toggle="tab"
2120
href="#projectsType"
@@ -27,7 +26,7 @@
2726
<li class="nav-item">
2827
<a
2928
class="nav-link text-black font-weight-bold"
30-
[ngClass]="{ 'nav-active': isActiveNavsItemTabs, disabled: !isActiveNavsItemTabs }"
29+
[ngClass]="{ 'nav-active': areTabsActive, disabled: !areTabsActive }"
3130
id="projects-tab"
3231
data-toggle="tab"
3332
href="#projects"
@@ -45,8 +44,8 @@
4544
aria-labelledby="customer-information-tab"
4645
>
4746
<app-create-customer
48-
[isActiveItemTabs]="isActiveNavsItemTabs"
49-
(changeValueIsActiveItemTabs)="isActiveNavsItemTabs = $event"
47+
[areTabsActive]="areTabsActive"
48+
(changeValueAreTabsActives)="areTabsActive = $event"
5049
></app-create-customer>
5150
</div>
5251
<div class="tab-pane fade mt-3" id="projects" role="tabpanel" aria-labelledby="projects-tab">

src/app/modules/customer-management/components/management-customer-projects/management-customer-projects.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { Component } from '@angular/core';
66
styleUrls: ['./management-customer-projects.component.scss'],
77
})
88
export class ManagementCustomerProjectsComponent {
9-
isActiveNavsItemTabs = false;
9+
areTabsActive = false;
1010

1111
constructor() {}
1212
}

src/app/modules/customer-management/components/projects/components/create-project/create-project.component.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@
2020
<hr />
2121
<div class="row text-right">
2222
<hr />
23-
<app-search></app-search>
23+
<div class="col-5 text-right">
24+
<app-search-project></app-search-project>
25+
</div>
2426
</div>
2527
<app-project-list></app-project-list>
2628
</div>

src/app/modules/customer-management/components/search/search.component.html

Lines changed: 0 additions & 5 deletions
This file was deleted.

src/app/modules/customer-management/components/search/search.component.scss

Whitespace-only changes.

src/app/modules/customer-management/components/search/search.component.spec.ts

Lines changed: 0 additions & 25 deletions
This file was deleted.

0 commit comments

Comments
 (0)