ManageCoursePage - handleChange function

master
Tudor Stanciu 2020-04-12 00:02:01 +03:00
parent 31834fdb59
commit f6970c99ee
1 changed files with 16 additions and 1 deletions

View File

@ -25,7 +25,22 @@ function ManageCoursePage({ courses, authors, actions, ...props }) {
} }
}, []); }, []);
return <CourseForm course={course} errors={errors} authors={authors} />; function handleChange(event) {
const { name, value } = event.target;
setCourse((prevCourse) => ({
...prevCourse,
[name]: name === "authorId" ? parseInt(value, 10) : value
}));
}
return (
<CourseForm
course={course}
errors={errors}
authors={authors}
onChange={handleChange}
/>
);
} }
ManageCoursePage.propTypes = { ManageCoursePage.propTypes = {