Skip to content

Commit

Permalink
Fix /new page with webscrape: auto redirect to /materials page (#106)
Browse files Browse the repository at this point in the history
* Fix /new page with webscrape. Auto redirect to /materials page.

* minor cleanup
  • Loading branch information
KastanDay authored Jan 31, 2024
1 parent 23fba6a commit b4f3e96
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/components/UIUC-Components/WebScrape.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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: [],
Expand All @@ -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]
Expand Down Expand Up @@ -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
Expand All @@ -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: [],
Expand All @@ -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 {
Expand Down

0 comments on commit b4f3e96

Please sign in to comment.