File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2,10 +2,21 @@ import React from 'react';
22import { Formik , Form } from 'formik' ;
33import { TextFieldComponent , CheckboxComponent } from 'common/components' ;
44import { CommandFooterComponent } from '../../../common-app/command-footer' ;
5+ import { Project } from '../project.vm' ;
56
6- export const DataComponent : React . FunctionComponent = ( ) => {
7+ interface Props {
8+ project : Project ;
9+ onSave : ( project : Project ) => void ;
10+ onCancel : ( ) => void ;
11+ }
12+
13+ export const DataComponent : React . FunctionComponent < Props > = ( {
14+ project,
15+ onSave,
16+ onCancel,
17+ } ) => {
718 return (
8- < Formik initialValues = { { } } enableReinitialize = { true } onSubmit = { console . log } >
19+ < Formik initialValues = { project } enableReinitialize = { true } onSubmit = { onSave } >
920 { ( ) => (
1021 < Form >
1122 < TextFieldComponent
@@ -19,6 +30,7 @@ export const DataComponent: React.FunctionComponent = () => {
1930 < TextFieldComponent label = "Id Externo" name = "externalId" />
2031 < TextFieldComponent label = "Comentarios" name = "comments" multiline />
2132 < CheckboxComponent label = "Activo" name = "isActive" color = "primary" />
33+ < CommandFooterComponent onCancel = { onCancel } />
2234 </ Form >
2335 ) }
2436 </ Formik >
Original file line number Diff line number Diff line change 11import React from 'react' ;
2+ import { EmployeeSummary } from '../project.vm' ;
23
3- export const EmployeeComponent : React . FunctionComponent = ( ) => {
4+ interface Props {
5+ employeeSummaryList : EmployeeSummary [ ] ;
6+ onCancel : ( ) => void ;
7+ }
8+
9+ export const EmployeeComponent : React . FunctionComponent < Props > = ( {
10+ employeeSummaryList,
11+ onCancel,
12+ } ) => {
413 return < h1 > Hello Employee Component</ h1 > ;
514} ;
Original file line number Diff line number Diff line change @@ -4,7 +4,13 @@ import { SelectComponent } from 'common/components';
44import { monthList } from 'common/constants' ;
55import { CommandFooterComponent } from 'common-app/command-footer' ;
66
7- export const ReportComponent : React . FunctionComponent = ( ) => {
7+ interface Props {
8+ onCancel : ( ) => void ;
9+ }
10+
11+ export const ReportComponent : React . FunctionComponent < Props > = ( {
12+ onCancel,
13+ } ) => {
814 return (
915 < Formik initialValues = { { } } enableReinitialize = { true } onSubmit = { console . log } >
1016 { ( ) => (
@@ -27,7 +33,7 @@ export const ReportComponent: React.FunctionComponent = () => {
2733 disabled
2834 />
2935 < CommandFooterComponent
30- onCancel = { console . log }
36+ onCancel = { onCancel }
3137 labels = { { saveButton : 'Generar' , cancelButton : 'Cancelar' } }
3238 />
3339 </ Form >
Original file line number Diff line number Diff line change @@ -10,13 +10,20 @@ import {
1010 EmployeeComponent ,
1111 ReportComponent ,
1212} from './components' ;
13+ import { Project } from './project.vm' ;
1314
1415interface Props {
1516 isEditMode : boolean ;
17+ project : Project ;
18+ onSave : ( project : Project ) => void ;
19+ onCancel : ( ) => void ;
1620}
1721
1822export const ProjectComponent : React . FunctionComponent < Props > = ( {
1923 isEditMode,
24+ project,
25+ onSave,
26+ onCancel,
2027} ) => {
2128 const [ tab , setTab ] = React . useState ( 0 ) ;
2229 return (
@@ -29,13 +36,16 @@ export const ProjectComponent: React.FunctionComponent<Props> = ({
2936 </ TabListComponent >
3037 </ AppBar >
3138 < TabPanelComponent value = { tab } index = { 0 } >
32- < DataComponent />
39+ < DataComponent project = { project } onCancel = { onCancel } onSave = { onSave } />
3340 </ TabPanelComponent >
3441 < TabPanelComponent value = { tab } index = { 1 } >
35- < EmployeeComponent />
42+ < EmployeeComponent
43+ employeeSummaryList = { project . employees }
44+ onCancel = { onCancel }
45+ />
3646 </ TabPanelComponent >
3747 < TabPanelComponent value = { tab } index = { 2 } >
38- < ReportComponent />
48+ < ReportComponent onCancel = { onCancel } />
3949 </ TabPanelComponent >
4050 </ >
4151 ) ;
Original file line number Diff line number Diff line change @@ -25,6 +25,14 @@ export const ProjectContainer: React.FunctionComponent = () => {
2525 }
2626 } ;
2727
28+ const handleSave = ( Project : Project ) => {
29+ console . log ( 'Guardado' ) ;
30+ } ;
31+
32+ const handleCancel = ( ) => {
33+ history . back ( ) ;
34+ } ;
35+
2836 React . useEffect ( ( ) => {
2937 const isEditMode = isEditModeHelper ( id ) ;
3038 setIsEditMode ( isEditMode ) ;
@@ -33,5 +41,12 @@ export const ProjectContainer: React.FunctionComponent = () => {
3341 }
3442 } , [ ] ) ;
3543
36- return < ProjectComponent isEditMode = { isEditMode } /> ;
44+ return (
45+ < ProjectComponent
46+ isEditMode = { isEditMode }
47+ project = { project }
48+ onSave = { handleSave }
49+ onCancel = { handleCancel }
50+ />
51+ ) ;
3752} ;
Original file line number Diff line number Diff line change @@ -4,13 +4,13 @@ import * as viewModel from './project.vm';
44
55const mapEmployeeSummaryFromApiToVm = (
66 employeeSummary : apiModel . EmployeeSummary
7- ) : viewModel . ProloyeeSummary => ( {
7+ ) : viewModel . EmployeeSummary => ( {
88 ...employeeSummary ,
99} ) ;
1010
1111const mapEmployeeSummaryListFromApiToVm = (
1212 employeeSummary : apiModel . EmployeeSummary [ ]
13- ) : viewModel . ProloyeeSummary [ ] =>
13+ ) : viewModel . EmployeeSummary [ ] =>
1414 mapToCollection ( employeeSummary , es => mapEmployeeSummaryFromApiToVm ( es ) ) ;
1515
1616export const mapProjectFromApiToVm = (
Original file line number Diff line number Diff line change @@ -4,10 +4,10 @@ export interface Project {
44 externalId ?: string ;
55 comments ?: string ;
66 isActive : boolean ;
7- employees : ProloyeeSummary [ ] ;
7+ employees : EmployeeSummary [ ] ;
88}
99
10- export interface ProloyeeSummary {
10+ export interface EmployeeSummary {
1111 id : string ;
1212 isAssigned ?: boolean ;
1313 employeeName : string ;
You can’t perform that action at this time.
0 commit comments