Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix behavior when creating new course; Redirect to /materials #86

Merged
merged 1 commit into from
Dec 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
// 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`)
Dismissed Show dismissed Hide dismissed
Dismissed Show dismissed Hide dismissed
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 @@
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 @@
if (!response) {
throw new Error('Error while setting course metadata')
}
router.replace(`/${courseName}/materials`)
router.push(`/${courseName}/materials`)
Dismissed Show dismissed Hide dismissed
Dismissed Show dismissed Hide dismissed
}
router.push(`/${courseName}/materials`)
} else if (url.includes('canvas.illinois.edu/courses/')) {
Expand Down Expand Up @@ -498,11 +494,9 @@
}}
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
Loading