Skip to content

Commit

Permalink
fix: update the cance/reset logic in course management
Browse files Browse the repository at this point in the history
  • Loading branch information
marianzburlea committed Jul 19, 2019
1 parent ff1f7f8 commit 6a555c5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/component/course-edit/course-edit.component.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react'
import { StyledActionButtonWrapper, StyledCourseEdit } from './course-edit.style';

const CourseEdit = ({ title, handleTitle, addCourse, courseIdToEdit, description, handleDescription }) => {
const CourseEdit = ({ title, handleTitle, addCourse, courseIdToEdit, description, handleDescription, handleCancel }) => {
return (
<StyledCourseEdit>
<input
Expand All @@ -20,7 +20,7 @@ const CourseEdit = ({ title, handleTitle, addCourse, courseIdToEdit, description
<button onClick={addCourse}>
{courseIdToEdit ? 'Save course' : 'Add course'}
</button>
{courseIdToEdit && <button onClick={handleTitle}>
{courseIdToEdit && <button onClick={handleCancel}>
Cancel
</button>}
</StyledActionButtonWrapper>
Expand Down
7 changes: 7 additions & 0 deletions src/component/course-panel/course-panel.component.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,12 @@ const CoursePanel = () => {
}
setTitle(value)
}

const handleCancel = () => {
setCourseIdToEdit(null)
setTitle('')
setDescription('')
}

const handleDescription = e => {
const { value } = e.target
Expand All @@ -122,6 +128,7 @@ const CoursePanel = () => {
<CourseEdit
addCourse={addCourse}
handleTitle={handleTitle}
handleCancel={handleCancel}
courseIdToEdit={courseIdToEdit}
description={courseEditValue.description}
handleDescription={handleDescription}
Expand Down

0 comments on commit 6a555c5

Please sign in to comment.