fix: Error when you try to edit a course from a button

This commit is contained in:
swve 2024-06-14 00:35:57 +01:00
parent f524ddb51a
commit 0fb213ee4e
7 changed files with 22 additions and 17 deletions

View file

@ -34,7 +34,7 @@ export function CourseProvider({ children, courseuuid }: any) {
}, [courseStructureData]);
if (error) return <div>Failed to load course structure</div>;
if (!courseStructureData) return <PageLoading />;
if (!courseStructureData) return '';
if (courseStructureData) {
return (

View file

@ -142,8 +142,9 @@ function ActivityElement(props: ActivitiyElementProps) {
''
)}/edit`
}
prefetch
className=" hover:cursor-pointer p-1 px-3 bg-sky-700 rounded-md items-center"
rel="noopener noreferrer"
target='_blank' // hotfix for an editor prosemirror bug
>
<div className="text-sky-100 font-bold text-xs flex items-center space-x-1">
<FilePenLine size={12} /> <span>Edit Page</span>
@ -162,6 +163,7 @@ function ActivityElement(props: ActivitiyElementProps) {
''
)}`
}
prefetch
className=" hover:cursor-pointer p-1 px-3 bg-gray-200 rounded-md font-bold text-xs flex items-center space-x-1"
rel="noopener noreferrer"
>

View file

@ -25,7 +25,7 @@ interface EditorWrapperProps {
function EditorWrapper(props: EditorWrapperProps): JSX.Element {
const session = useLHSession() as any
const access_token = session?.data?.tokens?.access_token;
const access_token = session?.data?.tokens?.access_token;
// Define provider in the state
const [provider, setProvider] = React.useState<HocuspocusProvider | null>(null);
const [thisPageColor, setThisPageColor] = useState(randomColor({ luminosity: 'light' }) as string)
@ -51,7 +51,7 @@ function EditorWrapper(props: EditorWrapperProps): JSX.Element {
}, 10);
};
// Store the Y document in the browser
new IndexeddbPersistence(props.activity.activity_uuid, doc)
@ -80,7 +80,7 @@ function EditorWrapper(props: EditorWrapperProps): JSX.Element {
}
});
toast.promise(updateActivity(activity, activity.activity_uuid,access_token), {
toast.promise(updateActivity(activity, activity.activity_uuid, access_token), {
loading: 'Saving...',
success: <b>Activity saved!</b>,
error: <b>Could not save.</b>,