fix: user avatar editor

This commit is contained in:
swve 2022-12-04 10:39:35 +01:00
parent 2995c8ec84
commit fec4437e0a
4 changed files with 14 additions and 14 deletions

View file

@ -15,7 +15,7 @@ function Element(props: any) {
<a target="_blank" rel="noopener noreferrer">&nbsp; <EyeOpenIcon/></a>
</Link>
<Link href={`/org/${props.orgslug}/course/${props.courseid}/element/${props.element.id.replace("element_", "")}/edit`}>
<a target="_blank" rel="noopener noreferrer">&nbsp; <Pencil2Icon/></a>
<a rel="noopener noreferrer">&nbsp; <Pencil2Icon/></a>
</Link>
</ElementWrapper>
)}

View file

@ -24,8 +24,6 @@ interface Editor {
function Editor(props: Editor) {
const auth: any = React.useContext(AuthContext);
console.log(props.element);
console.log(props.course);
const editor: any = useEditor({
extensions: [
@ -53,7 +51,7 @@ function Editor(props: Editor) {
return (
<div>
<motion.div
initial={{ opacity: 0, scale: 0.9 }}
initial={{ opacity: 0, scale: 0.98 }}
animate={{ opacity: 1, scale: 1 }}
key="modal"
transition={{
@ -83,13 +81,14 @@ function Editor(props: Editor) {
</EditorDocSection>
<EditorUsersSection>
<EditorUserProfileWrapper>
<Avvvatars value={auth.userInfo.user_object.user_id} style="shape" />
{!auth.isAuthenticated && <span>Loading</span>}
{auth.isAuthenticated && <Avvvatars value={auth.userInfo.user_object.user_id} style="shape" />}
</EditorUserProfileWrapper>
</EditorUsersSection>
</EditorTop>
</motion.div>
<motion.div
initial={{ opacity: 0, scale: 0.9 }}
initial={{ opacity: 0, scale: 0.99 }}
animate={{ opacity: 1, scale: 1 }}
key="modal"
transition={{
@ -100,9 +99,9 @@ function Editor(props: Editor) {
}}
exit={{ opacity: 0 }}
>
<EditorContentWrapper>
<EditorContent editor={editor} />
</EditorContentWrapper>
<EditorContentWrapper>
<EditorContent editor={editor} />
</EditorContentWrapper>
</motion.div>
</div>
);

View file

@ -12,14 +12,15 @@ export interface Auth {
isLoading: boolean;
}
const AuthProvider = (props: any) => {
const router = useRouter();
const [auth, setAuth] = React.useState<Auth>({ access_token: "", isAuthenticated: false, userInfo: {}, isLoading: true });
async function checkRefreshToken() {
let data = await getRefreshToken();
return data.access_token;
if (data) {
return data.access_token;
}
}
async function checkAuth() {
@ -27,13 +28,13 @@ const AuthProvider = (props: any) => {
let access_token = await checkRefreshToken();
let userInfo = {};
let isLoading = false;
if (access_token) {
userInfo = await getUserInfo(access_token);
setAuth({ access_token, isAuthenticated: true, userInfo, isLoading });
// if user is authenticated and tries to access login or signup page, redirect to home
if(NON_AUTHENTICATED_ROUTES.includes(router.pathname)) {
if (NON_AUTHENTICATED_ROUTES.includes(router.pathname)) {
router.push("/");
}
} else {

View file

@ -4,7 +4,7 @@ import styled from "styled-components";
import { Header } from "../../../../../../components//UI/Header";
import Layout from "../../../../../../components//UI/Layout";
import { Title } from "../../../../../../components//UI/Elements/Styles/Title";
import { DragDropContext, Droppable, Draggable } from "react-beautiful-dnd";
import { DragDropContext, Droppable } from "react-beautiful-dnd";
import { initialData, initialData2 } from "../../../../../../components/Drags/data";
import Chapter from "../../../../../../components/Drags/Chapter";
import { createChapter, deleteChapter, getCourseChaptersMetadata, updateChaptersMetadata } from "../../../../../../services/courses/chapters";