Skip to content

Commit

Permalink
Merge branch 'master' into deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
Gabau committed Nov 13, 2023
2 parents 09deee2 + 81134da commit e4721e6
Show file tree
Hide file tree
Showing 13 changed files with 792 additions and 33 deletions.
27 changes: 3 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,30 +39,9 @@ Notes:

```bash
docker build -t peer-prep .
docker compose --profile prod up
docker compose --profile prod up -d
```

## What's next? How do I make an app with this?
## Production Environment

We try to keep this project as simple as possible, so you can start with just the scaffolding we set up for you, and add additional things later when they become necessary.

If you are not familiar with the different technologies used in this project, please refer to the respective docs. If you still are in the wind, please join our [Discord](https://t3.gg/discord) and ask for help.

- [Next.js](https://nextjs.org)
- [NextAuth.js](https://next-auth.js.org)
- [Prisma](https://prisma.io)
- [Tailwind CSS](https://tailwindcss.com)
- [tRPC](https://trpc.io)

## Learn More

To learn more about the [T3 Stack](https://create.t3.gg/), take a look at the following resources:

- [Documentation](https://create.t3.gg/)
- [Learn the T3 Stack](https://create.t3.gg/en/faq#what-learning-resources-are-currently-available) — Check out these awesome tutorials

You can check out the [create-t3-app GitHub repository](https://github.com/t3-oss/create-t3-app) — your feedback and contributions are welcome!

## How do I deploy this?

Follow our deployment guides for [Vercel](https://create.t3.gg/en/deployment/vercel), [Netlify](https://create.t3.gg/en/deployment/netlify) and [Docker](https://create.t3.gg/en/deployment/docker) for more information.
For Assignment 4 and beyond, do note there is an additional `.env` file that needs to be initialized in the folder `production`. If you are a grader, please refer to the secret submission `Assignment4-production.env.txt`.
Binary file modified docs/cs3219archi.pptx
Binary file not shown.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"prisma:generate": "prisma generate --schema prisma/mongodb/schema.prisma && prisma generate --schema prisma/postgres/schema.prisma",
"prisma:push": "prisma db push --schema prisma/mongodb/schema.prisma && prisma db push --schema prisma/postgres/schema.prisma",
"prisma:studio": "prisma studio --schema prisma/mongodb/schema.prisma | prisma studio --schema prisma/postgres/schema.prisma -p 5556",
"docker:up": "docker compose up",
"docker:up": "docker compose up -d",
"docker:down": "docker compose down",
"start-dev": "./start-dev-script.sh"
},
Expand Down
23 changes: 22 additions & 1 deletion src/components/NavBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@ const NavBar = () => {
const toggleDropdown = () => {
setIsDropdownOpen(!isDropdownOpen);
};
const { data: session } = useSession();

const closeDropdown = () => setIsDropdownOpen(false);

const { data: session } = useSession();

return (
<div className="relative bg-slate-800 py-3">
<div className="">
Expand Down Expand Up @@ -82,6 +83,26 @@ const NavBar = () => {
>
SignIn
</Link>}
{
session?.user.role === "MAINTAINER" &&
<Link
href="/maintainer/testcases"
onClick={closeDropdown}
className="flex items-center justify-center font-bold text-white no-underline transition hover:bg-white/20 rounded-md whitespace-nowrap bg-white/10 flex-[1_0_0%] px-4"
>
Test cases
</Link>
}
{
session?.user.role === "MAINTAINER" &&
<Link
href="/maintainer/environments"
onClick={closeDropdown}
className="flex items-center justify-center font-bold text-white no-underline transition hover:bg-white/20 rounded-md whitespace-nowrap bg-white/10 flex-[1_0_0%] px-4"
>
Environments
</Link>
}
{session && <div
onClick={() => {
void signOut();
Expand Down
12 changes: 9 additions & 3 deletions src/hooks/useQuestions.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useState, useEffect } from "react";
import toast from "react-hot-toast";
import { CodeOutput, Difficulty, Language, Question, TestCase } from "~/types/global";
import { CodeOutput, Difficulty, Environment, Language, Question, TestCase } from "~/types/global";
import { api } from "~/utils/api";

type UseQuestionsReturn = {
Expand Down Expand Up @@ -39,6 +39,7 @@ type UseQuestionsReturn = {
currentLanguage: Language | undefined;
setCurrentLanguage: (lang: Language) => void;
environmentId: string;
environment: Environment | undefined | null;
/**
* The submission status
*/
Expand Down Expand Up @@ -72,7 +73,6 @@ export default function useQuestions(): UseQuestionsReturn {
passed: number,
numOfTests: number
} | undefined>(undefined);

const questions =
api.question.getAllReduced.useQuery(undefined, {
onError: (e) => {
Expand Down Expand Up @@ -166,7 +166,7 @@ export default function useQuestions(): UseQuestionsReturn {
);

const currentTest = testCases.data?.find((val) => {
val.id === testCaseId
return val.id === testCaseId
});

useEffect(() => {
Expand All @@ -180,6 +180,7 @@ export default function useQuestions(): UseQuestionsReturn {
}
}, [submissionStatus])

// update testcase related info
useEffect(() => {
setTestCaseIdList(
testCases?.data?.map(({ id, description }) => ({ id, description })) ??
Expand Down Expand Up @@ -224,5 +225,10 @@ export default function useQuestions(): UseQuestionsReturn {
});
},
submissionStatus: tempSubmissionStatus,
environment: currentEnvironment ? {
...currentEnvironment,
prepend: currentEnvironment?.prepend ?? "",
append: currentEnvironment?.append ?? "",
} : undefined
};
}
10 changes: 9 additions & 1 deletion src/pages/collab/rooms/[id].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -192,9 +192,17 @@ const Output = ({
name="output"
id="output"
className="mt-3 h-full min-h-[2rem] w-full p-2 font-mono box-border bg-gray-500 border border-gray-300 text-gray-900 sm:text-sm rounded-lg dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white "
value={output?.status.description ?? ""}
value={output?.status?.description ?? ""}
readOnly
/>
{output?.compile_output && <><em>Compile output</em>
<textarea
name="output"
id="output"
className="mt-3 h-full min-h-[8rem] w-full p-2 font-mono box-border bg-gray-500 border border-gray-300 text-gray-900 sm:text-sm rounded-lg dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white "
value={output?.compile_output ?? ""}
readOnly
/></>}
</label>
</div>
);
Expand Down
Loading

0 comments on commit e4721e6

Please sign in to comment.