Skip to content
This repository was archived by the owner on Dec 24, 2022. It is now read-only.

Commit 711d2ce

Browse files
after post reset form done
1 parent 48f416c commit 711d2ce

File tree

2 files changed

+15
-29
lines changed

2 files changed

+15
-29
lines changed

src/forms/FormActionButtons.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ function FormActionButtons({ onClose, isSubmitting }) {
6060
</SubmitButton>
6161
</Col>
6262
</Row>
63-
{/* {process.env.NODE_ENV === 'development' && <Debug />} */}
63+
{process.env.NODE_ENV === 'development' && <Debug />}
6464
</>
6565
);
6666
}

src/forms/todo/todo.form.js

Lines changed: 14 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import moment from 'moment';
99

1010
import { API } from '../../services';
1111
import { FormActionButtons } from '../FormActionButtons';
12-
import { TODO_LABEL } from '../../helpers/';
12+
import { TODO_LABEL } from '../../helpers/constants';
1313

1414
const { Option } = Select;
1515

@@ -20,28 +20,22 @@ const TodoSchema = Yup.object({
2020
label: Yup.number().required('Label code required'),
2121
});
2222

23+
const TOMORROW = moment().add(1, 'days');
24+
2325
function TodoForm({ onClose, editMode, editableTodo }) {
2426
const dispatch = useDispatch();
2527
const [dueDate, setDueDate] = useState();
28+
const [todoLabel, setTodoLabel] = useState();
2629

2730
const initialValues = {
2831
title: editMode ? editableTodo.title : undefined,
2932
description: editMode ? editableTodo.description : undefined,
30-
dueDate: editMode ? editableTodo.phone : moment(),
33+
dueDate: editMode ? editableTodo.phone : TOMORROW,
3134
label: editMode ? editableTodo.label : 3,
3235
};
3336

3437
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-
// };
4338
console.log('values visit', values);
44-
4539
let url = `todos`;
4640

4741
if (editMode) {
@@ -64,6 +58,8 @@ function TodoForm({ onClose, editMode, editableTodo }) {
6458
.then(() => {
6559
showSuccessMessage(values);
6660
resetForm();
61+
setTodoLabel(1);
62+
setDueDate(TOMORROW);
6763
})
6864
.finally(() => {
6965
setSubmitting(false);
@@ -153,26 +149,16 @@ function TodoForm({ onClose, editMode, editableTodo }) {
153149
allowClear={true}
154150
optionFilterProp="children"
155151
onChange={(data) => {
152+
console.log('setTodoLabel', data);
153+
setTodoLabel(data);
156154
setFieldValue('label', data);
157155
}}
158-
filterOption={(input, option) =>
159-
option.props.children
160-
.toLowerCase()
161-
.indexOf(input.toLowerCase()) >= 0
162-
}
163156
>
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+
))}
176162
</Select>
177163
</Form.Item>
178164
</Col>

0 commit comments

Comments
 (0)