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

Draft: What? #285

Open
wants to merge 8 commits into
base: release
Choose a base branch
from
Open
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
4 changes: 2 additions & 2 deletions backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@
"cookie-parser": "^1.4.5",
"cors": "^2.8.5",
"dotenv": "^8.2.0",
"express": "^4.17.1",
"express": "^4.17.3",
"firebase-admin": "^9.5.0",
"fs-capacitor": "^6.2.0",
"graphql": "^15.5.0",
"graphql-middleware": "^6.0.6",
"graphql-upload": "^12.0.0",
"json2csv": "^5.0.6",
"lodash": "^4.17.21",
"mongoose": "^5.12.12",
"mongoose": "^5.13.15",
"multer": "^1.4.2",
"node-fetch": "^2.6.1",
"nodemailer": "^6.5.0",
Expand Down
292 changes: 141 additions & 151 deletions backend/yarn.lock

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@
"web-vitals": "^1.0.1"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject",
"start": "react-scripts --openssl-legacy-provider start",
"build": "react-scripts --openssl-legacy-provider build",
"test": "react-scripts --openssl-legacy-provider test",
"eject": "react-scripts --openssl-legacy-provider eject",
"lint": "eslint . --ext .ts,.tsx,.js,.jsx --cache",
"fix": "eslint . --ext .ts,.tsx,.js,.jsx --fix --cache"
},
Expand Down
8 changes: 5 additions & 3 deletions frontend/src/APIClients/BaseAPIClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ const refreshDirectionalLink = new RetryLink().split(
"Refresh",
"ResetPassword",
"Login",
"Logout",
Copy link
Contributor

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?

"Signup_Register",
"PublicCourses",
].includes(operation.operationName),
Expand Down Expand Up @@ -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) {
Copy link
Contributor

Choose a reason for hiding this comment

The 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";
}
});
Expand Down
5 changes: 4 additions & 1 deletion frontend/src/components/auth/Login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
VStack,
Input,
Center,
Show,
Spinner,
Alert,
AlertDescription,
Expand Down Expand Up @@ -406,7 +407,9 @@ const Login = (): React.ReactElement => {
{getLoginForm(loginState)}
</VStack>
</Center>
<Image maxH="100vh" w="50vw" objectFit="cover" src={BackgroundImage} />
<Show above="md">
<Image width="50vw" h="100vh" objectFit="cover" src={BackgroundImage} />
</Show>
</Flex>
);
};
Expand Down
21 changes: 12 additions & 9 deletions frontend/src/components/auth/Signup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
Flex,
VStack,
Image,
Show,
} from "@chakra-ui/react";

import authAPIClient from "../../APIClients/AuthAPIClient";
Expand Down Expand Up @@ -50,7 +51,7 @@ const Signup = (): React.ReactElement => {
firstName,
lastName,
email,
town,
town.toLowerCase(),
password,
register,
);
Expand Down Expand Up @@ -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"
Expand All @@ -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}
Expand All @@ -117,7 +118,7 @@ const Signup = (): React.ReactElement => {
marginRight="1vh"
/>
<Input
autocomplete="family-name"
autoComplete="family-name"
type="text"
placeholder="Last"
value={lastName}
Expand All @@ -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>) =>
Expand All @@ -148,7 +149,7 @@ const Signup = (): React.ReactElement => {
City/Town
</FormLabel>
<Input
autocomplete="address-level2"
autoComplete="address-level2"
type="text"
value={town}
placeholder="Shaughnessy"
Expand All @@ -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)
}
Expand All @@ -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)
}
Expand Down Expand Up @@ -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>
);
};
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/module-viewer/LessonViewer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const LessonViewer = ({
if (!focusedLesson) return <></>;

return (
<Flex ref={provided?.innerRef} height="100%" direction="column" flex="1">
<Flex ref={provided?.innerRef} h="max-content" minH="100%" direction="column" flex="1">
{lesson?.content.map((block: ContentBlockState, index: number) => (
<ContentBlock
editable={editable}
Expand Down
70 changes: 47 additions & 23 deletions frontend/src/components/module-viewer/SideBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
Spacer,
Text,
useDisclosure,
useToast,
VStack,
} from "@chakra-ui/react";
import { ChevronLeftIcon, EditIcon } from "@chakra-ui/icons";
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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",
);
Expand Down Expand Up @@ -225,7 +233,23 @@ const Sidebar = ({
}),
);
setIsSaving(false);
dispatch({ type: "clear-change-log" });

if (mutationError) {
saveToast({
title: "An error occured while saving.",
Copy link
Contributor

Choose a reason for hiding this comment

The 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 = () => {
Expand Down