diff --git a/components/ClassInviteTable.js b/components/ClassInviteTable.js
index 5501a308a..f0ea0367c 100644
--- a/components/ClassInviteTable.js
+++ b/components/ClassInviteTable.js
@@ -30,12 +30,11 @@ export default function ClassInviteTable({
);
const ref = useRef();
- const userCurrentDomain = process.env.NEXTAUTH_URL;
const copy = async () => {
//Add the full URL to send to student
await navigator.clipboard.writeText(
- `${userCurrentDomain}/join/` + currentClass.classroomId
+ `${window.location.origin}/join/` + currentClass.classroomId
);
toast('Class code successfully copied', {
diff --git a/pages/join/[...joinCode].js b/pages/join/[...joinCode].js
index cf2065ab2..0fc8390af 100644
--- a/pages/join/[...joinCode].js
+++ b/pages/join/[...joinCode].js
@@ -1,4 +1,5 @@
import Head from 'next/head';
+import Link from 'next/link';
import Navbar from '../../components/navbar';
import { useState } from 'react';
import { useRouter } from 'next/router';
@@ -7,16 +8,35 @@ import AuthButton from '../../components/authButton';
import DisplayNotification from '../../components/displayNotification';
import { ToastContainer } from 'react-toastify';
import 'react-toastify/dist/ReactToastify.css';
+import prisma from '../../prisma/prisma';
export async function getServerSideProps(ctx) {
const userSession = await getSession(ctx);
+
+ const params = ctx.params || {};
+ const joinParam = params.joinCode || null;
+ const classroomId = Array.isArray(joinParam) ? joinParam[0] : joinParam;
+
+ let classroom = null;
+ if (classroomId) {
+ try {
+ classroom = await prisma.classroom.findUnique({
+ where: { classroomId },
+ select: { classroomName: true, description: true, classroomId: true }
+ });
+ } catch (err) {
+ classroom = null;
+ }
+ }
+
return {
props: {
- userSession: userSession
+ userSession: userSession,
+ classroom
}
};
}
-export default function JoinWithCode({ userSession }) {
+export default function JoinWithCode({ userSession, classroom }) {
const [formData] = useState({});
const router = useRouter();
const { joinCode } = router.query;
@@ -61,57 +81,84 @@ export default function JoinWithCode({ userSession }) {
+ We could not find a classroom for this invite link. Please check + the link or ask your teacher to resend the invite. +
++ Joining:{' '} + + {classroom.classroomName || classroom.classroomId} + +
+ )}+ If you have not enabled Classroom access on freeCodeCamp, + please open your settings and enable it before connecting. +
+ ++ Note: If you change the email on your freeCodeCamp account + later, you may need to reconnect to this classroom. +
Welcome
-
+ To join a Classroom, you must open the unique join link provided
+ by your instructor. The link should look like{' '}
+ /join/<classroomId>.
+