Skip to content

Commit df75b51

Browse files
author
Antonio Contreras LEMONCODE
committed
Refactor components and apply styles to report and project
1 parent 46175cc commit df75b51

9 files changed

Lines changed: 70 additions & 16 deletions

src/pods/employee/employee.component.tsx

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {
44
TabListComponent,
55
TabPanelComponent,
66
} from 'common/components';
7+
import AppBar from '@material-ui/core/AppBar';
78
import { DataComponent, ProjectComponent, ReportComponent } from './components';
89
import { Employee } from './employee.vm';
910
import * as classes from './employee.styles';
@@ -26,11 +27,13 @@ export const EmployeeComponent: React.FunctionComponent<Props> = ({
2627
const [tab, setTab] = React.useState(0);
2728
return (
2829
<>
29-
<TabListComponent value={tab} onChange={setTab}>
30-
<TabComponent label="Datos" />
31-
<TabComponent label="Proyectos" disabled={!isEditMode} />
32-
<TabComponent label="Informes" disabled={!isEditMode} />
33-
</TabListComponent>
30+
<AppBar position="static">
31+
<TabListComponent value={tab} onChange={setTab}>
32+
<TabComponent label="Datos" />
33+
<TabComponent label="Proyectos" disabled={!isEditMode} />
34+
<TabComponent label="Informes" disabled={!isEditMode} />
35+
</TabListComponent>
36+
</AppBar>
3437
<TabPanelComponent value={tab} index={0}>
3538
<DataComponent
3639
employee={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-
employeeId: string;
13+
employeeName: 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-
employeeId: 'Daniel Perez',
6+
employeeName: 'Daniel Perez',
77
isAssigned: true,
88
},
99
{
1010
id: '2',
11-
employeeId: 'Jose Sanchez',
11+
employeeName: 'Jose Sanchez',
1212
isAssigned: false,
1313
},
1414
{
1515
id: '3',
16-
employeeId: 'Javier Benitez',
16+
employeeName: 'Javier Benitez',
1717
isAssigned: false,
1818
},
1919
{
2020
id: '4',
21-
employeeId: 'María Peña',
21+
employeeName: 'María Peña',
2222
isAssigned: true,
2323
},
2424
];

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,19 @@ interface Props {
88
project: Project;
99
onSave: (project: Project) => void;
1010
onCancel: () => void;
11+
className: string;
1112
}
1213

1314
export const DataComponent: React.FunctionComponent<Props> = ({
1415
project,
1516
onSave,
1617
onCancel,
18+
className,
1719
}) => {
1820
return (
1921
<Formik initialValues={project} enableReinitialize={true} onSubmit={onSave}>
2022
{() => (
21-
<Form>
23+
<Form className={className}>
2224
<TextFieldComponent
2325
label="Id"
2426
name="id"

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,20 @@ import { ProjectRowComponent } from './employee-row.component';
77
interface Props {
88
employeeSummaryList: EmployeeSummary[];
99
onCancel: () => void;
10+
className: string;
1011
}
1112

1213
export const EmployeeComponent: React.FunctionComponent<Props> = ({
1314
employeeSummaryList,
1415
onCancel,
16+
className,
1517
}) => {
1618
return (
1719
<>
1820
<TableContainer
19-
columns={['Asignado', 'Proyecto']}
21+
columns={['Asignado', 'Empleado']}
2022
rows={employeeSummaryList}
23+
className={className}
2124
rowRenderer={(rowProps: RowRendererProps<EmployeeSummary>) => (
2225
<ProjectRowComponent {...rowProps} />
2326
)}

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,28 @@ import { Formik, Form } from 'formik';
33
import { SelectComponent } from 'common/components';
44
import { monthList } from 'common/constants';
55
import { CommandFooterComponent } from 'common-app/command-footer';
6+
import { cx } from 'emotion';
7+
import * as classes from './report.styles';
68

79
interface Props {
810
onCancel: () => void;
11+
className: string;
912
}
1013

1114
export const ReportComponent: React.FunctionComponent<Props> = ({
1215
onCancel,
16+
className,
1317
}) => {
1418
return (
1519
<Formik initialValues={{}} enableReinitialize={true} onSubmit={console.log}>
1620
{() => (
17-
<Form>
21+
<Form className={cx(classes.form, className)}>
1822
<SelectComponent
1923
name="month"
2024
label="Mes"
2125
items={monthList}
2226
disabled
27+
className={classes.month}
2328
/>
2429
<SelectComponent
2530
name="year"
@@ -31,10 +36,12 @@ export const ReportComponent: React.FunctionComponent<Props> = ({
3136
},
3237
]}
3338
disabled
39+
className={classes.year}
3440
/>
3541
<CommandFooterComponent
3642
onCancel={onCancel}
3743
labels={{ saveButton: 'Generar', cancelButton: 'Cancelar' }}
44+
className={classes.commands}
3845
/>
3946
</Form>
4047
)}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { css } from 'emotion';
2+
import { theme } from 'core/theme';
3+
4+
export const form = css`
5+
display: grid;
6+
grid-template-columns: 1fr;
7+
grid-template-areas: 'month' 'year' 'commands' 'commands';
8+
grid-column-gap: ${theme.spacing(2)}px;
9+
10+
@media (min-width: ${theme.breakpoints.values.md}px) {
11+
grid-template-columns: 1fr 1fr;
12+
grid-template-areas: 'month year' 'commands commands';
13+
}
14+
`;
15+
16+
export const month = css`
17+
grid-area: month;
18+
`;
19+
20+
export const year = css`
21+
grid-area: year;
22+
`;
23+
24+
export const commands = css`
25+
grid-area: commands;
26+
`;

src/pods/project/project.component.tsx

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,14 @@ import {
44
TabListComponent,
55
TabPanelComponent,
66
} from 'common/components';
7-
import { AppBar } from '@material-ui/core';
7+
import AppBar from '@material-ui/core/AppBar';
88
import {
99
DataComponent,
1010
EmployeeComponent,
1111
ReportComponent,
1212
} from './components';
1313
import { Project } from './project.vm';
14+
import * as classes from './project.styles';
1415

1516
interface Props {
1617
isEditMode: boolean;
@@ -36,16 +37,22 @@ export const ProjectComponent: React.FunctionComponent<Props> = ({
3637
</TabListComponent>
3738
</AppBar>
3839
<TabPanelComponent value={tab} index={0}>
39-
<DataComponent project={project} onCancel={onCancel} onSave={onSave} />
40+
<DataComponent
41+
project={project}
42+
onCancel={onCancel}
43+
onSave={onSave}
44+
className={classes.root}
45+
/>
4046
</TabPanelComponent>
4147
<TabPanelComponent value={tab} index={1}>
4248
<EmployeeComponent
4349
employeeSummaryList={project.employees}
4450
onCancel={onCancel}
51+
className={classes.root}
4552
/>
4653
</TabPanelComponent>
4754
<TabPanelComponent value={tab} index={2}>
48-
<ReportComponent onCancel={onCancel} />
55+
<ReportComponent onCancel={onCancel} className={classes.root} />
4956
</TabPanelComponent>
5057
</>
5158
);

src/pods/project/project.styles.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { css } from 'emotion';
2+
import { theme } from 'core/theme';
3+
4+
export const root = css`
5+
margin-top: ${theme.spacing(1.5)}px;
6+
`;

0 commit comments

Comments
 (0)