@@ -8,11 +8,12 @@ import cn from 'classnames'
8
8
import CheckBox from './CheckBox'
9
9
import redirect from '../../lib/Redirect'
10
10
import Radio from './Radio'
11
- import FormInput from '../styles/FormInput'
11
+ import FormSection from '../styles/FormSection'
12
+ import FormButton from '../styles/FormButton'
12
13
import FormTitle from '../styles/FormTitle'
13
14
import ClearFix from '../styles/ClearFix'
14
15
import Select from './Select'
15
- import FormButton from '../styles/FormButton '
16
+ import DatePicker from 'react-datepicker '
16
17
17
18
class AddContractForm extends react . Component {
18
19
constructor ( props ) {
@@ -22,6 +23,9 @@ class AddContractForm extends react.Component {
22
23
selectedBusinessUnit : '' ,
23
24
selectedLawyer : '' ,
24
25
contract : {
26
+ executionDate : null ,
27
+ effectiveDate : null ,
28
+ expiryDate : null ,
25
29
internalParties : [ 'ACME Inc' ] ,
26
30
externalParties : [ ] ,
27
31
currentStatus : [ ] ,
@@ -34,6 +38,24 @@ class AddContractForm extends react.Component {
34
38
}
35
39
}
36
40
41
+ handleExecutionDate = date => {
42
+ let contract = this . state . contract
43
+ contract . executionDate = date
44
+ this . setState ( { contract } )
45
+ }
46
+
47
+ handleEffectiveDate = date => {
48
+ let contract = this . state . contract
49
+ contract . effectiveDate = date
50
+ this . setState ( { contract } )
51
+ }
52
+
53
+ handleExpiryDate = date => {
54
+ let contract = this . state . contract
55
+ contract . expiryDate = date
56
+ this . setState ( { contract } )
57
+ }
58
+
37
59
handleClick = e => {
38
60
e . preventDefault ( )
39
61
this . props . addContract ( this . state . contract )
@@ -55,7 +77,16 @@ class AddContractForm extends react.Component {
55
77
handleStatusChange = e => {
56
78
let { contract } = this . state
57
79
let status = e . target . value
58
- let date = new Date ( ) . getTime ( )
80
+ let date = null
81
+ if ( status !== 'Executed' ) {
82
+ contract . executionDate = null
83
+ this . setState ( { contract } )
84
+ date = new Date ( ) . getTime ( )
85
+ } else {
86
+ if ( contract . executionDate ) {
87
+ date = contract . executionDate . valueOf ( )
88
+ } else date = null
89
+ }
59
90
contract . statuses . push ( { status, date } )
60
91
contract . currentStatus = status
61
92
this . setState ( { selectedStatus : status , contract } )
@@ -121,6 +152,7 @@ class AddContractForm extends react.Component {
121
152
selectedLawyer,
122
153
selectedBusinessUnit
123
154
} = this . state
155
+
124
156
let businessUnitSelect = (
125
157
< div className = 'mb2' >
126
158
< select
@@ -153,50 +185,97 @@ class AddContractForm extends react.Component {
153
185
) ) }
154
186
</ div >
155
187
)
156
- let { externalParties } = this . state . contract
188
+ let {
189
+ externalParties,
190
+ executionDate,
191
+ expiryDate,
192
+ effectiveDate
193
+ } = this . state . contract
194
+
157
195
return (
158
196
< div >
159
197
< Header client = { this . props . client } user = { this . props . loggedUser } />
160
- < div className = 'center pa3 mw6 bg-haus mt3 ' >
198
+ < div className = 'center pa3 mw6 bg-haus mt4 shadow-4 ' >
161
199
< form >
162
- < div className = 'b f4 bb bw1 w-100 pb2' > Add contract</ div >
163
- < FormInput >
200
+ < div className = 'b f4 bb bw1 b--black-50 w-100 pb2' >
201
+ Add contract
202
+ </ div >
203
+ < FormSection >
164
204
< Input
165
205
onChange = { this . saveToState }
166
206
value = { externalParties }
167
207
placeholder = 'External party'
168
208
label = 'External party'
169
209
name = 'externalParty'
170
210
/>
171
- </ FormInput >
211
+ </ FormSection >
172
212
< ClearFix />
173
213
< FormTitle > Tags</ FormTitle >
174
- < FormInput >
214
+ < FormSection >
175
215
{ tagInputs }
176
- </ FormInput >
216
+ </ FormSection >
177
217
< ClearFix />
178
218
< FormTitle > Status</ FormTitle >
179
- < FormInput >
219
+ < FormSection >
180
220
< Radio
181
221
handleChange = { this . handleStatusChange }
182
222
selectedItem = { selectedStatus }
183
223
items = { allStatuses }
184
224
/>
185
- </ FormInput >
225
+ </ FormSection >
226
+ < ClearFix />
227
+ < FormSection >
228
+ < FormTitle > Execution date</ FormTitle >
229
+ < DatePicker
230
+ className = 'pa2'
231
+ selected = { executionDate }
232
+ onChange = { this . handleExecutionDate }
233
+ placeholderText = 'Execution date'
234
+ showMonthDropdown
235
+ showYearDropdown
236
+ dateFormat = 'DD/MM/YYYY'
237
+ />
238
+ </ FormSection >
239
+ < ClearFix />
240
+ < FormSection >
241
+ < FormTitle > Effective date</ FormTitle >
242
+ < DatePicker
243
+ className = 'pa2'
244
+ selected = { effectiveDate }
245
+ onChange = { this . handleEffectiveDate }
246
+ placeholderText = 'Effective date'
247
+ showMonthDropdown
248
+ showYearDropdown
249
+ dateFormat = 'DD/MM/YYYY'
250
+ />
251
+ </ FormSection >
252
+ < ClearFix />
253
+ < FormSection >
254
+ < FormTitle > Expiry date</ FormTitle >
255
+ < DatePicker
256
+ className = 'pa2'
257
+ selected = { expiryDate }
258
+ onChange = { this . handleExpiryDate }
259
+ placeholderText = 'Expiry date'
260
+ showMonthDropdown
261
+ showYearDropdown
262
+ dateFormat = 'DD/MM/YYYY'
263
+ />
264
+ </ FormSection >
186
265
< ClearFix />
187
- < FormTitle > Business Units </ FormTitle >
188
- < FormInput >
266
+ < FormTitle > Business Unit </ FormTitle >
267
+ < FormSection >
189
268
{ businessUnitSelect }
190
- </ FormInput >
269
+ </ FormSection >
191
270
< ClearFix />
192
271
< FormTitle > Lawyer</ FormTitle >
193
- < FormInput >
272
+ < FormSection >
194
273
< Select
195
274
selectedItem = { selectedLawyer }
196
275
items = { allLawyers }
197
276
handleChange = { this . handleLawyerChange }
198
277
/>
199
- </ FormInput >
278
+ </ FormSection >
200
279
< ClearFix />
201
280
< FormButton onClick = { this . handleClick } />
202
281
< ClearFix />
0 commit comments