Skip to content

Commit 9b6516f

Browse files
committed
fix: ioet#256 Display_Customer_name_during_their_edition
1 parent 10a46cb commit 9b6516f

File tree

7 files changed

+55
-26
lines changed

7 files changed

+55
-26
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ export class CreateCustomerComponent implements OnInit, OnDestroy {
2424
@Input() areTabsActive: boolean;
2525
@Output() changeValueAreTabsActives = new EventEmitter<boolean>();
2626
@Output() closeCustomerComponent = new EventEmitter<boolean>();
27+
@Output() sendActivityName = new EventEmitter<string>();
2728
customerToEdit: Customer;
2829
editSubscription: Subscription;
2930

@@ -59,6 +60,7 @@ export class CreateCustomerComponent implements OnInit, OnDestroy {
5960
} else {
6061
this.store.dispatch(new CreateCustomer(customerData));
6162
}
63+
this.sendActivityName.emit(customerData.name);
6264
this.areTabsActive = true;
6365
this.changeValueAreTabsActives.emit(this.areTabsActive);
6466
}
@@ -68,6 +70,7 @@ export class CreateCustomerComponent implements OnInit, OnDestroy {
6870
this.store.dispatch(new LoadProjectTypes(customerData.id));
6971
this.store.dispatch(new LoadCustomerProjects(customerData.id));
7072
this.changeValueAreTabsActives.emit(true);
73+
this.sendActivityName.emit(customerData.name);
7174
this.customerForm.setValue({
7275
name: customerData.name,
7376
description: customerData.description,

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

Lines changed: 22 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
import {async, ComponentFixture, TestBed} from '@angular/core/testing';
2-
import {MockStore, provideMockStore} from '@ngrx/store/testing';
1+
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
2+
import { MockStore, provideMockStore } from '@ngrx/store/testing';
33

4-
import {NgxPaginationModule} from 'ngx-pagination';
5-
import {CustomerListComponent} from './customer-list.component';
4+
import { NgxPaginationModule } from 'ngx-pagination';
5+
import { CustomerListComponent } from './customer-list.component';
66
import {
77
CustomerManagementActionTypes,
88
CustomerState,
99
DeleteCustomer,
1010
LoadCustomers,
11-
SetCustomerToEdit
11+
SetCustomerToEdit,
1212
} from 'src/app/modules/customer-management/store';
13-
import {DataTablesModule} from 'angular-datatables';
14-
import {ActionsSubject} from '@ngrx/store';
13+
import { DataTablesModule } from 'angular-datatables';
14+
import { ActionsSubject } from '@ngrx/store';
1515

1616
describe('CustomerTableListComponent', () => {
1717
let component: CustomerListComponent;
@@ -20,22 +20,18 @@ describe('CustomerTableListComponent', () => {
2020
const actionSub: ActionsSubject = new ActionsSubject();
2121

2222
const state = {
23-
data: [{tenant_id: 'id', name: 'name', description: 'description'}],
23+
data: [{ tenant_id: 'id', name: 'name', description: 'description' }],
2424
isLoading: false,
2525
message: '',
2626
customerIdToEdit: '',
27-
customerId: ''
27+
customerId: '',
2828
};
2929

30-
3130
beforeEach(async(() => {
3231
TestBed.configureTestingModule({
3332
imports: [NgxPaginationModule, DataTablesModule],
3433
declarations: [CustomerListComponent],
35-
providers: [
36-
provideMockStore({initialState: state}),
37-
{provide: ActionsSubject, useValue: actionSub}
38-
],
34+
providers: [provideMockStore({ initialState: state }), { provide: ActionsSubject, useValue: actionSub }],
3935
}).compileComponents();
4036
}));
4137

@@ -46,7 +42,6 @@ describe('CustomerTableListComponent', () => {
4642
store = TestBed.inject(MockStore);
4743
store.setState(state);
4844
fixture.detectChanges();
49-
5045
});
5146

5247
it('component should be created', () => {
@@ -79,40 +74,42 @@ describe('CustomerTableListComponent', () => {
7974
});
8075

8176
const params = [
82-
{actionName: 'delete', actionType: CustomerManagementActionTypes.DELETE_CUSTOMER_SUCCESS},
83-
{actionName: 'update', actionType: CustomerManagementActionTypes.UPDATE_CUSTOMER_SUCCESS},
84-
{actionName: 'create', actionType: CustomerManagementActionTypes.CREATE_CUSTOMER_SUCCESS}
77+
{ actionName: 'delete', actionType: CustomerManagementActionTypes.DELETE_CUSTOMER_SUCCESS },
78+
{ actionName: 'update', actionType: CustomerManagementActionTypes.UPDATE_CUSTOMER_SUCCESS },
79+
{ actionName: 'create', actionType: CustomerManagementActionTypes.CREATE_CUSTOMER_SUCCESS },
8580
];
8681

87-
params.map(param =>
82+
params.map((param) =>
8883
it(`on success ${param.actionName} customer, the load all customer action should be triggered`, () => {
8984
const actionSubject = TestBed.get(ActionsSubject) as ActionsSubject;
9085
const action = {
91-
type: param.actionType
86+
type: param.actionType,
9287
};
9388
spyOn(store, 'dispatch');
9489

9590
actionSubject.next(action);
9691

9792
expect(store.dispatch).toHaveBeenCalledWith(new LoadCustomers());
98-
}));
93+
})
94+
);
9995

100-
params.map(param =>
96+
params.map((param) =>
10197
it(`on success ${param.actionName} customer, the customer form should be disabled`, () => {
10298
const actionSubject = TestBed.get(ActionsSubject) as ActionsSubject;
10399
const action = {
104-
type: param.actionType
100+
type: param.actionType,
105101
};
106102
actionSubject.next(action);
107103

108104
expect(component.showCustomerForm).toBe(false);
109-
}));
105+
})
106+
);
110107

111108
it('on success load customers, the customer list should be populated', () => {
112109
const actionSubject = TestBed.get(ActionsSubject) as ActionsSubject;
113110
const action = {
114111
type: CustomerManagementActionTypes.LOAD_CUSTOMERS_SUCCESS,
115-
payload: state.data
112+
payload: state.data,
116113
};
117114

118115
actionSubject.next(action);

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<div class="container border mb-4 mt-0">
2+
<h3 class="title">{{customerName}}</h3>
23
<ul class="nav nav-tabs mt-2" id="myTab" role="tablist">
34
<li class="nav-item">
45
<a
@@ -52,6 +53,7 @@
5253
[areTabsActive]="areTabsActive"
5354
(changeValueAreTabsActives)="activeTabs($event)"
5455
(closeCustomerComponent)="closeCustomer($event)"
56+
(sendActivityName)="sendActivityName($event)"
5557
></app-create-customer>
5658
</div>
5759
<div

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,8 @@
66
.nav-item > a:hover {
77
opacity: 0.6;
88
}
9+
10+
.title {
11+
text-align: center;
12+
padding: 12px;
13+
}

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,37 @@
11
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
22

33
import { ManagementCustomerProjectsComponent } from './management-customer-projects.component';
4+
import { MockStore, provideMockStore } from '@ngrx/store/testing';
5+
import { CustomerState } from '../../store';
46

57
describe('ManagmentCustomerProjectsComponent', () => {
68
let component: ManagementCustomerProjectsComponent;
79
let fixture: ComponentFixture<ManagementCustomerProjectsComponent>;
10+
let store: MockStore<CustomerState>;
11+
12+
const state = {
13+
data: [],
14+
isLoading: false,
15+
message: '',
16+
customerIdToEdit: '',
17+
customerId: '',
18+
};
819

920
beforeEach(async(() => {
1021
TestBed.configureTestingModule({
1122
declarations: [ManagementCustomerProjectsComponent],
23+
providers: [
24+
provideMockStore({ initialState: state })
25+
],
1226
}).compileComponents();
1327
}));
1428

1529
beforeEach(() => {
1630
fixture = TestBed.createComponent(ManagementCustomerProjectsComponent);
1731
component = fixture.componentInstance;
1832
fixture.detectChanges();
33+
store = TestBed.inject(MockStore);
34+
store.setState(state);
1935
});
2036

2137
it('component should be created', () => {

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export class ManagementCustomerProjectsComponent {
99
@Output() closeCustemerForm = new EventEmitter<boolean>();
1010
areTabsActive: boolean;
1111
activeTab: string;
12+
customerName: string;
1213
constructor() {}
1314

1415
activeTabs($areTabsActive: boolean) {
@@ -25,5 +26,9 @@ export class ManagementCustomerProjectsComponent {
2526
showTab(activeTab: string) {
2627
this.activeTab = activeTab;
2728
}
28-
29+
sendActivityName(event) {
30+
setTimeout(() => {
31+
this.customerName = event;
32+
}, 1);
33+
}
2934
}

src/app/modules/customer-management/pages/customer.component.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { Component } from '@angular/core';
77
})
88
export class CustomerComponent {
99
showCustomerForm = false;
10+
activityName: string;
1011

1112
activateCustomerForm() {
1213
this.showCustomerForm = true;

0 commit comments

Comments
 (0)