Skip to content

Commit 7ca1f55

Browse files
committed
Revert "refactor: TT-327 Replace recently projects (#753)"
This reverts commit 02cb07b.
1 parent 5f0c2ad commit 7ca1f55

22 files changed

+222
-297
lines changed

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ describe('InputProjectComponent', () => {
1717
const state = {
1818
projects: [{ id: '', name: '', project_type_id: '' }],
1919
customerProjects: [{ id: '', name: '', project_type_id: '' }],
20-
recentProjects: [],
2120
isLoading: false,
2221
message: '',
2322
projectToEdit: undefined,

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ describe('ProjectListComponent', () => {
2323
const state: ProjectState = {
2424
projects: [project],
2525
customerProjects: [project],
26-
recentProjects: [],
2726
isLoading: false,
2827
message: '',
2928
projectToEdit: undefined,

src/app/modules/customer-management/components/projects/components/services/project.service.spec.ts

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -59,16 +59,6 @@ describe('ProjectService', () => {
5959
getProjectsRequest.flush(projectsList);
6060
});
6161

62-
it('recent projects are read using GET from url/recent', () => {
63-
const projectsFoundSize = projectsList.length;
64-
service.getRecentProjects().subscribe((projectsInResponse) => {
65-
expect(projectsInResponse.length).toBe(projectsFoundSize);
66-
});
67-
const getProjectsRequest = httpMock.expectOne(`${service.url}/recent`);
68-
expect(getProjectsRequest.request.method).toBe('GET');
69-
getProjectsRequest.flush(projectsList);
70-
});
71-
7262
it('create project using POST from url', () => {
7363
const project: Project[] = [{ id: '1', name: 'ccc', description: 'xxx', project_type_id: '123' }];
7464
service.url = 'projects';

src/app/modules/customer-management/components/projects/components/services/project.service.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,6 @@ export class ProjectService {
2222
return this.http.get<Project[]>(this.url);
2323
}
2424

25-
getRecentProjects(): Observable<Project[]> {
26-
return this.http.get<Project[]>(`${this.url}/recent`);
27-
}
28-
2925
createProject(projectData): Observable<any> {
3026
return this.http.post<Project[]>(this.url, projectData);
3127
}

src/app/modules/customer-management/components/projects/components/store/project.actions.spec.ts

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,6 @@ describe('Actions for Projects', () => {
2727
expect(LoadCustomerProjectsFail.type).toEqual(actions.ProjectActionTypes.LOAD_CUSTOMER_PROJECTS_FAIL);
2828
});
2929

30-
it('LoadRecentProjectsSuccess type is ProjectActionTypes.LOAD_RECENT_PROJECTS_SUCCESS', () => {
31-
const action = new actions.LoadRecentProjectsSuccess([]);
32-
expect(action.type).toEqual(actions.ProjectActionTypes.LOAD_RECENT_PROJECTS_SUCCESS);
33-
});
34-
35-
it('LoadRecentProjectsFail type is ProjectActionTypes.LOAD_RECENT_PROJECTS_FAIL', () => {
36-
const action = new actions.LoadRecentProjectsFail('error');
37-
expect(action.type).toEqual(actions.ProjectActionTypes.LOAD_RECENT_PROJECTS_FAIL);
38-
});
39-
4030
it('CreateProjectSuccess type is ProjectActionTypes.CREATE_PROJECT_SUCCESS', () => {
4131
const createProjectSuccess = new actions.CreateProjectSuccess({
4232
id: '1',

src/app/modules/customer-management/components/projects/components/store/project.actions.ts

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ export enum ProjectActionTypes {
88
LOAD_CUSTOMER_PROJECTS = '[Projects] LOAD_CUSTOMER_PROJECTS',
99
LOAD_CUSTOMER_PROJECTS_SUCCESS = '[Projects] LOAD_CUSTOMER_PROJECTS_SUCCESS',
1010
LOAD_CUSTOMER_PROJECTS_FAIL = '[Projects] LOAD_CUSTOMER_PROJECTS_FAIL',
11-
LOAD_RECENT_PROJECTS_SUCCESS = '[Projects] LOAD_RECENT_PROJECTS_SUCCESS',
12-
LOAD_RECENT_PROJECTS_FAIL = '[Projects] LOAD_RECENT_PROJECTS_FAIL',
1311
CREATE_PROJECT = '[Projects] CREATE_PROJECT',
1412
CREATE_PROJECT_SUCCESS = '[Projects] CREATE_PROJECT_SUCCESS',
1513
CREATE_PROJECT_FAIL = '[Projects] CREATE_PROJECT_FAIL',
@@ -62,16 +60,6 @@ export class LoadCustomerProjectsFail implements Action {
6260
constructor(public error: string) {}
6361
}
6462

65-
export class LoadRecentProjectsSuccess implements Action {
66-
readonly type = ProjectActionTypes.LOAD_RECENT_PROJECTS_SUCCESS;
67-
constructor(readonly payload: Project[]) {}
68-
}
69-
70-
export class LoadRecentProjectsFail implements Action {
71-
public readonly type = ProjectActionTypes.LOAD_RECENT_PROJECTS_FAIL;
72-
constructor(public error: string) {}
73-
}
74-
7563
export class CreateProject implements Action {
7664
public readonly type = ProjectActionTypes.CREATE_PROJECT;
7765

@@ -162,8 +150,6 @@ export type ProjectActions =
162150
| LoadCustomerProjects
163151
| LoadCustomerProjectsSuccess
164152
| LoadCustomerProjectsFail
165-
| LoadRecentProjectsSuccess
166-
| LoadRecentProjectsFail
167153
| CreateProject
168154
| CreateProjectSuccess
169155
| CreateProjectFail

src/app/modules/customer-management/components/projects/components/store/project.effects.spec.ts

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -55,28 +55,6 @@ describe('ProjectEffects', () => {
5555
});
5656
});
5757

58-
it('action type is LOAD_RECENT_PROJECTS_SUCCESS when service is executed sucessfully', async () => {
59-
actions$ = of({ type: ProjectActionTypes.LOAD_PROJECTS });
60-
const serviceSpy = spyOn(service, 'getRecentProjects');
61-
serviceSpy.and.returnValue(of(projects));
62-
63-
effects.loadRecentProjects$.subscribe((action) => {
64-
expect(action.type).toEqual(ProjectActionTypes.LOAD_RECENT_PROJECTS_SUCCESS);
65-
});
66-
});
67-
68-
it('action type is LOAD_RECENT_PROJECTS_FAIL when service fail in execution', async () => {
69-
actions$ = of({ type: ProjectActionTypes.LOAD_PROJECTS });
70-
const serviceSpy = spyOn(service, 'getRecentProjects');
71-
serviceSpy.and.returnValue(throwError({ error: { message: 'fail!' } }));
72-
spyOn(toastrService, 'error');
73-
74-
effects.loadRecentProjects$.subscribe((action) => {
75-
expect(toastrService.error).toHaveBeenCalled();
76-
expect(action.type).toEqual(ProjectActionTypes.LOAD_RECENT_PROJECTS_FAIL);
77-
});
78-
});
79-
8058
it('action type is UPDATE_PROJECT_SUCCESS when service is executed sucessfully', async () => {
8159
actions$ = of({ type: ProjectActionTypes.UPDATE_PROJECT, project });
8260
spyOn(toastrService, 'success');

src/app/modules/customer-management/components/projects/components/store/project.effects.ts

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -49,22 +49,6 @@ export class ProjectEffects {
4949
)
5050
);
5151

52-
@Effect()
53-
loadRecentProjects$: Observable<Action> = this.actions$.pipe(
54-
ofType(actions.ProjectActionTypes.LOAD_PROJECTS),
55-
mergeMap(() =>
56-
this.projectService.getRecentProjects().pipe(
57-
map((projects) => {
58-
return new actions.LoadRecentProjectsSuccess(projects);
59-
}),
60-
catchError((error) => {
61-
this.toastrService.error(error.error.message);
62-
return of(new actions.LoadRecentProjectsFail(error));
63-
})
64-
)
65-
)
66-
);
67-
6852
@Effect()
6953
createProject$: Observable<Action> = this.actions$.pipe(
7054
ofType(actions.ProjectActionTypes.CREATE_PROJECT),

src/app/modules/customer-management/components/projects/components/store/project.reducer.spec.ts

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@ import { projectReducer, ProjectState } from './project.reducer';
55
describe('projectReducer', () => {
66
const initialState: ProjectState = {
77
projects: [{ id: 'id', name: 'name', project_type_id: '', status: 'inactive' }],
8-
customerProjects: [],
9-
recentProjects: [],
10-
isLoading: false, message: '', projectToEdit: undefined
8+
customerProjects: [], isLoading: false, message: '', projectToEdit: undefined
119
};
1210
const archivedProject: Project = { id: '1', name: 'aaa', description: 'bbb', project_type_id: '123', status: 'inactive' };
1311
const project: Project = { id: '1', name: 'aaa', description: 'bbb', project_type_id: '123', status: 'active' };
@@ -40,23 +38,6 @@ describe('projectReducer', () => {
4038
expect(state.customerProjects).toEqual([]);
4139
});
4240

43-
it('on LoadRecentProjectsSuccess, projectsFound are saved in the store', () => {
44-
const projectsFound: Project[] = [{ id: '1', name: 'abc', description: 'xxx', status: 'active' }];
45-
const newState = initialState;
46-
newState.recentProjects = projectsFound;
47-
const action = new actions.LoadRecentProjectsSuccess(projectsFound);
48-
const state = projectReducer(initialState, action);
49-
expect(state).toEqual(newState);
50-
});
51-
52-
it('on LoadRecentProjectsFail, recentProjects equal []', () => {
53-
const newState = initialState;
54-
newState.recentProjects = [];
55-
const action = new actions.LoadRecentProjectsFail('error');
56-
const state = projectReducer(initialState, action);
57-
expect(state).toEqual(newState);
58-
});
59-
6041
it('on CreateProject, isLoading is true', () => {
6142
const action = new actions.CreateProject(project);
6243
const state = projectReducer(initialState, action);
@@ -93,7 +74,6 @@ describe('projectReducer', () => {
9374
const currentState: ProjectState = {
9475
projects: [project],
9576
customerProjects: [project],
96-
recentProjects: [project],
9777
isLoading: false,
9878
message: '',
9979
projectToEdit: project,
@@ -144,7 +124,6 @@ describe('projectReducer', () => {
144124
const currentState: ProjectState = {
145125
projects: [project],
146126
customerProjects: [project],
147-
recentProjects: [project],
148127
isLoading: false,
149128
message: '',
150129
projectToEdit: undefined,
@@ -179,7 +158,6 @@ describe('projectReducer', () => {
179158
const currentState: ProjectState = {
180159
projects: [project],
181160
customerProjects: [archivedProject],
182-
recentProjects: [project],
183161
isLoading: false,
184162
message: '',
185163
projectToEdit: project,

src/app/modules/customer-management/components/projects/components/store/project.reducer.ts

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import { Project } from '../../../../../shared/models';
44
export interface ProjectState {
55
projects: Project[];
66
customerProjects: Project[];
7-
recentProjects: Project[];
87
isLoading: boolean;
98
message: string;
109
projectToEdit: Project;
@@ -13,7 +12,6 @@ export interface ProjectState {
1312
export const initialState = {
1413
projects: [],
1514
customerProjects: [],
16-
recentProjects: [],
1715
isLoading: false,
1816
message: '',
1917
projectToEdit: undefined,
@@ -67,21 +65,6 @@ export const projectReducer = (state: ProjectState = initialState, action: Proje
6765
};
6866
}
6967

70-
case ProjectActionTypes.LOAD_RECENT_PROJECTS_SUCCESS:
71-
return {
72-
...state,
73-
recentProjects: action.payload,
74-
isLoading: false
75-
};
76-
77-
case ProjectActionTypes.LOAD_RECENT_PROJECTS_FAIL: {
78-
return {
79-
...state,
80-
recentProjects: [],
81-
isLoading: false,
82-
};
83-
}
84-
8568
case ProjectActionTypes.CREATE_PROJECT: {
8669
return {
8770
...state,

0 commit comments

Comments
 (0)