-
Notifications
You must be signed in to change notification settings - Fork 0
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
Draft: What? #285
base: release
Are you sure you want to change the base?
Draft: What? #285
Changes from all commits
d997199
3965c1e
d1ffd92
43c342c
9ed6aec
b40804d
38166dd
da7c2b5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -77,6 +77,7 @@ const refreshDirectionalLink = new RetryLink().split( | |
"Refresh", | ||
"ResetPassword", | ||
"Login", | ||
"Logout", | ||
"Signup_Register", | ||
"PublicCourses", | ||
].includes(operation.operationName), | ||
|
@@ -126,9 +127,10 @@ const errorLink = onError(({ graphQLErrors, networkError }) => { | |
/* eslint-enable no-console */ | ||
}); | ||
} | ||
// eslint-disable-next-line no-console | ||
if (networkError) console.log("[Network error]", networkError); | ||
if (networkError?.message === "Error: Failed to refresh access token!") { | ||
// if (networkError?.toString() === "Error: Failed to refresh access token!") { | ||
// window.location.href = "/logout"; | ||
// } | ||
if (networkError) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This seems a little risky since I'd imagine this would also sign people out if their internet briefly disconnected. Is there a particular reason to change the logic here? (i.e., was it not working before?) |
||
window.location.href = "/logout"; | ||
} | ||
}); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,7 @@ import { | |
Flex, | ||
VStack, | ||
Image, | ||
Show, | ||
} from "@chakra-ui/react"; | ||
|
||
import authAPIClient from "../../APIClients/AuthAPIClient"; | ||
|
@@ -50,7 +51,7 @@ const Signup = (): React.ReactElement => { | |
firstName, | ||
lastName, | ||
email, | ||
town, | ||
town.toLowerCase(), | ||
password, | ||
register, | ||
); | ||
|
@@ -80,7 +81,7 @@ const Signup = (): React.ReactElement => { | |
return ( | ||
<Flex> | ||
<Center flex="1"> | ||
<VStack marginLeft="30vh" marginRight="30vh"> | ||
<VStack w="40rem" maxW="100vw" p="0 1rem"> | ||
<Image | ||
height="13vh" | ||
marginBottom="2.5vh" | ||
|
@@ -106,7 +107,7 @@ const Signup = (): React.ReactElement => { | |
<Box display="flex"> | ||
<Input | ||
ref={nameRef} | ||
autocomplete="given-name" | ||
autoComplete="given-name" | ||
type="text" | ||
placeholder="First" | ||
value={firstName} | ||
|
@@ -117,7 +118,7 @@ const Signup = (): React.ReactElement => { | |
marginRight="1vh" | ||
/> | ||
<Input | ||
autocomplete="family-name" | ||
autoComplete="family-name" | ||
type="text" | ||
placeholder="Last" | ||
value={lastName} | ||
|
@@ -134,7 +135,7 @@ const Signup = (): React.ReactElement => { | |
</FormLabel> | ||
<Input | ||
type="email" | ||
autocomplete="email" | ||
autoComplete="email" | ||
value={email} | ||
placeholder="[email protected]" | ||
onChange={(event: React.FormEvent<HTMLInputElement>) => | ||
|
@@ -148,7 +149,7 @@ const Signup = (): React.ReactElement => { | |
City/Town | ||
</FormLabel> | ||
<Input | ||
autocomplete="address-level2" | ||
autoComplete="address-level2" | ||
type="text" | ||
value={town} | ||
placeholder="Shaughnessy" | ||
|
@@ -168,7 +169,7 @@ const Signup = (): React.ReactElement => { | |
<Input | ||
type="password" | ||
value={password} | ||
placeholder="●●●●●●●●" | ||
placeholder="Password" | ||
onChange={(event: React.FormEvent<HTMLInputElement>) => | ||
setPassword(event.currentTarget.value) | ||
} | ||
|
@@ -185,7 +186,7 @@ const Signup = (): React.ReactElement => { | |
<Input | ||
type="password" | ||
value={currentPassword} | ||
placeholder="●●●●●●●●" | ||
placeholder="Rewrite your password" | ||
onChange={(event: React.FormEvent<HTMLInputElement>) => | ||
setCurrentPassword(event.currentTarget.value) | ||
} | ||
|
@@ -227,7 +228,9 @@ const Signup = (): React.ReactElement => { | |
</Box> | ||
</VStack> | ||
</Center> | ||
<Image width="50vw" objectFit="cover" src={BackgroundImage} /> | ||
<Show above="md"> | ||
<Image width="50vw" h="100vh" objectFit="cover" src={BackgroundImage} /> | ||
</Show> | ||
</Flex> | ||
); | ||
}; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,7 @@ import { | |
Spacer, | ||
Text, | ||
useDisclosure, | ||
useToast, | ||
VStack, | ||
} from "@chakra-ui/react"; | ||
import { ChevronLeftIcon, EditIcon } from "@chakra-ui/icons"; | ||
|
@@ -83,31 +84,38 @@ const Sidebar = ({ | |
} = useDisclosure(); | ||
|
||
const context: EditorContextType = useContext(EditorContext); | ||
const { data: courseData, error } = useQuery<{ course: CourseResponse }>( | ||
GET_COURSE, | ||
{ variables: { id: courseID } }, | ||
); | ||
const { data: courseData, error: queryError } = useQuery<{ | ||
course: CourseResponse; | ||
}>(GET_COURSE, { variables: { id: courseID } }); | ||
|
||
const module = courseData?.course?.modules?.[moduleIndex] as ModuleResponse; | ||
|
||
const [updateCourse] = useMutation<{ updateCourse: CourseResponse }>( | ||
UPDATE_COURSE, | ||
{ | ||
refetchQueries: [ | ||
{ | ||
query: GET_COURSE, | ||
variables: { id: courseID }, | ||
}, | ||
], | ||
}, | ||
); | ||
const [updateLesson] = useMutation<{ updateLesson: LessonResponse }>( | ||
UPDATE_LESSON, | ||
); | ||
const [createLesson] = useMutation<{ createLesson: LessonResponse }>( | ||
CREATE_LESSON, | ||
const [updateCourse, { error: updateCourseError }] = useMutation<{ | ||
updateCourse: CourseResponse; | ||
}>(UPDATE_COURSE, { | ||
refetchQueries: [ | ||
{ | ||
query: GET_COURSE, | ||
variables: { id: courseID }, | ||
}, | ||
], | ||
}); | ||
const [updateLesson, { error: updateLessonError }] = useMutation<{ | ||
updateLesson: LessonResponse; | ||
}>(UPDATE_LESSON); | ||
const [createLesson, { error: createLessonError }] = useMutation<{ | ||
createLesson: LessonResponse; | ||
}>(CREATE_LESSON); | ||
const [deleteLesson, { error: deleteLessonError }] = useMutation( | ||
DELETE_LESSON, | ||
); | ||
const [deleteLesson] = useMutation(DELETE_LESSON); | ||
|
||
const saveToast = useToast(); | ||
const mutationError = | ||
updateCourseError || | ||
updateLessonError || | ||
createLessonError || | ||
deleteLessonError; | ||
|
||
const { state, dispatch } = context; | ||
|
||
|
@@ -145,7 +153,7 @@ const Sidebar = ({ | |
const formatCourseRequest = ( | ||
newModule?: ModuleRequest, | ||
): [string, CourseRequest] => { | ||
if (!courseData || error) | ||
if (!courseData || queryError) | ||
throw Error( | ||
"Attempted to edit module when course does not contain modules", | ||
); | ||
|
@@ -225,7 +233,23 @@ const Sidebar = ({ | |
}), | ||
); | ||
setIsSaving(false); | ||
dispatch({ type: "clear-change-log" }); | ||
|
||
if (mutationError) { | ||
saveToast({ | ||
title: "An error occured while saving.", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe add "Please try again later!" to be friendlier? |
||
description: `Error: ${mutationError}`, | ||
status: "error", | ||
isClosable: true, | ||
}); | ||
} else { | ||
saveToast({ | ||
title: "Module saved successfully!", | ||
status: "success", | ||
duration: 3000, | ||
isClosable: true, | ||
}); | ||
dispatch({ type: "clear-change-log" }); | ||
} | ||
}; | ||
|
||
const onCoursePageRoute = () => { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Surprised this didn't cause problems before?