Skip to content

Commit

Permalink
On new course creation, properly redirect to /materials page (#86)
Browse files Browse the repository at this point in the history
  • Loading branch information
KastanDay authored Dec 20, 2023
1 parent 44aeb80 commit f47ee0e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 43 deletions.
9 changes: 8 additions & 1 deletion src/components/UIUC-Components/LargeDropzone.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,18 @@ export function LargeDropzone({
// console.log("in LargeDropzone.tsx ALL emailAddresses: ", user?.emailAddresses )

const refreshOrRedirect = async (redirect_to_gpt_4: boolean) => {
if (is_new_course) {
// refresh current page
await new Promise((resolve) => setTimeout(resolve, 200))
router.push(`/${courseName}/materials`)
return
}

if (redirect_to_gpt_4) {
router.push(`/${courseName}/chat`)
}
// refresh current page
await new Promise((resolve) => setTimeout(resolve, 700))
await new Promise((resolve) => setTimeout(resolve, 200))
router.reload()
}
const uploadToS3 = async (file: File | null, uniqueFileName: string) => {
Expand Down
33 changes: 2 additions & 31 deletions src/components/UIUC-Components/MakeNewCoursePage.tsx
Original file line number Diff line number Diff line change
@@ -1,26 +1,6 @@
import Head from 'next/head'
// import {
// Card,
// Text,
// Flex,
// Group,
// Checkbox,
// Col,
// Paper,
// Input,
// Textarea,
// FileInput,
// MediaQuery,
// type CheckboxProps,
// Title,
// } from '@mantine/core'

import React, { useState } from 'react'
// import GlobalHeader from './GlobalHeader'
// import GlobalFooter from './GlobalFooter'
// import EmailChipsComponent from './EmailChipsComponent'
// import { type CourseMetadata } from '~/types/courseMetadata'
// import LargeDropzone from './LargeDropzone'

import PlainNavbar from '~/components/UIUC-Components/navbars/PlainNavbar'
import { useMediaQuery } from '@mantine/hooks'
import EditCourseCard from '~/components/UIUC-Components/EditCourseCard'
Expand All @@ -32,15 +12,6 @@ const MakeNewCoursePage = ({
course_name: string
current_user_email: string
}) => {
const [introMessage, setIntroMessage] = useState('')
const [courseName, setCourseName] = useState(course_name || '')
const [isCourseAvailable, setIsCourseAvailable] = useState<
boolean | undefined
>(undefined)
const [allExistingCourseNames, setAllExistingCourseNames] = useState<
string[]
>([])
const isSmallScreen = useMediaQuery('(max-width: 960px)')

return (
<>
Expand All @@ -49,7 +20,7 @@ const MakeNewCoursePage = ({
<title>{course_name}</title>
<meta
name="description"
content="The AI teaching assistant built for students at UIUC."
content="Create a new project on UIUC.chat."
/>
<link rel="icon" href="/favicon.ico" />
</Head>
Expand Down
16 changes: 5 additions & 11 deletions src/components/UIUC-Components/WebScrape.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -133,11 +133,7 @@ export const WebScrape = ({
showToast()

if (is_new_course) {
// Make course exist in kv store
// Removing this for kv refactor
// await setCourseExistsAPI(courseName)

// set course exists in new metadata endpoint. Works great.
// set course exists in new metadata endpoint
const response = callSetCourseMetadata(courseName, {
course_owner: current_user_email,
// Don't set properties we don't know about. We'll just upsert and use the defaults.
Expand All @@ -153,7 +149,7 @@ export const WebScrape = ({
if (!response) {
throw new Error('Error while setting course metadata')
}
router.replace(`/${courseName}/materials`)
router.push(`/${courseName}/materials`)
}
router.push(`/${courseName}/materials`)
} else if (url.includes('canvas.illinois.edu/courses/')) {
Expand Down Expand Up @@ -498,11 +494,9 @@ export const WebScrape = ({
}}
size="md"
radius={'xl'}
className={`rounded-s-md ${
isUrlUpdated ? 'bg-purple-800' : 'border-purple-800'
} overflow-ellipsis text-ellipsis p-2 ${
isUrlUpdated ? 'text-white' : 'text-gray-500'
} min-w-[5rem] -translate-x-1 transform hover:border-indigo-600 hover:bg-indigo-600 hover:text-white focus:shadow-none focus:outline-none`}
className={`rounded-s-md ${isUrlUpdated ? 'bg-purple-800' : 'border-purple-800'
} overflow-ellipsis text-ellipsis p-2 ${isUrlUpdated ? 'text-white' : 'text-gray-500'
} min-w-[5rem] -translate-x-1 transform hover:border-indigo-600 hover:bg-indigo-600 hover:text-white focus:shadow-none focus:outline-none`}
w={`${isSmallScreen ? 'auto' : 'auto'}`}
disabled={isDisabled}
>
Expand Down

1 comment on commit f47ee0e

@vercel
Copy link

@vercel vercel bot commented on f47ee0e Dec 20, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.