Skip to content

Commit

Permalink
Issue #PS-2103: Add Workspace UI implementation in admin portal
Browse files Browse the repository at this point in the history
  • Loading branch information
Arif-tekdi-technologies committed Oct 15, 2024
1 parent b5c6d18 commit d7a7d1b
Showing 1 changed file with 2 additions and 42 deletions.
44 changes: 2 additions & 42 deletions src/pages/editor.tsx
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;
Expand All @@ -58,4 +18,4 @@ export async function getStaticProps({ locale }: any) {
...(await serverSideTranslations(locale, ["common"])),
},
};
}
}

0 comments on commit d7a7d1b

Please sign in to comment.