diff --git a/client/src/components/LessonPage.js b/client/src/components/LessonPage.js index c1903f74..da33bd22 100644 --- a/client/src/components/LessonPage.js +++ b/client/src/components/LessonPage.js @@ -1,5 +1,5 @@ import React, { useState, useEffect } from 'react'; -import { Modal } from 'antd'; +import { Modal, Input } from 'antd'; import { FiEdit } from 'react-icons/fi'; import { EditorState, convertToRaw, convertFromRaw } from 'draft-js'; import TextEditor from './TextEditor'; @@ -12,6 +12,8 @@ const LessonPage = props => { const [editMode, setEditMode] = useState(false); const [title, setTitle] = useState(''); + const [replit, setReplit] = useState(''); + const [editedReplit, setEditedReplit] = useState(); const [descriptionState, setDescriptionState] = useState(EditorState.createEmpty()); const [resourcesState, setResourcesState] = useState(EditorState.createEmpty()); const [labState, setLabState] = useState(EditorState.createEmpty()); @@ -48,14 +50,23 @@ const LessonPage = props => { setExitTicketState(EditorState.createWithContent(content)); setOldExitTicketState(EditorState.createWithContent(content)); } + if (lesson[0].replitLink) { + const content = lesson[0].replitLink + setReplit(content); + setEditedReplit(content); + } }); }, [id]); const handleDescriptionChange = newState => { setDescriptionState(newState); - console.log(newState); + // console.log(newState); }; + const onChangeReplit = event => { + setEditedReplit(event.target.value); + } + const handleResourcesChange = newState => { setResourcesState(newState); }; @@ -85,6 +96,7 @@ const LessonPage = props => { editedResourcesState: convertToRaw(resourcesState.getCurrentContent()), editedLabState: convertToRaw(labState.getCurrentContent()), editedExitTicketState: convertToRaw(exitTicketState.getCurrentContent()), + editedReplitLink: editedReplit, }), headers: new Headers({ 'Content-Type': 'application/json', @@ -96,6 +108,7 @@ const LessonPage = props => { setOldResourcesState(resourcesState); setOldLabState(labState); setOldExitTicketState(exitTicketState); + setReplit(editedReplit); setEditMode(false); }) .catch(() => @@ -106,6 +119,38 @@ const LessonPage = props => { ); }; + let maybeReplit; + if (editMode) { + maybeReplit = ( +