Skip to content

Commit

Permalink
chore: added formatting, removed mock data
Browse files Browse the repository at this point in the history
  • Loading branch information
Hardik-hi committed Aug 23, 2022
1 parent 82b7a84 commit 95bbfe6
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 1,150 deletions.
21 changes: 10 additions & 11 deletions packages/common-lib/src/services/contentPagesRegistryService.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
import { get, post, update as coreUpdate } from './RestClient'
import qs from 'qs'

export const getContentPageData = async (slug="", header = {}) => {
export const getContentPageData = async (slug = '', header = {}) => {
let headers = {
...header,
Authorization: 'Bearer ' + localStorage.getItem('token')
}

const result = await get(`http://localhost:3000/api/v1/contentPages/${slug}`, {
headers
})
const result = await get(
`http://localhost:3000/api/v1/contentPages/${slug}`,
{
headers
}
)
if (result.data.data) {
console.log(result);
return result.data.data;
console.log(result)
return result.data.data
} else {
return {error: 404}
return { error: 404 }
}
}




4 changes: 2 additions & 2 deletions packages/content-pages/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ function App() {
},
{
path: "*",
component: FourOFour
}
component: FourOFour,
},
];
const LoginComponent = React.lazy(() => import("core/Login"));

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { BodyMedium, Collapsible } from "@shiksha/common-lib";

const CollapsibleBlockComponent = ({ collapsibleHeader, collapsibleContent }) => {
const CollapsibleBlockComponent = ({
collapsibleHeader,
collapsibleContent,
}) => {
return (
<Collapsible
defaultCollapse
Expand Down
12 changes: 6 additions & 6 deletions packages/content-pages/src/components/RichtextBlockComponent.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
import { Box } from "@shiksha/common-lib";
import { useEffect, useState } from "react";
import { EditorState, convertToRaw, convertFromRaw } from "draft-js";
import draftToHtml from "draftjs-to-html";
import { mock1, mock2 } from "./mock";
import DOMPurify from "isomorphic-dompurify";

console.log(mock1);
export default function RichtextBlockComponent({initialData}) {
export default function RichtextBlockComponent({ initialData }) {
const [editorState, setEditorState] = useState(() =>
EditorState.createEmpty()
);
Expand All @@ -15,7 +12,6 @@ export default function RichtextBlockComponent({initialData}) {
useEffect(() => {
if (initialData) {
const rawContent = convertFromRaw(initialData);
console.log(rawContent, editorState);
setEditorState(EditorState.createWithContent(rawContent));
let currentContentAsHTML = draftToHtml(
convertToRaw(editorState.getCurrentContent())
Expand All @@ -24,5 +20,9 @@ export default function RichtextBlockComponent({initialData}) {
}
}, [convertedContent]);

return <div dangerouslySetInnerHTML={{ __html: DOMPurify.sanitize(convertedContent) }}></div>;
return (
<div
dangerouslySetInnerHTML={{ __html: DOMPurify.sanitize(convertedContent) }}
></div>
);
}
Loading

0 comments on commit 95bbfe6

Please sign in to comment.