Skip to content

Commit

Permalink
styling change, handle errors in lesson page
Browse files Browse the repository at this point in the history
  • Loading branch information
cidneyweng committed Mar 28, 2021
1 parent cf197cd commit 45ea690
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 4 deletions.
18 changes: 17 additions & 1 deletion client/src/components/LessonPage.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import React, { useState, useEffect } from 'react';
import { Modal } from 'antd';
import { FiEdit } from 'react-icons/fi';
import { EditorState, convertToRaw, convertFromRaw } from 'draft-js';
import TextEditor from './TextEditor';
import 'draft-js/dist/Draft.css';
import '../stylesheets/LessonPage.css';
import { handleErrors } from '../utils/helpers';

const LessonPage = props => {
const { id, ismentor } = props;
Expand Down Expand Up @@ -87,7 +89,21 @@ const LessonPage = props => {
headers: new Headers({
'Content-Type': 'application/json',
}),
}).then(setEditMode(false));
})
.then(handleErrors)
.then(() => {
setOldDescriptionState(descriptionState);
setOldResourcesState(resourcesState);
setOldLabState(labState);
setOldExitTicketState(exitTicketState);
setEditMode(false);
})
.catch(() =>
Modal.error({
title: 'Unable to save changes.',
centered: true,
}),
);
};

return (
Expand Down
6 changes: 4 additions & 2 deletions client/src/stylesheets/LessonPage.css
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,11 @@ h1,
border: none;
border-radius: 3px;
cursor: pointer;
width: 30px;
height: 30px;
min-width: 30px;
min-height: 30px;
color: grey;
padding-left: 8px;
padding-right: 8px;
}

.editorButton:hover {
Expand Down
2 changes: 1 addition & 1 deletion client/src/utils/addLink.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import { RichUtils, KeyBindingUtil, EditorState, CompositeDecorator } from 'draft-js';
import { RichUtils, KeyBindingUtil, EditorState } from 'draft-js';

export const linkStrategy = (contentBlock, callback, contentState) => {
contentBlock.findEntityRanges(character => {
Expand Down
9 changes: 9 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"debug": "~2.6.9",
"dotenv": "^6.2.0",
"draft-js": "^0.11.7",
"draft-js-plugins-editor": "^3.0.0",
"express": "~4.16.0",
"google-auth-library": "^6.1.6",
"joi": "^14.3.0",
Expand Down

0 comments on commit 45ea690

Please sign in to comment.