Skip to content

Commit 46175cc

Browse files
author
Antonio Contreras LEMONCODE
committed
Create employee row component and refactor other components
1 parent 36de8e0 commit 46175cc

9 files changed

Lines changed: 52 additions & 15 deletions

File tree

src/pods/employee/api/employee.api-model.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@ export interface Employee {
1010
export interface ProjectSummary {
1111
id: string;
1212
isAssigned?: boolean;
13-
employeeName: string;
13+
projectName: string;
1414
}

src/pods/employee/api/employee.mock-data.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,22 @@ const mockProjectSummaryList: ProjectSummary[] = [
44
{
55
id: '1',
66
isAssigned: true,
7-
employeeName: 'Mapfre',
7+
projectName: 'Mapfre',
88
},
99
{
1010
id: '2',
1111
isAssigned: false,
12-
employeeName: 'Bankia',
12+
projectName: 'Bankia',
1313
},
1414
{
1515
id: '3',
1616
isAssigned: false,
17-
employeeName: 'Vacaciones',
17+
projectName: 'Vacaciones',
1818
},
1919
{
2020
id: '4',
2121
isAssigned: true,
22-
employeeName: 'Baja',
22+
projectName: 'Baja',
2323
},
2424
];
2525

src/pods/employee/components/project-row.component.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export const EmployeeRowComponent: React.FunctionComponent<Props> = ({
1717
<CellComponent>
1818
<Checkbox checked={row.isAssigned} color="primary" />
1919
</CellComponent>
20-
<CellComponent>{row.employeeName}</CellComponent>
20+
<CellComponent>{row.projectName}</CellComponent>
2121
</RowComponent>
2222
);
2323
};

src/pods/employee/employee.mappers.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ describe('./pods/employee/employee.mappers', () => {
9090
projects: [
9191
{
9292
id: 'test id',
93-
employeeName: 'test employee name',
93+
projectName: 'test employee name',
9494
isAssigned: true,
9595
},
9696
],
@@ -105,7 +105,7 @@ describe('./pods/employee/employee.mappers', () => {
105105
projects: [
106106
{
107107
id: 'test id',
108-
employeeName: 'test employee name',
108+
projectName: 'test employee name',
109109
isAssigned: true,
110110
},
111111
],

src/pods/employee/employee.vm.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export interface Employee {
1010
export interface ProjectSummary {
1111
id: string;
1212
isAssigned?: boolean;
13-
employeeName: string;
13+
projectName: string;
1414
}
1515

1616
export const createEmptyEmployee = (): Employee => ({

src/pods/project/api/project.api-model.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@ export interface Project {
1010
export interface EmployeeSummary {
1111
id: string;
1212
isAssigned?: boolean;
13-
employeeName: string;
13+
employeeId: string;
1414
}

src/pods/project/api/project.mock-data.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,22 @@ import { Project, EmployeeSummary } from './project.api-model';
33
const mockEmployeeSummaryList: EmployeeSummary[] = [
44
{
55
id: '1',
6-
employeeName: 'Daniel Perez',
6+
employeeId: 'Daniel Perez',
77
isAssigned: true,
88
},
99
{
1010
id: '2',
11-
employeeName: 'Jose Sanchez',
11+
employeeId: 'Jose Sanchez',
1212
isAssigned: false,
1313
},
1414
{
1515
id: '3',
16-
employeeName: 'Javier Benitez',
16+
employeeId: 'Javier Benitez',
1717
isAssigned: false,
1818
},
1919
{
2020
id: '4',
21-
employeeName: 'María Peña',
21+
employeeId: 'María Peña',
2222
isAssigned: true,
2323
},
2424
];
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import React from 'react';
2+
import {
3+
RowRendererProps,
4+
RowComponent,
5+
CellComponent,
6+
} from 'common/components';
7+
import Checkbox from '@material-ui/core/Checkbox';
8+
import { EmployeeSummary } from '../project.vm';
9+
10+
type Props = RowRendererProps<EmployeeSummary>;
11+
12+
export const ProjectRowComponent: React.FunctionComponent<Props> = ({
13+
row,
14+
}) => {
15+
return (
16+
<RowComponent>
17+
<CellComponent>
18+
<Checkbox checked={row.isAssigned} color="primary" />
19+
</CellComponent>
20+
<CellComponent>{row.employeeName}</CellComponent>
21+
</RowComponent>
22+
);
23+
};

src/pods/project/components/employee.component.tsx

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
import React from 'react';
2+
import { TableContainer, RowRendererProps } from 'common/components';
23
import { EmployeeSummary } from '../project.vm';
4+
import { CommandFooterComponent } from 'common-app/command-footer';
5+
import { ProjectRowComponent } from './employee-row.component';
36

47
interface Props {
58
employeeSummaryList: EmployeeSummary[];
@@ -10,5 +13,16 @@ export const EmployeeComponent: React.FunctionComponent<Props> = ({
1013
employeeSummaryList,
1114
onCancel,
1215
}) => {
13-
return <h1>Hello Employee Component</h1>;
16+
return (
17+
<>
18+
<TableContainer
19+
columns={['Asignado', 'Proyecto']}
20+
rows={employeeSummaryList}
21+
rowRenderer={(rowProps: RowRendererProps<EmployeeSummary>) => (
22+
<ProjectRowComponent {...rowProps} />
23+
)}
24+
/>
25+
<CommandFooterComponent onCancel={onCancel} />
26+
</>
27+
);
1428
};

0 commit comments

Comments
 (0)