From b4f3e9609d9f9911187f58b006a14532a90bf427 Mon Sep 17 00:00:00 2001 From: Kastan Day Date: Wed, 31 Jan 2024 13:46:05 -0800 Subject: [PATCH] Fix /new page with webscrape: auto redirect to /materials page (#106) * Fix /new page with webscrape. Auto redirect to /materials page. * minor cleanup --- src/components/UIUC-Components/WebScrape.tsx | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/components/UIUC-Components/WebScrape.tsx b/src/components/UIUC-Components/WebScrape.tsx index 8febec30..92ab6f84 100644 --- a/src/components/UIUC-Components/WebScrape.tsx +++ b/src/components/UIUC-Components/WebScrape.tsx @@ -150,7 +150,7 @@ export const WebScrape = ({ if (is_new_course) { // set course exists in new metadata endpoint - const response = callSetCourseMetadata(courseName, { + const response = await callSetCourseMetadata(courseName, { course_owner: current_user_email, // Don't set properties we don't know about. We'll just upsert and use the defaults. course_admins: [], @@ -166,9 +166,8 @@ export const WebScrape = ({ if (!response) { throw new Error('Error while setting course metadata') } - router.push(`/${courseName}/materials`) } - router.push(`/${courseName}/materials`) + await router.push(`/${courseName}/materials`) } else if (url.includes('canvas.illinois.edu/courses/')) { const canvasCourseIdParts = url.split('canvas.illinois.edu/courses/') const canvasCourseId = canvasCourseIdParts[1]?.split('/')[0] @@ -205,7 +204,7 @@ export const WebScrape = ({ if (response.data.outcome) { console.log('Canvas content ingestion was successful!') // Navigate to the course materials page or any other success behavior - router.push(`/${courseName}/materials`) + await router.push(`/${courseName}/materials`) } else { console.error('Canvas content ingestion failed.') // Handle the failure, maybe show a notification or alert to the user @@ -228,7 +227,7 @@ export const WebScrape = ({ if (is_new_course) { // set course exists in fast course_metadatas KV db - const response = callSetCourseMetadata(courseName, { + const response = await callSetCourseMetadata(courseName, { course_owner: current_user_email, // Don't set properties we don't know about. We'll just upsert and use the defaults. course_admins: [], @@ -243,7 +242,7 @@ export const WebScrape = ({ if (!response) { throw new Error('Error while setting course metadata') } - router.replace(`/${courseName}/materials`) + await router.push(`/${courseName}/materials`) } } } else {