@@ -9,7 +9,7 @@ import moment from 'moment';
9
9
10
10
import { API } from '../../services' ;
11
11
import { FormActionButtons } from '../FormActionButtons' ;
12
- import { TODO_LABEL } from '../../helpers/' ;
12
+ import { TODO_LABEL } from '../../helpers/constants ' ;
13
13
14
14
const { Option } = Select ;
15
15
@@ -20,28 +20,22 @@ const TodoSchema = Yup.object({
20
20
label : Yup . number ( ) . required ( 'Label code required' ) ,
21
21
} ) ;
22
22
23
+ const TOMORROW = moment ( ) . add ( 1 , 'days' ) ;
24
+
23
25
function TodoForm ( { onClose, editMode, editableTodo } ) {
24
26
const dispatch = useDispatch ( ) ;
25
27
const [ dueDate , setDueDate ] = useState ( ) ;
28
+ const [ todoLabel , setTodoLabel ] = useState ( ) ;
26
29
27
30
const initialValues = {
28
31
title : editMode ? editableTodo . title : undefined ,
29
32
description : editMode ? editableTodo . description : undefined ,
30
- dueDate : editMode ? editableTodo . phone : moment ( ) ,
33
+ dueDate : editMode ? editableTodo . phone : TOMORROW ,
31
34
label : editMode ? editableTodo . label : 3 ,
32
35
} ;
33
36
34
37
function handleSubmit ( values , { setErrors, resetForm, setSubmitting } ) {
35
- /**
36
- * below two keys no needed for post call
37
- */
38
-
39
- // let data = {
40
- // ...values,
41
- // phone: values.phone.toString(),
42
- // };
43
38
console . log ( 'values visit' , values ) ;
44
-
45
39
let url = `todos` ;
46
40
47
41
if ( editMode ) {
@@ -64,6 +58,8 @@ function TodoForm({ onClose, editMode, editableTodo }) {
64
58
. then ( ( ) => {
65
59
showSuccessMessage ( values ) ;
66
60
resetForm ( ) ;
61
+ setTodoLabel ( 1 ) ;
62
+ setDueDate ( TOMORROW ) ;
67
63
} )
68
64
. finally ( ( ) => {
69
65
setSubmitting ( false ) ;
@@ -153,26 +149,16 @@ function TodoForm({ onClose, editMode, editableTodo }) {
153
149
allowClear = { true }
154
150
optionFilterProp = "children"
155
151
onChange = { ( data ) => {
152
+ console . log ( 'setTodoLabel' , data ) ;
153
+ setTodoLabel ( data ) ;
156
154
setFieldValue ( 'label' , data ) ;
157
155
} }
158
- filterOption = { ( input , option ) =>
159
- option . props . children
160
- . toLowerCase ( )
161
- . indexOf ( input . toLowerCase ( ) ) >= 0
162
- }
163
156
>
164
- < Option key = { 1 } value = { 1 } >
165
- PERSONAL
166
- </ Option >
167
- < Option key = { 2 } value = { 2 } >
168
- WORK
169
- </ Option >
170
- < Option key = { 3 } value = { 3 } >
171
- SHOPPING
172
- </ Option >
173
- < Option key = { 4 } value = { 4 } >
174
- OTHER
175
- </ Option >
157
+ { TODO_LABEL . map ( ( { id, key } ) => (
158
+ < Option key = { id } value = { id } >
159
+ { key }
160
+ </ Option >
161
+ ) ) }
176
162
</ Select >
177
163
</ Form . Item >
178
164
</ Col >
0 commit comments