diff --git a/webclient/src/Courses.js b/webclient/src/Courses.js index 835d83c..0f089f4 100644 --- a/webclient/src/Courses.js +++ b/webclient/src/Courses.js @@ -5,7 +5,7 @@ import { Container, Divider, Dropdown, Form, Grid, Header, Icon, Image, Menu, Me import moment from 'moment'; import { isInstructor, requester } from './utils.js'; import { NotFound, PleaseLogin } from './Misc.js'; -import { InstructorCourseList } from './Instructor.js'; +import { InstructorCourseList, InstructorCourseDetail } from './Instructor.js'; export function Courses(props) { const [courses, setCourses] = useState(false); @@ -86,6 +86,10 @@ export function CourseDetail(props) {
'+x+'
').join('') + const [input, setInput] = useState({ + ...course, + description: course.is_old ? convertNewlineToPara(course.description) : course.description, + }); const [error, setError] = useState(false); const [loading, setLoading] = useState(false); const [success, setSuccess] = useState(false); - const id = props.card.id; - - const handleValues = (e, v) => setInput({ ...input, [v.name]: v.value }); - const handleUpload = (e, v) => setInput({ ...input, [v.name]: e.target.files[0] }); - const handleChange = (e) => handleValues(e, e.currentTarget); - const handleCheck = (e, v) => setInput({ ...input, [v.name]: v.checked }); + const { id } = useParams(); const handleSubmit = (e) => { setLoading(true); setSuccess(false); - const data = { ...input, member_id: props.result.member.id }; - requester('/cards/'+id+'/', 'PUT', props.token, data) + const data = { ...input, is_old: false }; + requester('/courses/'+id+'/', 'PUT', props.token, data) .then(res => { - setLoading(false); setSuccess(true); + setLoading(false); setError(false); - setInput(res); + setOpen(false); + props.setCourse({...course, ...res}); }) .catch(err => { setLoading(false); @@ -90,65 +92,28 @@ function InstructorCourseDetail(props) { }); }; - const handleDelete = (e) => { - e.preventDefault(); - - requester('/cards/'+id+'/', 'DELETE', props.token) - .then(res => { - setInput(false); - }) - .catch(err => { - console.log(err); - }); - }; + return ( +Saved!
} - return ( - input ? -Added to bottom of course list! View the course.
} + {!open && success &&Added to bottom of course list! View the course.
} {open ?