-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue #PS-2103: Add Workspace UI implementation in admin portal
- Loading branch information
1 parent
b5c6d18
commit d7a7d1b
Showing
1 changed file
with
2 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,12 @@ | ||
import React, { useEffect, useState } from "react"; | ||
import dynamic from "next/dynamic"; | ||
import { serverSideTranslations } from "next-i18next/serverSideTranslations"; | ||
import Loader from "@/components/Loader"; | ||
import { useTranslation } from "next-i18next"; | ||
|
||
// @ts-ignore | ||
const Editors = dynamic(() => import("editor/Editor"), { ssr: false }); | ||
|
||
const Editor = () => { | ||
const { t } = useTranslation(); | ||
const [isAssetsLoaded, setIsAssetsLoaded] = useState(false); | ||
|
||
useEffect(() => { | ||
const loadScriptAndStyles = () => { | ||
if (!document.getElementById("sunbird-editor-css")) { | ||
const link = document.createElement("link"); | ||
link.id = "sunbird-editor-css"; | ||
link.rel = "stylesheet"; | ||
link.href = | ||
"https://cdn.jsdelivr.net/npm/@tekdi/[email protected]/styles.css"; | ||
document.head.appendChild(link); | ||
} | ||
|
||
if (!document.getElementById("sunbird-editor-script")) { | ||
const script = document.createElement("script"); | ||
script.id = "sunbird-editor-script"; | ||
script.src = | ||
"https://cdn.jsdelivr.net/npm/@tekdi/[email protected]/sunbird-questionset-editor.js"; | ||
script.async = true; | ||
script.onload = () => setIsAssetsLoaded(true); | ||
document.body.appendChild(script); | ||
} else { | ||
setIsAssetsLoaded(true); | ||
} | ||
}; | ||
|
||
loadScriptAndStyles(); | ||
}, []); | ||
|
||
return ( | ||
<div> | ||
{isAssetsLoaded ? ( | ||
<Editors /> | ||
) : ( | ||
<Loader showBackdrop={false} loadingText={t("COMMON.LOADING")} /> | ||
)} | ||
</div> | ||
); | ||
return <Editors />; | ||
}; | ||
|
||
export default Editor; | ||
|
@@ -58,4 +18,4 @@ export async function getStaticProps({ locale }: any) { | |
...(await serverSideTranslations(locale, ["common"])), | ||
}, | ||
}; | ||
} | ||
} |