Skip to content

Commit 7675c47

Browse files
committed
fix: #256 Display_Customer_name_during_their_edition
1 parent 10a46cb commit 7675c47

File tree

3 files changed

+31
-3
lines changed

3 files changed

+31
-3
lines changed

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

Lines changed: 1 addition & 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>{{customerName}}</h3>
23
<ul class="nav nav-tabs mt-2" id="myTab" role="tablist">
34
<li class="nav-item">
45
<a

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: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,26 @@
1-
import { Component, Output, EventEmitter } from '@angular/core';
1+
import { Component, Output, EventEmitter, OnInit } from '@angular/core';
2+
import { getCustomerById } from '../../store/customer-management.selectors';
3+
import { Store, select } from '@ngrx/store';
4+
import { CustomerState } from '../../store';
25

36
@Component({
47
selector: 'app-management-customer-projects',
58
templateUrl: './management-customer-projects.component.html',
69
styleUrls: ['./management-customer-projects.component.scss'],
710
})
8-
export class ManagementCustomerProjectsComponent {
11+
export class ManagementCustomerProjectsComponent implements OnInit {
912
@Output() closeCustemerForm = new EventEmitter<boolean>();
1013
areTabsActive: boolean;
1114
activeTab: string;
12-
constructor() {}
15+
customerName: string;
16+
constructor( private store: Store<CustomerState>) {}
17+
18+
ngOnInit(): void {
19+
const customers$ = this.store.pipe(select(getCustomerById));
20+
customers$.subscribe((customer) => {
21+
this.customerName = customer ? customer.name : '';
22+
});
23+
}
1324

1425
activeTabs($areTabsActive: boolean) {
1526
setTimeout(() => {

0 commit comments

Comments
 (0)